views:

17

answers:

1

Hi,

what is the method to create OR?

I mean: I know to craate this SQL clause:

SELECT * FROM author WHERE author.FIRST_NAME = 'Karl' AND author.LAST_NAME <> 'Marx';

I should do this:

<?php
$c = new Criteria();
$c->add(AuthorPeer::FIRST_NAME, "Karl");
$c->add(AuthorPeer::LAST_NAME, "Marx", Criteria::NOT_EQUAL);
$authors = AuthorPeer::doSelect($c);

But if i want to create:

SELECT * FROM author WHERE author.FIRST_NAME = 'Karl' OR author.LAST_NAME <> 'Marx';

what should i do?

Regards

Javi

+2  A: 
$c = new Criteria();  
$cton1 = $c->getNewCriterion(AuthorPeer::FIRST_NAME, "Karl");  
$cton2 = $c->getNewCriterion(AuthorPeer::LAST_NAME, "Marx", Criteria::NOT_EQUAL);  
$cton1->addOr($cton2);  
$c->add($cton1);  
dcp
More information can be found in the [Propel documentation about Criteria](http://www.propelorm.org/wiki/Documentation/1.4/Criteria#LogicallyComplexCriteria), or [Queries for Propel 1.5 and higher](http://www.propelorm.org/wiki/Documentation/1.5/BasicCRUD).
Jan Fabry