开发者

Propel: what is the equivalent of OR in SQL?

开发者 https://www.devze.com 2023-01-18 10:19 出处:网络
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\';

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:

SELE开发者_StackOverflow中文版CT * FROM author WHERE author.FIRST_NAME = 'Karl' OR author.LAST_NAME <> 'Marx';

what should i do?

Regards

Javi


$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);  


Check orWhere(), combine(), and the new _or() operator:

  • http://www.propelorm.org/wiki/Documentation/1.5/ModelCriteria#CombiningSeveralConditions
  • http://propel.posterous.com/using-or-in-propel-queries-becomes-much-easie
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号