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 . '`
if (!is_null($limit)) { ORDER BY `id` DESC
$query .= ' LIMIT :limit '; ';
if ($limit !== null) {
$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