UNION query with Propel ORM

前端 未结 2 1069
不思量自难忘°
不思量自难忘° 2021-01-18 12:11

I\'m trying to create a UNION query using the Propel ORM e.g

$criterion1 UNION $criterion2

Does anyone know how to do this?

2条回答
  •  萌比男神i
    2021-01-18 12:24

    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.

提交回复
热议问题