Tidy up selectTelegramUpdate method.

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