Exemplo n.º 1
0
 /**
  * @param string $table - table for check field
  * @param string $field - check this field
  * @return bool
  */
 public static function checkField($table, $field)
 {
     $cResult = DB::query(Database::SELECT, 'SHOW FIELDS FROM `' . $table . '`')->execute();
     $found = FALSE;
     foreach ($cResult as $arr) {
         if ($arr['Field'] == $field) {
             $found = TRUE;
         }
     }
     return $found;
 }
Exemplo n.º 2
0
 public function listAction()
 {
     $this->_template = 'ItemsList';
     Route::factory()->setAction('list');
     // Filter parameters to array if need
     Filter::setFilterParameters();
     // Set filter elements sortable
     Filter::setSortElements();
     $page = !(int) Route::param('page') ? 1 : (int) Route::param('page');
     // Check for existance
     $group = DB::select()->from('catalog_tree')->where('alias', '=', Route::param('alias'))->where('status', '=', 1)->as_object()->execute()->current();
     if (!$group) {
         return Config::error();
     }
     // Seo
     $this->setSeoForGroup($group);
     // Add plus one to views
     DB::update('catalog_tree')->set(array('views' => (int) $group->views + 1))->where('id', '=', $group->id)->execute();
     // Get items list
     $result = Filter::getFilteredItemsList($this->limit, ($page - 1) * $this->limit, $this->sort, $this->type);
     // Generate filter add for sql queries
     $add = Filter::getSql();
     // Count of parent groups
     $count = DB::query(Database::SELECT, 'SELECT COUNT(DISTINCT catalog.id) AS count FROM catalog ' . $add['join'] . 'WHERE catalog.parent_id = "' . $group->id . '" AND catalog.status = "1"' . $add['where'])->as_object()->execute()->current();
     if ($count) {
         $count = $count->count;
     } else {
         $count = 0;
     }
     // Generate pagination
     $pager = Pager::factory($page, $count, $this->limit)->create();
     // Render page
     $this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Catalog/ItemsList');
 }