The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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! |
#2
|
||||
|
||||
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.
|
#3
|
|||
|
|||
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. |
#4
|
|||
|
|||
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. |
#5
|
|||
|
|||
If i'm correct, you can use $db->query() to do any valid mysql query. I've always assumed as much anyway...
|
#6
|
||||
|
||||
Yes, that is true, but also note that $db->query() is deprecated and has been replaced by $db->mysql_read() and $db->mysql_write().
|
#7
|
|||
|
|||
Quote:
$db->query_write is used for write queries. |
#8
|
||||
|
||||
Yep, my bad.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|