推进ORM UNION查询 [英] Propel ORM UNION query

查看:97
本文介绍了推进ORM UNION查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个条件对象$ c1,$ c2,$ c3

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

我想返回所有三个的联合集,即:($ c1 || $ c2 || $ c3) 我有一个期望使用Criteria对象的函数,因此我需要能够返回代表$ c1,$ c2和$ c3的UNION的条件.

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.

有人知道如何实现吗?

推荐答案

您可以使用以下标准来做到这一点:

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

这篇关于推进ORM UNION查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆