PHP:
скопировать код в буфер обмена
скопировать код в буфер обмена
- public static function getList($numRows=1000000, $categoryId=null, $order="publicationDate DESC") {
- $conn = new PDO(DB_DNS, DB_USERNAME, DB_PASSWORD);
- $categoryClause = $categoryId ? "WHERE categoryId = :categoryId" : "";
- $sql = "SELECT SQL_CALC_FOUND_ROWS *, UNIX_TIMESTAMP(publicationDate) AS publicationDate
- FROM articles $categoryClause
- $sth = $conn->prepare($sql);
- $sth->bindValue(":numRows", $numRows, PDO::PARAM_INT);
- $sth->execute();
- while($row = $sth->fetch()) {
- $article = new Article($row);
- $list[] = $article;
- }
- $sql = "SELECT FOUND_ROWS() AS totalRows";
- $totalRows = $conn->query($sql)->fetch();
- $conn = null;
- }