Re: multiple queries, one transaction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 20, 2005 2:02 pm, mayo said:
> I have a site where I need to do multiple queries in sequence.

In sequence, or as one single atomic un-interruptable action?

Cuz, like, just doing them in sequence is real straight forward:

$query = "select ... ";
$meaningful_variable_names_are_good = mysql_query($query...
$query = "select ... ";
$another_good_variable = mysql_query($query...

> I see there is a way to do consider all querys and to fail the entire
> procedure if one query fails. It's a BEGIN and COMMIT statement.

That is called a transaction.

And it is rather hefty performance penalties on your database.

And you need your tables to be innoDB or ??? but not the default MyISAM in
MySQL.

> mysql_query("BEGIN"); // starts the transaction


Just put your queries in here.

ONLY do this if the queries succeed!
If they fail, do mysql_query("ROLLBACK");

> mysql_query("COMMIT"); // ends the transaction
>
> I'm just not certain how it's used.

It's a lot easier to do the queries (you did all the hard work already)
than it is to figure out if you REALLY need them or not...

If you can avoid the transaction, and still have quality data and quality
application, you can gain significant performance that way...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux