用Propel ORM进行UNION查询 [英] UNION query with Propel ORM
问题描述
我正在尝试使用Propel ORM创建UNION查询,例如
I'm trying to create a UNION query using the Propel ORM e.g
$criterion1 UNION $criterion2
有人知道该怎么做吗?
推荐答案
您不能使用Criteria创建联合查询.相反,您可以自己创建SQL字符串,并用它来水合对象.如果仍然要使用标准"来构建联合查询的两个部分,则可以调用BasePeer::createSelectSql(Criteria $criteria, array &$params)
.这将在PDO层需要设置的值的位置返回带?
的SQL字符串.第二个参数是将用这些参数填充的数组(这就是为什么要通过引用传递它的原因).您可以将其传递给PDOStatement::execute(array $params)
函数.
You cannot create a union query using Criteria. Instead, you can create the SQL string yourself, and use it to hydrate the objects. If you still want to use Criteria to build both parts of the union query, you can call BasePeer::createSelectSql(Criteria $criteria, array &$params)
. This will return an SQL string with ?
in the places of the values that need to be set by the PDO layer. The second parameter is an array that will be filled with these parameters (which is why you pass it by reference). You can pass this to the PDOStatement::execute(array $params)
function.
这篇关于用Propel ORM进行UNION查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!