我在类中的以下函数中遇到了错误。
<?php
if(isset($_REQUEST['customer_id'])){
$customer_id = $_REQUEST['customer_id'];
}
?>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$data = array(
$_POST['customer_name'],
$_POST['customer_address'],
$_POST['customer_phone'],
$_POST['customer_email']
);
var_dump($data);
$update = DB::update('customer',$data,$customer_id,'customer_id');
错误消息是:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in
这里有什么问题?我错过了我睡眼惺忪的眼睛看不到问题的东西......
var_dump结果是:
array (size=4)
0 => string 'Foo M' (length=5)
1 => string 'Foo Lab' (length=17)
2 => string '2147483647' (length=10)
3 => string 'foo@moo.com' (length=11)
基本上,问题是您在 sql 语句中为这些列指定了太多列或太多值。你有col1,col2,col3。瓦尔1,瓦尔2...<-- 值的数量列太多,反之亦然....Col1, Col2....Val1, Val2, Val3.
尝试在执行查询之前回显查询,您将看到不匹配。