【发布时间】:2014-01-28 07:20:16
【问题描述】:
我正在尝试在 PHP PDO 中运行此 SQL 查询:
$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"] ));
但我得到了这个输出:
致命错误:未捕获的异常 'PDOException' 和消息 'SQLSTATE[HY093]:无效的参数号:参数未定义'在 /home/integra/public_html/service_status/index.php:48 堆栈跟踪:# 0 /home/integra/public_html/service_status/index.php(48): PDOStatement->execute(Array) #1 /home/integra/public_html/index.php(124): include('/home/integra/p. ..') #2 {main} 在第 48 行的 /home/integra/public_html/service_status/index.php 中抛出
【问题讨论】: