<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
	
	class Mod_category extends CI_Model
	{
		
		function category($title)
		{
			$this->db->where("catSlug",$title);
			$this->db->from("blog_cats");	
			$q = $this->db->get();
			if($q->num_rows() > 0)
			{
				return $q->row();
			}
			return false;	
		}	
		
		
		function getcategory($id,$c=1,$ID="")
		{
			$this->db->SELECT("*");
			$this->db->from("blog_post_cats");
			$this->db->where("blog_post_cats.catID",$id);
			$this->db->order_by('blog_post_cats.id','DESC');
			
			if($this->uri->segment(4))
			{
				$c = ($this->uri->segment(4)) ;
			}
			
			if($c==1)
			{
				$start=0;	
			}else{
				$start=($c*10)-10;			
			}
			$count=10;
			
			if($ID=="")
			{
				$this->db->limit($count,$start);
			} 	
			return $this->db->get();
			
		}
			
	
		function category_countAll($subcatID)
		{
			$this->db->where("catID",$subcatID);
			return $this->db->count_all_results('blog_post_cats');
		}
		
		
		function show_article($id)
		{	
			$this->db->SELECT("*");
			$this->db->from("blog_posts");
			$this->db->where("postStatus",1);
			$this->db->where("postID",$id);
			$this->db->join('tbluser', 'tbluser.userid = blog_posts.postBy','left');
			return $this->db->get();
			
		}
		
	}