diff --git a/ground/classes/Model.php b/ground/classes/Model.php index 5a6f3ed..fcc1004 100644 --- a/ground/classes/Model.php +++ b/ground/classes/Model.php @@ -46,13 +46,19 @@ class Model } /** - * Возвращает массив с ассоциативными массивами, соответствующими записями в БД. - * @return array - */ - function getAll() + * Возвращает массив с ассоциативными массивами, соответствующими записями в БД. + * @param string $where просто строка с условиями: (`id` > 1) AND (`name` == 'TEST') + * @param string $order строка с именем толбца и напрабления: `summ` DESC + * @return type + */ + function getAll($where = '', $order = '') { /* TODO: Переделать этот метод. Сделать статическим, возвращать массив объектов. */ - $res = App::$DB->query('SELECT * FROM ' . $this->_tableName_); + $sql = 'SELECT * FROM ' . $this->_tableName_; + $sql .= $where ? ' WHERE '.$where : ''; + $sql .= $order ? ' ORDER BY '.$order : ''; + + $res = App::$DB->query($sql); $this->_id_ = NULL; // Это больше не конкретная запись $ready = array(); diff --git a/ground/controllers/IndexController.php b/ground/controllers/IndexController.php index ed30b40..43d945f 100644 --- a/ground/controllers/IndexController.php +++ b/ground/controllers/IndexController.php @@ -19,7 +19,7 @@ class IndexController extends Controller $category = new Category(); self::render('indexTemplate.php', array( - 'categories' => $category->getAll(), + 'categories' => $category->getAll('', 'ord'), )); } diff --git a/public/ico/cup.png b/public/ico/cup.png new file mode 100644 index 0000000..6171df1 Binary files /dev/null and b/public/ico/cup.png differ