Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-18-2008, 05:18 PM
JamesTalbot JamesTalbot is offline
 
Join Date: Dec 2004
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default vB Save() mysql_insert_id ?

Hey,

I am trying to alter my newly upgraded vBulletin Forum register.php file.

All i want to do is insert the userid from that registered person and insert it into another table.

In vB2 this was very easy. I am unsure how to do this in vB3 though. I have looked at vBulletin Data Documentation but didnt see anything relevant to this issue.

Can anyone help me?

Thanks in Advance.

James
Reply With Quote
  #2  
Old 02-18-2008, 07:25 PM
cheesegrits's Avatar
cheesegrits cheesegrits is offline
 
Join Date: May 2006
Posts: 500
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Don't edit the register.php file. Use a plugin on the register_addmember_complete hook, where $vbulletin->userinfo['userid'] will be the new userid.

-- hugh
Reply With Quote
  #3  
Old 02-18-2008, 08:28 PM
Eikinskjaldi's Avatar
Eikinskjaldi Eikinskjaldi is offline
 
Join Date: Feb 2006
Location: Hell, never looked better
Posts: 572
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

or use a trigger.
Reply With Quote
  #4  
Old 02-18-2008, 08:53 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Eikinskjaldi View Post
or use a trigger.
trigger?

P.S. the id value is normally returned when the save() function is execute so...
PHP Code:
$somevar $userdm->save()

// $somevar is the userid 
Obviously it won't be $somevar but it maybe be another variable.
Reply With Quote
  #5  
Old 02-18-2008, 10:09 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by cheesegrits View Post
Don't edit the register.php file. Use a plugin on the register_addmember_complete hook, where $vbulletin->userinfo['userid'] will be the new userid.

-- hugh
This is exactly what I do for my tracker. I have a separate table for registration to the tracker that I populate with the userid and username at the time of registration. I use the register_addmember_complete hook and simply put a query in there:
PHP Code:
$db->query_write("INSERT INTO mytable (all variables) VALUES
  (variable contents)
          "
); 
Reply With Quote
  #6  
Old 02-19-2008, 11:04 AM
JamesTalbot JamesTalbot is offline
 
Join Date: Dec 2004
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, have you got a link for more info on these hooks you are referring to?

EDIT - I have found the hook you are referring to. I will test my code and see if it works.

Thanks.

--------------- Added [DATE]1203427548[/DATE] at [TIME]1203427548[/TIME] ---------------

Thanks that worked great!



James
Reply With Quote
  #7  
Old 02-19-2008, 03:56 PM
cheesegrits's Avatar
cheesegrits cheesegrits is offline
 
Join Date: May 2006
Posts: 500
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Opserty View Post
trigger?
As of MySQL 5.02, you can add 'triggers' to tables. So you can specify things like "when data is inserted into table A, do such-and-such to table B". See:

http://dev.mysql.com/doc/refman/5.0/en/triggers.html

The advantage of this approach is that you don't have to write any PHP code, it just happens automagically within MySQL. The disadvantage is that ... well, you don't have any PHP code and it happens automagically within MySQL. So you can't add any data which can't be derived from a select on existing MySQL data, and you can't handle errors gracefully. And of course it's MySQL version specific.

If all you are doing is literally inserting data already present in your table(s) into another table, triggers are a useful shortcut.

-- hugh
Reply With Quote
  #8  
Old 02-19-2008, 05:22 PM
Coders Shack Coders Shack is offline
 
Join Date: Apr 2007
Location: Culver City, CA
Posts: 807
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

wow thats f***in sweet! Thx for pointing that out, too bad the company i work at still uses PHP 4 ><.
Reply With Quote
  #9  
Old 02-19-2008, 05:46 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

MySQL... not PHP.
Reply With Quote
  #10  
Old 02-20-2008, 05:48 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Still, most servers have MySQL 4.x installed .
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 01:50 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.08153 seconds
  • Memory Usage 2,256KB
  • Queries Executed 13 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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