-1
这里是我的SQL语句:我的PDO插入语句有什么问题?
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对象::执行():SQLSTATE [HY093]:无效的参数号:参数是不...
那么,我究竟做错了定义???
编辑:这里的数组:
(
[host_id] => 15
[street] => Street 15
[suburb] => Suburb 15
[region] => Region 15
[post_code] => Post Code 15
[country] => AU
[phone] => 12341234
[email] => [email protected]
[timezone] => 1
[longitude] => 123
[latitude] => 234
[is_main] => 1
)
谢谢!
可能重复[“无效参数编号:参数未定义”插入Yii数据] stackoverflow.com/questions/5874383/invalid-parameter-number-parameter-was-not-defined-inserting-data-in-yii) – mario
'参数未定义',也许你忘了在数组中定义一个参数?我会使用关联占位符作为':host_id'而不是几十个'''来更好地跟踪你的参数。 –
@mario:我没有使用命名参数 –