Hello,
am a little confused trying to build a join from 3 different tables. First
of all, I noticed in the debug toolbar it was hitting the table 20 times
which is the number of records i have although i made a join.
this is my action code
$c = new Criteria();
$c->add(AreaPeer::DISTRICTS_ID,
$request->getParameter('search_input_districts'));
$c->addJoin(AreaPeer::ID, ResturantAreaPeer::AREA_ID);
$c->addJoin(ResturantAreaPeer::RESTURANTS_ID, ResturantsPeer::ID);
$c->add(ResturantsPeer::IS_ACTIVE, TRUE);
$this->objs = AreaPeer::doSelect($c);
the resulted query from this is the following
SELECT area.ID, area.NAME, area.GIS, area.DISTRICTS_ID FROM `area`,
`resturants`, `resturants_area` WHERE area.DISTRICTS_ID='2' AND
resturants.IS_ACTIVE=1 AND area.ID=resturants_area.AREA_ID AND
resturants_area.RESTURANTS_ID=resturants.ID
Which seem to be okay, when i remove the column names and run it with select
* i get all the records am aiming to.
Now, in my template, am not entirely sure how to use it. Here is what i
did..
<?php foreach ($objs as $obj):?>
<?php echo $obj->getName();?>
<?php foreach ($obj->getResturantAreas() as $Resturant):?>
<?php echo $Resturant->getResturants();?>
<br>
<?php endforeach;?>
<?php endforeach;?>
It does return all the records, but it has goes into a inner loop repeating
the same thing over and over for each record from the main AreaPeer. Any
idea how I can over come this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---