I’m looking for way to do a simple query using criteria OR in symfony framework. The official documentation does not covers the sql query criteria for OR statement. After googling for while, there is some reference from the Propel Guide
To perform a simple SQL query with OR criteria is a bit complicated in symfony or i can say in Propel. Here’s the example of how to perform the SQL query for:
SELECT * FROM table_a WHERE (column_a = 1 OR column_a = 3) AND column_c = ‘xxx’
$c = new Criteria;
$c1 = $c->getNewCriterion(TableAPeer::COLUMN_A, 1);
$c2 = $c->getNewCriterion(TableAPeer::COLUMN_A, 2);
$c1->addOr($c2);
$c->add(TableAPeer::COLUMN_B, ‘xxx’);
$c->add($c1);
So, now you can perform your query using criteria OR in symfony.
Yes, no doubt it’s complicated but it works!
Subscribe to:
Post Comments (Atom)


0 comments:
Post a Comment