function getNewCategoy($catID, $start = 0, $limit = 10) { global $mainframe, $db; $list_ids = getListObjectID("videos"); $where = array(); $where[] = "A.status = 1"; $where[] = "B.status = 1"; $where[] = "A.catID = {$catID} "; if ($list_ids != false and $list_ids != "") { $where[] = "A.id not in({$list_ids})"; } $where = implode(" AND ", $where); $query = "SELECT A.*, B.alias cat_alias, B.title cat_title " . "FROM " . TBL_VIDEOS . " A LEFT JOIN " . TBL_CATEGORIES . " B ON A.catID = B.id " . " WHERE {$where} " . " ORDER BY A.cdate DESC LIMIT {$start}, {$limit}"; $query_command = $db->createCommand($query); $items = $query_command->queryAll(); if (count($items)) { foreach ($items as &$item) { $item['link'] = Yii::app()->createUrl("videos/detail", array("id" => $item['id'], "alias" => $item['alias'])); addObjectID($item['id'], "videos"); } } return $items; }
function getArticlesCategoy($catID, $start = 0, $limit = 10) { global $mainframe, $db; $list_idnews = getListObjectID("news"); $where = array(); $where[] = "A.status = 1"; $where[] = "B.status = 1"; $where[] = "A.catid = {$catID} "; if ($list_idnews != false and $list_idnews != "") { $where[] = "A.id not in({$list_idnews})"; } $where = implode(" AND ", $where); $query_command = Yii::app()->db->createCommand(); $query_command->select("A.*, B.alias cat_alias, B.title cat_title")->from($this->tablename . " A")->leftJoin($this->tbl_category . " B", "A.catID = B.id")->where($where)->order("A.created DESC, A.ordering DESC")->limit($limit, $start); $items = $query_command->queryAll(); if (count($items)) { foreach ($items as &$item) { $params = array("view" => "detail", "id" => $item['id'], "alias" => $item['alias'], "catID" => $item['catID'], "cat_alias" => $item['cat_alias']); $item['link'] = Router::buildLink('articles', $params); addObjectID($item['id'], "news"); } } return $items; }