I am trying to inner join two tables using CodeIgniter's query builder. My coding attempt is emitting an error:
Unknown column 'category' in 'where clause'
My coding attempt:
$query = $this->db
->select('title, name as category, rental_rate, length')
->order_by($sort_by, $sort_order);
$query = $this->db->join('film_category', 'film_category.film_id = film.film_id');
$query = $this->db->join('category', 'film_category.category_id = category.category_id');
if (strlen($query_array['title'])) {
$query->like('title', $query_array['title']);
}
if (strlen($query_array['category'])) {
$query->where('category', $query_array['category']);
}
$data['films'] = $query->get('film', 20, $this->uri->segment(6));
If I only put 'film' (without the join() calls), it cannot find 'category' column in another table.
categorycolumn within your table I think it should benameinstead ofcategoryfilmWHEREtitleLIKE '%ac%' ESCAPE '!' ANDname= 'Horror' ANDlength> '100'