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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.