Php 如何在数组中绑定值?
我有很多东西要插入数据库colums中Php 如何在数组中绑定值?,php,pdo,bindvalue,Php,Pdo,Bindvalue,我有很多东西要插入数据库colums中 $connect->prepare("INSERT INTO users (username, password, message, date, time, id) VALUES (:username, :password, :message, :date, :time, :id"); 我没有将它们全部绑定,而是创建了一个数组: $IDs = array($username, $password, $message, $time,
$connect->prepare("INSERT INTO users (username, password, message, date, time, id) VALUES (:username, :password, :message, :date, :time, :id");
我没有将它们全部绑定,而是创建了一个数组:
$IDs = array($username, $password, $message, $time, $date, $ID);
如何从该数组中获取每个变量并将其绑定?
我完全不懂PDO。使用:
$sth->execute(array(':username' => $username, ':password' => $password, $message, $time, $date, $ID))
对其他人来说……只需为数组项提供正确的键和
execute()
不需要冒号的东西。您还缺少一些参数;)