本文介绍了MySQL/PHP更新查询错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个查询,以从PHP更新表中的一小部分项目".使用"Sequel Pro"运行代码可以完美地执行代码,而使用mysql("query here")在PHP上运行代码即可;失败了.

I'm running a query to update a small group of 'items' in a table, from PHP.Running the code with "Sequel Pro" executes it perfectly, while running it on PHP using mysql("query here"); fails miserably.

查询有问题吗?

UPDATE `service_joblocation`
   SET  `in_use` =  '1',
        `in_use_since` =  '1283488686',
        `in_use_currentcount` =  `in_use_currentcount`+1,
        `in_use_historicalcount`= `in_use_historicalcount`+1
  WHERE `id` = 5
  LIMIT 1;

UPDATE `service_joblocation`
   SET `in_use` =  '1',
       `in_use_since` =  '1283488686',
       `in_use_currentcount` = `in_use_currentcount`+1,
       `in_use_historicalcount` = `in_use_historicalcount`+1
 WHERE `id`=16
  LIMIT 1;

UPDATE `service_joblocation`
   SET  `in_use` =  '1',
        `in_use_since` = '1283488686',
        `in_use_currentcount` = `in_use_currentcount`+1,
        `in_use_historicalcount` = `in_use_historicalcount`+1
  WHERE `id`=18
   LIMIT 1;

UPDATE `service_items` SET  `checkin_user`='9', `checkin_date`='1283488686', `location`='5' WHERE `id`=576;
UPDATE `service_items` SET  `checkin_user`='9', `checkin_date`='1283488686', `location`='16' WHERE `id`=577;
UPDATE `service_items` SET  `checkin_user`='9', `checkin_date`='1283488686', `location`='18' WHERE `id`=578;
UPDATE `service_jobs` SET `checkin_date`='1283488686', `checkin_user`='9',`checkin_department`='1',`checkin_client_person`='0', `items_x`=`items_x`+1 WHERE `id`='518' LIMIT 1;
UPDATE `service_jobs` SET `checkin_date`='1283488686', `checkin_user`='9',`checkin_department`='1',`checkin_client_person`='0', `items_x`=`items_x`+1 WHERE `id`='518' LIMIT 1;
UPDATE `service_jobs` SET `checkin_date`='1283488686', `checkin_user`='9',`checkin_department`='1',`checkin_client_person`='0', `items_x`=`items_x`+1 WHERE `id`='518' LIMIT 1;

这是输出消息...

推荐答案

您只能将一条语句传递给mysql_query().

You can only pass a single statement to mysql_query().

还有其他功能/方法,例如 mysqli :: multi_query(),但不适用于旧版mysql扩展.

There are other functions/methods like e.g. mysqli::multi_query() but not for the old mysql extension.

这篇关于MySQL/PHP更新查询错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 20:15