gpt4 book ai didi

php - 查询在 phpmyadmin 中运行良好,但在脚本中运行不正常

转载 作者:行者123 更新时间:2023-11-29 03:53:00 25 4
gpt4 key购买 nike

$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);

查询从 phpmyadmin 运行正常,但如果从 php 运行则抛出此错误:

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE _notifications SET _notifications.notification_flag = 0 WHERE _notificati' at line 2

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' ;

更新:谢谢大家!

最佳答案

假设我假设问题是您在同一个查询中有多个语句,您可以试试这个:

$query_string = "UPDATE _notifications SET _notifications.notification_flag = 0 
WHERE _notifications.notification_id IN ('JTQBPULM3M', 'KC7KZT2JAT', 'M6L5T5Z2K0')";
$this->db->query($query_string);

这将使它成为一个单一的声明。

我假设它在 phpMyAdmin 中有效,因为我怀疑 phpMyAdmin 将多个语句分解为单独的查询,而不是单个查询。 (纯属猜测,注意。)

关于php - 查询在 phpmyadmin 中运行良好,但在脚本中运行不正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8275074/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com