I need help on this plz :
2 tables
Service : has many Sub_Service Sub_Service : has one Service
My code :
$services = new Service();
$services->where('org_id', $org_id)->get();
$services->sub_service->get();
foreach($services as $service)
{
echo $service->title;
foreach($service->sub_service as $sub_service)
{
echo $sub_service->title;
}
}
But it doesn’t work, if I want to access sub_service i have to take it out of the first loop and do somthing like
foreach($services->sub_service as $sub_service)
{
echo $sub_service->title;
}
But this is not what I want, i want to get an array like this one :
Service 1
—Subservice 1
—Subservice 3
Service 2
Service 3
—Subservice 2
Info i’m using DM 1.8 and CI2.
Thx for ur help
Try using the 'all' property available in datamapper objects