Longman\TelegramBot\ConversationDB::selectConversation PHP Method

selectConversation() public static method

Select a conversation from the DB
public static selectConversation ( integer $user_id, integer $chat_id, boolean $limit = null ) : array | boolean
$user_id integer
$chat_id integer
$limit boolean
return array | boolean
    public static function selectConversation($user_id, $chat_id, $limit = null)
    {
        if (!self::isDbConnected()) {
            return false;
        }
        try {
            $query = 'SELECT * FROM `' . TB_CONVERSATION . '` ';
            $query .= 'WHERE `status` = :status ';
            $query .= 'AND `chat_id` = :chat_id ';
            $query .= 'AND `user_id` = :user_id ';
            if (!is_null($limit)) {
                $query .= ' LIMIT :limit';
            }
            $sth = self::$pdo->prepare($query);
            $active = 'active';
            $sth->bindParam(':status', $active, PDO::PARAM_STR);
            $sth->bindParam(':user_id', $user_id, PDO::PARAM_INT);
            $sth->bindParam(':chat_id', $chat_id, PDO::PARAM_INT);
            $sth->bindParam(':limit', $limit, PDO::PARAM_INT);
            $sth->execute();
            $results = $sth->fetchAll(PDO::FETCH_ASSOC);
        } catch (Exception $e) {
            throw new TelegramException($e->getMessage());
        }
        return $results;
    }