PDA

View Full Version : PHP plugin SQL query running multiple SET lines?


Skyrider
05-04-2015, 09:34 PM
I'm trying to run a SQL query code:

{
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "user
SET usergroupid = x
WHERE usergroupid = x");
}

of which appears to be working (with the rest of the other IF codes included), but I can't seem to figure out how to run multiple arrays in a single SET command. for example, with the usergroupID that is being set, I'd like to include the displaygroupid and title as well. I've tried:

{
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "user
SET usergroupid = 10, displaygroupid = 1
WHERE usergroupid = 6");
}

But I appear to be getting a SQL error with that one. Anyone could land a hand?

Side question. If anyone has a better idea how to include the code so the usergroup, eg changes are being logged in to the users history through admincp, please let me know.

ForceHSS
05-04-2015, 10:09 PM
UPDATE `user` SET `usergroupid`='10', `displaygroupid`='1' WHERE (`usergroupid`='6')

Skyrider
05-05-2015, 06:12 AM
This appears to be working:

{
$vbulletin->db->query_write("
UPDATE `user` SET `usergroupid`='10', `displaygroupid`='1' WHERE (`usergroupid`='6')");
}

Is this any good? And if I wish to leave an empty result in a table, how would I perform that?

ForceHSS
05-05-2015, 08:57 AM
This appears to be working:

{
$vbulletin->db->query_write("
UPDATE `user` SET `usergroupid`='10', `displaygroupid`='1' WHERE (`usergroupid`='6')");
}

Is this any good? And if I wish to leave an empty result in a table, how would I perform that?

The query you have is the one I gave you and yes it will work I always test before I post.

Leaving any of the columns with any empty value will cause an error

Dave
05-05-2015, 10:32 AM
Not all columns accept null/empty values, but you can set a column to empty by just using an empty string as follows: somecolumn = ''