如何使用mysql在INSERT期间连接并保存名字和姓氏?

时间:2015-05-02 19:39:07

标签: php mysql sql database pdo

我正在尝试将语言和代码连接为第二个查询并保存到数据库字段litcode。 这是我的代码

$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO library (spot,code,language,count) values(?, ?, ?,?);UPDATE library SET litcode = CONCAT(language, code);";
$q = $pdo->prepare($sql);
$q->execute(array($spot,$code,$language,$count));
Database::disconnect();

出现此错误

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in /home/booking/public_html/x/concat.php:46 Stack trace: #0 /home/booking/public_html/x/concat.php(46): PDOStatement->execute(Array) #1 {main} thrown in /home/booking/public_html/x/concat.php on line 5

这是代码$q->execute(array($spot,$code,$language,$count));中的第5行 如何添加连接词litcode?

0 个答案:

没有答案