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 07-23-2008, 11:40 PM
Ransy72560 Ransy72560 is offline
 
Join Date: Mar 2008
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default database transactions and prepared statements

I apologize in advance if there is documentation on this - I can't find it. If it is available and someone has a link handy, I'd appreciate it.

I have some php code that was originally written to communicate with the database through the PEAR MDB2 module, and I'm porting it into a vBulletin product. I have run into a couple of questions/issues with the way vBulletin interacts with the db:

1) My code currently makes use of database transactions (I need to rollback if any part of the transaction fails). Does vBulletin provide support for this? If not, is there some recommended way I can hack it? For instance, manually initiate a transaction with $db->query("START TRANSACTION;"); ? I'm not sure I like that idea because it seems db-specific, but may be the only option I suppose.

2) My code also makes use of prepared statements because a single transaction has the potential to make a substantial number of inserts into the database. For performance reasons I would like to continue using them. Does vBulletin provide support for this functionality?

Thank you in advance!
Reply With Quote
  #2  
Old 07-24-2008, 07:39 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

vBulletin (in its current form) only uses the MySQL/MySQLi functions, and not PDO. Mainly because the current architecture was coded ages ago. My guess is that vBulletin 4 will most likely use PDO.
Reply With Quote
  #3  
Old 07-24-2008, 08:13 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The default engine vBulletin uses is MyIsam. MyIsam does not support transactions.

If you are adding your own tables, then you can use 1 of the other database engines supported by MySQL that do support transactions.
Reply With Quote
  #4  
Old 07-24-2008, 01:22 PM
Ransy72560 Ransy72560 is offline
 
Join Date: Mar 2008
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, I should have specified that I am creating InnoDB tables, so that's not a problem.

I guess I will try to execute commands directly against MySQL. I was hoping there was a more generic system in place though. Thanks for the replies.
Reply With Quote
  #5  
Old 07-26-2008, 05:33 PM
Carnage Carnage is offline
 
Join Date: Jan 2005
Location: uk
Posts: 760
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If i'm correct, you can use $db->query() to do any valid mysql query. I've always assumed as much anyway...
Reply With Quote
  #6  
Old 07-27-2008, 03:52 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Carnage- View Post
If i'm correct, you can use $db->query() to do any valid mysql query. I've always assumed as much anyway...
Yes, that is true, but also note that $db->query() is deprecated and has been replaced by $db->mysql_read() and $db->mysql_write().
Reply With Quote
  #7  
Old 07-27-2008, 05:48 AM
MoT3rror MoT3rror is offline
 
Join Date: Mar 2007
Posts: 423
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dismounted View Post
Yes, that is true, but also note that $db->query() is deprecated and has been replaced by $db->mysql_read() and $db->mysql_write().
I think you mean $db->query_read and $db->query_first for read queries.
$db->query_write is used for write queries.
Reply With Quote
  #8  
Old 07-27-2008, 06:35 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MoT3rror View Post
I think you mean $db->query_read and $db->query_first
Yep, my bad.
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 07:11 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04373 seconds
  • Memory Usage 2,230KB
  • 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
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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_postinfo_query
  • fetch_postinfo
  • 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