rajesh rajesh - 7 months ago 52
MySQL Question

Codeigniter - Database select


I need a help related to Codeigniter very badly.

I have some problems with a database query, i'am new to Codeigniter.

I have 3 tables:

1) film(film_id, filmname) PK (film_id)
2) category(category_id, categoryname) PK (category_id)
3) film_category(contains both primary keys (film_id) and (category_id))

The problem is that I want to
select all filmname from film tables where category_id = 3

How to do this with active record class?

Please make a suggestion.

I'am new to Codeigniter and I love it.

Thank you in advance from your friend.


Something like that:

$this->db->join('film_category fc', 'fc.film_id = f.film_id');
$this->db->where('fc.category_id', 3);
$query = $this->db->get('film f');

I find the ActiveRecord one of the most useful and elegant parts of CodeIgniter.