Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $this->db->select("*, articles.article_id as tmp_art_id,
- (SELECT COUNT(".$this->db->dbprefix."comments.comment_id)
- FROM ".$this->db->dbprefix."comments WHERE ".$this->db->dbprefix."comments.comment_parent_id = ".$this->db->dbprefix."articles.article_id
- AND ".$this->db->dbprefix('comments.comment_on_module')." = '".$this->router->fetch_module()."')
- AS article_num_comment,
- (SELECT GROUP_CONCAT(".$this->db->dbprefix."category.category_id) FROM ".$this->db->dbprefix."category
- JOIN ".$this->db->dbprefix."cat2article ON ".$this->db->dbprefix."cat2article.cat2_category_id = ".$this->db->dbprefix."category.category_id
- JOIN ".$this->db->dbprefix."articles ON ".$this->db->dbprefix."articles.article_id = ".$this->db->dbprefix."cat2article.cat2_article_id
- WHERE ".$this->db->dbprefix."articles.article_id = tmp_art_id)
- AS cat_id,
- (SELECT GROUP_CONCAT(".$this->db->dbprefix."category.category_title) FROM ".$this->db->dbprefix."category
- JOIN ".$this->db->dbprefix."cat2article ON ".$this->db->dbprefix."cat2article.cat2_category_id = ".$this->db->dbprefix."category.category_id
- JOIN ".$this->db->dbprefix."articles ON ".$this->db->dbprefix."articles.article_id = ".$this->db->dbprefix."cat2article.cat2_article_id
- WHERE ".$this->db->dbprefix."articles.article_id = tmp_art_id)
- AS cat_title,
- (SELECT GROUP_CONCAT(".$this->db->dbprefix."category.category_url) FROM ".$this->db->dbprefix."category
- JOIN ".$this->db->dbprefix."cat2article ON ".$this->db->dbprefix."cat2article.cat2_category_id = ".$this->db->dbprefix."category.category_id
- JOIN ".$this->db->dbprefix."articles ON ".$this->db->dbprefix."articles.article_id = ".$this->db->dbprefix."cat2article.cat2_article_id
- WHERE ".$this->db->dbprefix."articles.article_id = tmp_art_id)
- AS cat_url", FALSE);
- $this->db->join('cat2article', 'cat2article.cat2_article_id = articles.article_id');
- $this->db->join('category', 'category.category_id = cat2article.cat2_category_id');
- $this->db->groupby('articles.article_id');
- if ($this->article_type) $this->db->where('article_type',$this->article_type);
- if ($this->article_url) $this->db->where('article_url',$this->article_url);
- if ($this->article_publish) $this->db->where('article_publish',$this->article_publish);
- if (isset($this->current_page) and $this->per_page) $this->db->limit($this->per_page, $this->current_page);
- if ($this->category_url) $this->db->where('category_url',$this->category_url);
- $this->db->order_by('article_datetime','desc');
- $article = $this->db->get('articles')->result_array();
- if (array_key_exists('0', $article))
- {
- foreach (array_keys($article) AS $post_key)
- {
- $tmp_categories = explode(',', $article[$post_key]['cat_title']);
- $tmp_url_categories = explode(',', $article[$post_key]['cat_url']);
- $article[$post_key]['category'] = '';
- foreach (array_keys($tmp_categories) AS $key)
- {
- $tmp_categories[$key] = anchor('category/read/' . $tmp_url_categories[$key], $tmp_categories[$key]);
- }
- $article[$post_key]['category'] = implode(', ', $tmp_categories);
- }
- }
- $this->count_rows = count($article);//printvar($article);die;
- return $article;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement