sfPropelRouteCollection and method_for_criteria

Posted by Gregory McLean on 2009-04-22 in Criteria, Propel, Symfony

Recently while working with Symfony, and mucking about with the sfPropelRouteCollection class I had an action that queried a table with some foreign keys. Which is no big unique thing, and fairly typical. With propel you can get the related objects fairly easy as well which again is nothing ground shaking. What happens if you don't do the proper joining is for each related object from the query results in another query to the database, which adds up fast and slows your page down. So what we want to do is do some doSelectJoinXXX goodness on the queries.

This isn't as straight forward as it seems though..

In your routing.yml you'll have the sfPropelRouteCollection stuff.. in the options add model_methods: { list: doSelectJoin<Bleh> } then in the actions class you'll want to add the criteria object for the list action, $this->getRoute()->setListCriteria(new Criteria()); All should work as desired now.

 

Leave a reply

:*
:*
:
http://
:*