Bab*_*ker 1 php mysql sql codeigniter phpmyadmin
$query_string = "UPDATE _notifications SET _notifications.notification_flag = 0 WHERE _notifications.notification_id = 'JTQBPULM3M' ;
UPDATE _notifications SET _notifications.notification_flag = 0 WHERE _notifications.notification_id = 'KC7KZT2JAT' ;
UPDATE _notifications SET _notifications.notification_flag = 0 WHERE _notifications.notification_id = 'M6L5T5Z2K0' ;";
$this->db->query($query_string);
Run Code Online (Sandbox Code Playgroud)
查询从phpmyadmin运行正常但如果从php运行则抛出此错误:
错误号码:1064
您的SQL语法有错误; 检查与MySQL服务器版本对应的手册,以便在第2行的'UPDATE _notifications SET _notifications.notification_flag = 0 WHERE _notificati'附近使用正确的语法
UPDATE _notifications
SET _notifications.notification_flag = 0
WHERE _notifications.notification_id = 'JTQBPULM3M' ;
UPDATE _notifications
SET _notifications.notification_flag = 0
WHERE _notifications.notification_id = 'KC7KZT2JAT' ;
UPDATE _notifications
SET _notifications.notification_flag = 0
WHERE _notifications.notification_id = 'M6L5T5Z2K0' ;
Run Code Online (Sandbox Code Playgroud)
假设我的假设是问题是你在同一个查询中有多个语句,你可以尝试这样做:
$query_string = "UPDATE _notifications SET _notifications.notification_flag = 0
WHERE _notifications.notification_id IN ('JTQBPULM3M', 'KC7KZT2JAT', 'M6L5T5Z2K0')";
$this->db->query($query_string);
Run Code Online (Sandbox Code Playgroud)
这将使它成为一个单一的声明.
我假设它在phpMyAdmin中工作,因为我怀疑phpMyAdmin将多个语句分解为单独的查询,而不是单个查询.(纯粹的猜测,请记住.)