The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
![]()
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"? |
#2
|
||||
|
||||
![]()
After running the first query (INSERT INTO settinggroup), do this:
Code:
$newSettingGroupID = $DB_site->insert_id(); // Same as mysql_insert_id(); |
#3
|
||||
|
||||
![]()
So I'd have to do it as a script, and not as a simple query straight to the db?
|
#4
|
||||
|
||||
![]()
You could run these two queries, one after another:
Code:
INSERT INTO settinggroup (settinggroupid,title,displayorder) VALUES (null,"Group Title",1); INSERT INTO setting (settingid,settinggroupid,title,varname,value,description,optioncode,displayorder) SELECT null,LAST_INSERT_ID(),"Setting Name","varname","1","Description about setting","yesno",1 FROM settinggroup LIMIT 1; |
#5
|
||||
|
||||
![]()
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; INSERT INTO settinggroup (title, displayorder) VALUES ('Default PM', @displayorder); SELECT @settinggroupid:=LAST_INSERT_ID(); INSERT INTO setting (settinggroupid, title, varname, value, description, optioncode, displayorder) VALUES (@settinggroupid, 'Send default PM to new users?', 'defpmactive', '0', '', 'yesno', 1); |
#6
|
||||
|
||||
![]()
Umm, Chen... The board did some strange parsing when I posted that inside [sql ] instead of [code ]
|
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|