This is going to be a quick post as I needed to write this done as its quite useful for anyone who either doesnt like or doesnt understand how the complex criteria objects work.
If you want to write code for a criteria object for the SQL statement which is something like this.
SELECT field1, field2 from table1 where field1 in (5,30,23)
The corresponding PHP for that would be as follows
$values = array(5,30,23); $criteria_for_select = new Criteria(); $c = new Criteria(); $criteria_for_select = $c->getNewCriterion(table1::field1, $values, Criteria::IN);
That’s pretty much it, now this criteria object $criteria_for_select can now be used in your doSelectXXX calls.
Another really cool app that automates the task of writing criteria object is availabile here.
http://propel.jondh.me.uk/
The cool thing about this utility is you drop in your selection condition and it will write the code for the criteria object for you, now that’s really cool.


Recent Comments