Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Details »»

Version: , by TECK TECK is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 02-20-2002 Last Update: Never Installs: 0
 
No support by the author.

i want to call in settinggroup the last settinggroupid (for example, 32 that i just created in settinggroup with a NULL). here what i came up with:
PHP Code:
$settinggroupid=$DB_site->query("SELECT LAST_INSERT_ID() FROM settinggroup");
$DB_site->query("INSERT INTO setting VALUES (NULL,$settinggroupid,'News forum ID','newsforumid','15','The specified forum will contain threads viewed on the main page only.','',0)"); 
it doesnt want to grab it... hmmmm.. i'm upset :noid:

the script returns this:
---------------------------------------
INSERT INTO setting VALUES (NULL,Resource id #6,'News forum ID','newsforumid','15','The specified forum will contain threads viewed on the main page only.','',0)

instead of:
---------------------------------------
INSERT INTO setting VALUES (NULL,32,'News forum ID','newsforumid','15','The specified forum will contain threads viewed on the main page only.','',0)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 02-20-2002, 06:32 AM
Scott MacVicar Scott MacVicar is offline
 
Join Date: Oct 2001
Location: Glasgow, Scotland
Posts: 1,199
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$settinggroupid=$DB_site->query_first("SELECT LAST_INSERT_ID() FROM settinggroup"); 
Put the values from the query into an array then it will work
Reply With Quote
  #3  
Old 02-20-2002, 12:18 PM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just use $DB_site->last_insert().
Reply With Quote
  #4  
Old 02-20-2002, 11:51 PM
TECK's Avatar
TECK TECK is offline
 
Join Date: Nov 2001
Location: Canada
Posts: 4,182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is not working PPN.. it returns Array instead of the value.

FireFly, can you post the exact line please? i need to make a query on this. here it is what i try to do:
PHP Code:
$DB_site->query("INSERT INTO settinggroup (settinggroupid,title,displayorder) VALUES (NULL,'".addslashes($title)."','$displayorder')");
echo 
"Adding settinggroup data... Done. <font color='#006699'>settinggroup</font> table populated.<br>\n";

$settinggroupid=$DB_site->query_first("SELECT LAST_INSERT_ID() FROM settinggroup");
$DB_site->query("INSERT INTO setting VALUES (NULL,$settinggroupid,'News forum ID','newsforumid','15','The specified forum will contain threads viewed on the main page only.','',0)");
echo 
"Adding setting data... Done. <font color='#006699'>setting</font> table populated.<p></td>\n"
i need to call the last ID from settinggroup and insert it as a value into setting. let me know where i do it wrong.
Reply With Quote
  #5  
Old 02-21-2002, 06:25 AM
Scott MacVicar Scott MacVicar is offline
 
Join Date: Oct 2001
Location: Glasgow, Scotland
Posts: 1,199
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes it returns an array, thats how you get data from the database, or you fetch row or fetch object.

use $settinggroupid[LAST_INSERT_ID()] as you said its an array. If your ever curious to what value an array holds you can use print_r($array);
and it will print out all the values of $array.

Anyway you can use $DB_site->insert_id(); to use the abstraction layer if you want.

its part of the abstraction layer which simply uses mysql_insert_id(); which is a nice trait of mysql as it gets the last value of the auto incrememnt column.
Reply With Quote
  #6  
Old 02-21-2002, 06:40 AM
TECK's Avatar
TECK TECK is offline
 
Join Date: Nov 2001
Location: Canada
Posts: 4,182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by PPN
Anyway you can use $DB_site->insert_id(); to use the abstraction layer if you want.
i'm confused about one thing, how do i call it from settinggroup? if i use:
PHP Code:
$settinggroupid=$DB_site->insert_id(); 
it will not grab the last id from settinggroup, right? help me understand better this matter.

btw scott, ty for your tips. i learn alot from mysql.com site, but you guys have all kind of tricks..
Reply With Quote
  #7  
Old 02-21-2002, 10:00 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The bit of code you posted is correct nakkid.
mysql_insert_id() returns the last auto-increment ID that was insert into the DATABASE during the current connection.
Reply With Quote
  #8  
Old 02-21-2002, 03:04 PM
Scott MacVicar Scott MacVicar is offline
 
Join Date: Oct 2001
Location: Glasgow, Scotland
Posts: 1,199
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

use this

PHP Code:
$DB_site->query("INSERT INTO settinggroup (settinggroupid,title,displayorder) VALUES (NULL,'".addslashes($title)."','$displayorder')");
echo 
"Adding settinggroup data... Done. <font color='#006699'>settinggroup</font> table populated.<br>\n";

$settinggroupid=$DB_site->insert_id();
$DB_site->query("INSERT INTO setting VALUES (NULL,$settinggroupid,'News forum ID','newsforumid','15','The specified forum will contain threads viewed on the main page only.','',0)");
echo 
"Adding setting data... Done. <font color='#006699'>setting</font> table populated.<p></td>\n"
Reply With Quote
  #9  
Old 02-21-2002, 11:22 PM
TECK's Avatar
TECK TECK is offline
 
Join Date: Nov 2001
Location: Canada
Posts: 4,182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks alot PPN... i posted a thread in Website Feedback. let me know if i'm crazy.. read more in my signature why i decide not to post any hacks anymore here.

however, i will give you a copy of the script once completed, so you can use it. i will keep in touch here through pm's and email.

thanks alot for all your support (scott and chen).
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:20 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04546 seconds
  • Memory Usage 2,291KB
  • Queries Executed 22 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (5)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (8)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete