这是我的SQL语句:
protected static $_SQLInsert = "INSERT INTO location
(host_id, street, suburb, region, post_code, country, phone, email,
timezone, longitude, latitude, is_main)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
我准备如下声明:
static::$_PDOSInsert = self::$_PDO->prepare(static::$_SQLInsert);
在准备一个包含12个值的数组后,我执行语句:
static::$_PDOSInsert->execute($array);
然后我收到以下警告:
PDOStatement :: execute():SQLSTATE [HY093]:参数号无效:参数未在...中定义。
那么,我做错了什么?
编辑:这是阵列:
(
[host_id] => 15
[street] => Street 15
[suburb] => Suburb 15
[region] => Region 15
[post_code] => Post Code 15
[country] => AU
[phone] => 12341234
[email] => asfd@email.com
[timezone] => 1
[longitude] => 123
[latitude] => 234
[is_main] => 1
)
谢谢!
答案 0 :(得分:2)
pdo对于你给execute()的数组非常挑剔。如果你使用像?
这样的未命名占位符,它需要一个数字索引数组,它必须从索引0开始。