[eluser]artlover[/eluser]
I have a model (below), it returns last 9 works from works table.
and I need to get data from a different table (tbl_photo) which has the id_work.
normally I would run a sql in a while loop and to match tbl_photo.id_work with table work.id
but how can I do that in codeigniter and how can pass that in MVC :/ im very confused. please help!! thanks!
Code:
function get_last9work()
{
$q = $this->db->get('works', 9);
if($q->num_rows() > 0) {
foreach ($q->result() as $row) {
$data[] = $row;
}
return $data;
} else {
return false;
}
}