Php 如何在原始查询Symfony中添加union all?

Php 如何在原始查询Symfony中添加union all?,php,symfony4,Php,Symfony4,我需要在查询中使用UNION ALL。我已将所有where条件存储在一个循环中 $lastIndex = count($executionArray) - 1; $selectQuery = ""; foreach ($executionArray as $key => $wheres) { $selectQuery .= "SELECT {$selectFields} FROM {$tableName} WHERE &

我需要在查询中使用
UNION ALL
。我已将所有where条件存储在一个循环中

    $lastIndex = count($executionArray) - 1;
    $selectQuery = "";
    foreach ($executionArray as $key => $wheres) {
        $selectQuery .= "SELECT {$selectFields} FROM {$tableName} WHERE ";
        $selectQuery .= $wheres;
        if ($key !== $lastIndex) {
            $selectQuery .= " UNION ALL ";
        }
    }

    $selectStmt = $this->dbConnection->prepare($selectQuery);
    $selectStmt->execute($executionArray);
    $return = $selectStmt->fetchAll();
我得到数组到字符串的转换错误。我不确定在哪里放置
准备和执行语句

谁能帮我修一下这个吗


谢谢。

工会似乎都不是问题所在。你能分享$selectquery的内容吗?我已经解决了这个问题。它来自$selectStmt=$this->dbConnection->prepare($selectQuery)$选择stmt->execute($executionArray)您的解决方案是什么?