One query, 3 updates?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
totally_forgot
Forum Newbie
Posts: 5
Joined: Sat Mar 26, 2005 3:56 pm

One query, 3 updates?

Post by totally_forgot »

Is it possible to have three update queries in one?

Code: Select all

query("UPDATE $UserDB.unz_users SET pcount = pcount + 1 WHERE uid = '$uid'") or die_query(1);
query("UPDATE $forumzDB.forumz_threads SET replies = replies + 1, lp_time = '$time' WHERE tid = '$tid'") or die_query(3);//add one to the replies
query("UPDATE $forumzDB.forumz_forums SET postCount = postCount + 1 WHERE fid = '$fid'") or die_query(4);//add one post to total
#query is a custom function
Sphen001
Forum Contributor
Posts: 107
Joined: Thu Mar 10, 2005 12:24 pm
Location: Land of the Beaver

Post by Sphen001 »

Hi,

No, I don't think you can. Because you're updating three different tables, you need different queries.

Sphen001
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

update supports multiple tables, but I don't remember if it supports setting only various fields from each at the same time. Maybe you should read your database server's documentation on update queries.
Post Reply