vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Unit Testing & Transactions (https://vborg.vbsupport.ru/showthread.php?t=91268)

VBCoder 06-28-2005 08:18 PM

Unit Testing & Transactions
 
I'd like to use transactions to add unit testing to my vB mods & code. That is, I'd like to tell vB "Start a transaction. Now, use the DM API to do things. Now roll that transaction back" So the tests haven't disturbed anything.

Is there anyway to do this? How? (PHP4/MySQL4, but could switch to PHP5 if necessary)

merk 06-28-2005 10:24 PM

From memory, the transactional things are dealt with by mysql, not php.

But MyISAM doesnt support transactional queries.

Marco van Herwaarden 06-29-2005 05:13 AM

Have a look at the following URL's:
http://dev.mysql.com/books/mysqlpres...rial/ch10.html
http://dev.mysql.com/doc/mysql/en/an...rent-apis.html

Like Merk already say, you can not use this with MyISAM tables. For InnoDB it is basically:

Start transaction:
[sql]BEGIN TRANSACTION;[/sql]

Then end the transaction with one of the following:
[sql]COMMIT;[/sql]
or:
[sql]ROLLBACK;[/sql]

VBCoder 06-30-2005 01:40 AM

Sorry for not being more clear. I know how to do transactions in SQL. My question is, could I somehow wrap vB's actions in transactions. Something like:
Code:

mysql_query('BEGIN TRANSACTION');
build_new_post();
mysql_query('ROLLBACK');

or, even better:
Code:

$vbulletin->database->begin_transaction();
$dm = init_datamanager(...)
$dm->...
$vbulletin->database->rollback_transaction();

Note: I'm working from memory, so my syntax isn't exact


All times are GMT. The time now is 07:31 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.01644 seconds
  • Memory Usage 1,712KB
  • 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_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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