Propel ORM UNION query

[亡魂溺海] 提交于 2019-12-11 14:19:36

问题


I have three criteria objects $c1, $c2, $c3

I want to return the union set of all three i.e.: ($c1 || $c2 || $c3) I have a function that expects a Criteria object, so I need to be able to return a criteria that represents the UNION of $c1, $c2 and $c3.

Does anyone know how to achieve that?


回答1:


You can do that with criterions:

<?php

$c = new Criteria();
$cton1 = $c->getNewCriterion(AuthorPeer::FIRST_NAME, "Leo");
$cton2 = $c->getNewCriterion(AuthorPeer::LAST_NAME,  array("Tolstoy", "Dostoevsky", "Bakhtin"), Criteria::IN);

// combine them
$cton1->addOr($cton2);

// add to Criteria
$c->add($cton1);


来源:https://stackoverflow.com/questions/5063608/propel-orm-union-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!