Tidy up selectTelegramUpdate method.

parent f28f9b02
...@@ -173,22 +173,24 @@ class DB ...@@ -173,22 +173,24 @@ class DB
} }
try { try {
$query = 'SELECT `id` FROM `' . TB_TELEGRAM_UPDATE . '` '; $sql = '
$query .= 'ORDER BY `id` DESC'; SELECT `id`
FROM `' . TB_TELEGRAM_UPDATE . '`
ORDER BY `id` DESC
';
if (!is_null($limit)) { if ($limit !== null) {
$query .= ' LIMIT :limit '; $sql .= 'LIMIT :limit';
} }
$sth_select_telegram_update = self::$pdo->prepare($query); $sth = self::$pdo->prepare($sql);
$sth_select_telegram_update->bindParam(':limit', $limit, PDO::PARAM_INT); $sth->bindParam(':limit', $limit, \PDO::PARAM_INT);
$sth_select_telegram_update->execute(); $sth->execute();
$results = $sth_select_telegram_update->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