Useful Propel criteria methods and constants
April 6th, 2009
5 comments
I’m working with criteria quite often lately and must say it is a handy way of query writing. The only problem I have with criteria is that I don’t seem to find a simple overview (list) of the most important methods you can add to it. I don’t really like the Propel website as I don’t find the thing I need in a few seconds and that is a must for a lot of people. If I create a list of the most important criteria methods for myself, I rather share it with you guys…
Simple Select query with 2 criteria to check:
$c = new Criteria(); $c->add(AuthorPeer::FIRST_NAME, "Karl"); $c->add(AuthorPeer::LAST_NAME, "Marx", Criteria::NOT_EQUAL); $authors = AuthorPeer::doSelect($c); // $authors contains array of Author objects
In SQL this will be:
SELECT ... FROM author WHERE author.FIRST_NAME = 'Karl' AND author.LAST_NAME <> 'Marx';
It’s quite simple to write the criteria, the only thing needed to write them is a list of options.

Recent Comments