Jump to content

[SOLVED] Will this actually do something?


cooldude832

Recommended Posts

Lets say I run a query, but its an update query that doesn't update anything (it sets a value to the same thing) integer field.  Can I tell if it didn't do anything, without initally querying the previious information.

 

My point to this is I have a reservation system I am designing and when an admin updates the status on your reservation (this is done in bulk) I want to email you that your status has changed, but I don't want to have to do 2 queries each time.

 

Any ideas??

Link to comment
https://forums.phpfreaks.com/topic/78873-solved-will-this-actually-do-something/
Share on other sites

well i found a better way, update queries return nothing of mysql_affected_rows so basically I run my updates in a loop with mysql_affected_rows() right after like this

<?php
$queries = array();
foreach($_POST['data'] as $key => $value){
	$queries[$key] = "Update `".SALES_TABLE."` Set Status= '".$value."' Where SaleID = '".$key."'";
}
$emails = array();
foreach($queries as $key => $value){
	$tempr = mysql_query($value) or die(mysql_error());
	if(mysql_affected_rows()>0){
		$emails[] = $key;
	}
}
?>

then from that list of keys I run one more query that gets me the data to stuff in my emails that I will send.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.