vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   vB Save() mysql_insert_id ? (https://vborg.vbsupport.ru/showthread.php?t=170852)

JamesTalbot 02-18-2008 05:18 PM

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

cheesegrits 02-18-2008 07:25 PM

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

Eikinskjaldi 02-18-2008 08:28 PM

or use a trigger.

Opserty 02-18-2008 08:53 PM

Quote:

Originally Posted by Eikinskjaldi (Post 1446197)
or use a trigger.

trigger? :confused:

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.

Lynne 02-18-2008 10:09 PM

Quote:

Originally Posted by cheesegrits (Post 1446164)
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)
          "
); 


JamesTalbot 02-19-2008 11:04 AM

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

cheesegrits 02-19-2008 03:56 PM

Quote:

Originally Posted by Opserty (Post 1446213)
trigger? :confused:

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

Coders Shack 02-19-2008 05:22 PM

wow thats f***in sweet! Thx for pointing that out, too bad the company i work at still uses PHP 4 ><.

Adrian Schneider 02-19-2008 05:46 PM

MySQL... not PHP. ;)

Dismounted 02-20-2008 05:48 AM

Still, most servers have MySQL 4.x installed :p.


All times are GMT. The time now is 09:56 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
  • Page Generation 0.00978 seconds
  • Memory Usage 1,732KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete