PDA

View Full Version : Test Mode


Ultragames
02-16-2008, 03:30 AM
Is there any way of running a MySQL query in a sort of test mode. Something along the lines of "If you wanted to actually run this query, it would work."

The only way I can think to do it, is to run a transaction and then roll it back, but I cannot use InnoDB or any other transaction capable format on my host.

The reasons I want to do this, is i have built an extensive PHP class, that runs anywhere from 3 to hundreds of queries. I have tested the class via PHP by making it print out the queries instead of running them so that I can visually inspect them, but if at all possible, I would like to step it up a notch and actually have MySQL test that all of the queries do not contain parse errors, without actually permanently applying the inserts, updates, and deletes.

Yes or No? If so, how?
Thanks!

Fumigator
02-16-2008, 03:46 AM
The only way is as you mentioned, with a transaction and then a rollback.

There are alternatives, however. Do you have a test database? You should. One common method is to export a copy of the table and then run your test on the table then import the copy back into the table, restoring it to its original state. But this should all be done in a Test environment.

Ultragames
02-16-2008, 04:28 AM
Most unfortunate. If anyone else ever find evidents to the contrary, please post them here.

Thank you.