mysql中PDO参数化引号引起的Warning: PDOStatement::execute(): SQLSTATE[HY093]:报错
sql语句之前是这样写的:INSERT INTO tablename SET a = ':a',b = ':b',c = ':c',d = :d,e = :e
$data = array
(
[':a'] => 1,
[':b'] => 2,
[':c'] => 3,
[':d'] => 4,
[':e'] => 5,
)
$prepareResualt = $pdo->prepare($sql);
$prepareResualt->execute($data);
出现了Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens报错
然后改成:INSERT INTO tablename SET a = :a,b = :b,c = :c,d = :d,e = :e
正常插入数据 ,大概是参数化语句中不需要把字符串类型的参数加上引号吧,也确实感觉有点多此一举。