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;
}