vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   database transactions and prepared statements (https://vborg.vbsupport.ru/showthread.php?t=186178)

Ransy72560 07-23-2008 11:40 PM

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!

Dismounted 07-24-2008 07:39 AM

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.

Marco van Herwaarden 07-24-2008 08:13 AM

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.

Ransy72560 07-24-2008 01:22 PM

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.

Carnage 07-26-2008 05:33 PM

If i'm correct, you can use $db->query() to do any valid mysql query. I've always assumed as much anyway...

Dismounted 07-27-2008 03:52 AM

Quote:

Originally Posted by Carnage- (Post 1584743)
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().

MoT3rror 07-27-2008 05:48 AM

Quote:

Originally Posted by Dismounted (Post 1585004)
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.:D

Dismounted 07-27-2008 06:35 AM

Quote:

Originally Posted by MoT3rror (Post 1585042)
I think you mean $db->query_read and $db->query_first

Yep, my bad.


All times are GMT. The time now is 04:59 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.02043 seconds
  • Memory Usage 1,724KB
  • 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
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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