1
我试图运行这个SQL查询在PHP PDO:PDO SQL UNION查询显示错误
$stmt = $pdo_conn->prepare("SELECT * from integra_status where type <> :type1 and category1 = :category and (status = :status1 or status = :status2)
UNION
SELECT * from integra_status WHERE type = :type2 and maintenance_fromdate <= :maintenance_fromdate AND maintenance_todate >= :maintenance_todate and category = :category2 order by sequence ASC ");
$stmt->execute(array(':type1' => 'Maintenance', ':category1' => $result["sequence"], ':status1' => 'Open', ':status2' => 'Resolved',
':type2' => 'Maintenance', ':maintenance_fromdate' => 'DATE_ADD(NOW(), INTERVAL 7 DAY)', ':maintenance_todate' => 'DATE_SUB(NOW(), INTERVAL 2 DAY)', ':category2' => $result["sequence"]));
,但我得到这样的输出:
致命错误:未捕获的异常'在/ home/integra/public_html/service_status/index.php:48堆栈跟踪:#0/home/integra/public_html/service_status/index中,'PDOException'消息'SQLSTATE [HY093]:无效的参数号:参数未定义'。 php(48):PDOStatement-> execute(Array)#1/home/integra/publi c_html/index.php(124):include('/ home/integra/p ...')#2 {main}扔在/ home /integra/public_html/service_status/index.php在线48