07-16-2011, 01:44 PM
[eluser]vadimyer[/eluser]
Hello there.
I have a search_model with main function that creates the search query:
For example, this query returns 2 results (2 movies), when in controller, I have no problems printing them out:
This returns those 2 movies in separated divs, as formatted in HTML.
But the question is: How can I fetch additional data related to each one movie? For example, I have a separate table called "actors" which contains actor.id, actor.name and actor.movie_id (which equals to movies.id), and 5 actors related to one movie, and say 7 actors related to the second movie.
How do I do that? Also, actors can have additional columns like URI, actor_image etc. as well.
Please, if you can, post in code. Cause I'm stucked with this problem 2 days and didn't find a solution yet.
I like CI very much and don't wanna go back to WordPress, hehe.
THANKS IN ADVANCE!
Hello there.
I have a search_model with main function that creates the search query:
Code:
$query = $this->db->query("SELECT movies.title, movies.id FROM movies WHERE movies.title LIKE '%$match%'");
return $query;
For example, this query returns 2 results (2 movies), when in controller, I have no problems printing them out:
Code:
foreach($query->result() as $row) { echo $row->id; }
This returns those 2 movies in separated divs, as formatted in HTML.
But the question is: How can I fetch additional data related to each one movie? For example, I have a separate table called "actors" which contains actor.id, actor.name and actor.movie_id (which equals to movies.id), and 5 actors related to one movie, and say 7 actors related to the second movie.
How do I do that? Also, actors can have additional columns like URI, actor_image etc. as well.
Please, if you can, post in code. Cause I'm stucked with this problem 2 days and didn't find a solution yet.

THANKS IN ADVANCE!