Tidy up selectMessages method.

parent b814a923
...@@ -208,24 +208,25 @@ class DB ...@@ -208,24 +208,25 @@ class DB
} }
try { try {
//message table $sql = '
$query = 'SELECT * FROM `' . TB_MESSAGE . '` '; SELECT *
$query .= 'WHERE ' . TB_MESSAGE . '.`update_id` != 0 '; FROM `' . TB_MESSAGE . '`
$query .= 'ORDER BY ' . TB_MESSAGE . '.`message_id` DESC'; WHERE `update_id` != 0
ORDER BY `message_id` DESC
';
if (!is_null($limit)) { if ($limit !== null) {
$query .= ' LIMIT :limit '; $sql .= 'LIMIT :limit';
} }
$sth = self::$pdo->prepare($query); $sth = self::$pdo->prepare($sql);
$sth->bindParam(':limit', $limit, PDO::PARAM_INT); $sth->bindParam(':limit', $limit, PDO::PARAM_INT);
$sth->execute(); $sth->execute();
$results = $sth->fetchAll(PDO::FETCH_ASSOC);
return $sth->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) { } catch (PDOException $e) {
throw new TelegramException($e->getMessage()); throw new TelegramException($e->getMessage());
} }
return $results;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment