[eluser]phybertek[/eluser]
Hello,
I'm having a hard time understanding how to query categories and subcategories from a database and passing this data from the model, to the controller and out to the view.
Table format:
Main
-----
id
name
value
date
Sub
----
id
mainid
name
value
desc
date
Code:
public function getvMain()
{
$query = $this->db->get_where('vmain',array('status' => 'active'));
return $query->result();
}
public function getvCat($id)
{
$query = $this->db->get_where('vcat',array('mainid' => $id));
return $query->result();
}
I have a few methods in my model class. Method 1 selects * from main using active record class. and method 2 does the same for the sub. I'm trying to figure out how to combine this data as there is a One to Many relationship. Is there anyway to merge this data and sent it to my view?