You are here: Re: [PHP] multiple queries, one transaction « PHP « IT news, forums, messages
Re: [PHP] multiple queries, one transaction

Posted by "Richard Lynch" on 05/21/05 03:33

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация