Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transaction (Begin...end) 1

Status
Not open for further replies.

tcardoso

Programmer
Jan 31, 2005
56
PT
Hi,

I'm trying to do:
Code:
$result = mysql_query("DELETE FROM `table` WHERE `field`='value'");
if (mysql_affected_rows()>0) {
   //Run rest of code			
}

My question is:
If after the DELETE runs on DB and before mysql_affected_rows() is called another DELETE or UPDATE, etc occur? Then mysql_affected_rows() its going to return the rows affected by this delete or by the last query to DB.

I found out that I can use Begin...end (
But I never did it, can anyone give me an example (if this is necessary to use).

Thanks
 
No. You have a connection to the database, and a connection behaves like a sort of session. No matter how many statements occur between your DELETE command and you querying the affected rows, you will get the affected rows belonging to your actions only.
This is also valid for LAST_INSERT_ID() and its counterparts in the various language APIs.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top