![]() |
Little help with yet another advanced query...
Suppose I want to add a new settinggroup and settings to the vBulletin Options section of the admin cp. I know that to do this, I add a new record to the settinggroup table, like so: INSERT INTO settinggroup (settinggroupid,title,displayorder) VALUES (xx,"Group Title",xx);. I also know that to add settings to that setting group, I would use something like: INSERT INTO setting (settingid,settinggroupid,title,varname,value,desc ription,optioncode,displayorde r) VALUES (nn,xx,"Setting Name","$varname","1","Description about setting","yesno",yy);.
Now my question is, if I use NULL for xx while creating the settinggroup so that it takes the next auto-increment number, is there a way I can do the second query, making the setting, so that it uses the same number for xx? Some kind of join or something where it looks in settinggroup for a settinggroupid where the title equals "Group Title"? |
After running the first query (INSERT INTO settinggroup), do this:
Code:
$newSettingGroupID = $DB_site->insert_id(); |
So I'd have to do it as a script, and not as a simple query straight to the db?
|
You could run these two queries, one after another:
Code:
INSERT INTO settinggroup (settinggroupid,title,displayorder) VALUES (null,"Group Title",1); |
This is how I did the exact same thing in the installer of my Default PM-hack.
Code:
SELECT @displayorder:=displayorder+1 FROM settinggroup ORDER BY displayorder DESC LIMIT 1; |
Umm, Chen... The board did some strange parsing when I posted that inside [sql ] instead of [code ]
|
All times are GMT. The time now is 11:20 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|