M
M
maxwellum2015-10-31 16:42:51
CodeIgniter
maxwellum, 2015-10-31 16:42:51

How to exclude the main category from related content?

Hello. I started to master the CodeIgniter 2.x framework, and I had the following question: how to exclude the main category when generating similar news? For example, Movies > Action Movies, in similar content I need only Action Movies, but all movies are displayed. Thanks in advance.

function get_similar_videos($current_video_id, $categories){
    $query = $this->db->select('videos.title,videos.sef_uri,videos.image,videos.image,videos.view,videos.imdb,categories.sef_uri AS cat_sef_uri')
         		  ->from('videos')
         		  ->join('videos_category','videos_category.video_id = videos.video_id','LEFT OUTER')
         		  ->join('categories','videos.category_id = categories.cat_id','LEFT')
         	      ->where('videos.status',1)
         		  ->where_in('videos_category.category_id',$categories)
         		  ->where('videos.video_id !=',$current_video_id)
         		  ->group_by('videos.video_id')
         		  ->order_by('videos.title','ASC')
         		  ->limit(10)
         		  ->get('');

    if($query->num_rows() > 0){
      return $query->result();
    }
    return FALSE;
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rikcon, 2015-11-01
@maxwellum

->where('videos_category.category_id !=', $current_category_id);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question