簡體   English   中英

我的pdo語法出了什么問題?

[英]what is wrong with my pdo syntax?

我正在嘗試執行如下定義的pdo更新語句:

 $sql = "UPDATE users SET (email,name) VALUES (:email,:name) WHERE userId = :userId";
 $result= $db->prepare($sql);
 $result->execute(array(':userId'=>21,':email'=>'test',':name'=>'testname'));

但無論我嘗試什么,它都會返回以下錯誤

Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(email,name) VALUES ('test','testname') WHERE userId = '21'' at line 1' in /var/www/vhosts/tftest.co.uk/biggreensquare.co.uk/application/models/user_model.php:79

我無法看到我的語法有什么問題導致任何反饋非常感激。

我希望語法看起來像:

UPDATE users
    SET email = :email,
        name = :name
    WHERE userId = :userId;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM