Thanks, Gábor I still face the same problem, I mean in the template I don't know for sure how to retrieve records from other table without having to hit the database several times, plus its going into a loop between parent and child records as i described in the first email. Any idea how to handle this from the template side?
On Sat, Aug 8, 2009 at 3:14 PM, Gábor Fási <[email protected]> wrote: > > Using addJoin does not mean the resulting values are used while > hydrating, if the relationships are described in your schema.yml, use > this: > > $c = new Criteria(); > $c->add(AreaPeer::DISTRICTS_ID, > $request->getParameter('search_input_districts')); > $c->add(ResturantsPeer::IS_ACTIVE, TRUE); > $this->objs = AreaPeer::doSelectJoinAll($c); > > this code will automatically add the neccesary joins, and take care of > the hydration of the related objects. > > On Sat, Aug 8, 2009 at 14:03, Mo Mughrabi<[email protected]> wrote: > > 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 -~----------~----~----~----~------~----~------~--~---
