php - 如何在原始查询 Symfony 中添加 union all?
问题描述
我需要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();
我收到数组到字符串的转换错误。我不知道该放在哪里prepare & execute statement
任何人都可以帮我解决这个问题。
谢谢你。
解决方案
推荐阅读
- python - 对于数据帧中的每个 lat,lng 循环通过另一个数据帧并进行比较
- java - 如何在 Spring Boot 中使用 KeyHolder?
- selenium-webdriver - 如何在不传递selenium java中的元素的情况下实现wait()
- java - 如何优雅地解析字符串以获得您所需要的?
- java - 如何为线条绘制形状制作圆形破折号或圆点
- java - 什么解析策略最适合 Http 消息?
- c# - 自动选择下拉列表中的一项 asp.net c#
- sql - 获取 SQL Server 上员工的重新分配时间(以天为单位)
- azure - 需要将数据从一个 Azure 数据库同步到另一个数据库,其中两个数据库具有不同的位置和不同的服务器
- java - 如何从与另一个列表关联的地图中获取密钥