<?php
class Product {
const SHOW_BY_DEFAULT = 10;
public static function getLatestProducts($count = self::SHOW_BY_DEFAULT) {
$count = intval($count);
$db = Db::getConnection();
$productList = array();
$result = $db->query('SELECT id, name, new FROM product WHERE status = "1" LIMIT'.$count);
$i = 0;
while ($row = $result->fetch()) {
$productList[$i]['id'] = $row['id'];
$productList[$i]['name'] = $row['name'];
$productList[$i]['new'] = $row['new'];
$i++;
}
return $productList;
}
}
Fatal error: Call to a member function fetch() on a non-object in C:\OpenServer\domains\keram\models\product.php on line 19
while ($row = $result->fetch())
) В чём вопрос?while ($row = $result->fetch()) {
:)