Jump to content

running a function for each update row in a query


isedeasy

Recommended Posts

I would like to set up a cron to automatically remove items that have a low score after the first day. The problem is that I want to run a function that sends off a pm to the user for each item that is removed.

 

At the moment I just have

 

mysql_query("UPDATE deals SET status = 2 WHERE score < 0 AND added > $day AND status = 1");

 

Is there away to get an array of rows affected?

  Quote

I would like to set up a cron to automatically remove items that have a low score after the first day. The problem is that I want to run a function that sends off a pm to the user for each item that is removed.

 

At the moment I just have

 

mysql_query("UPDATE deals SET status = 2 WHERE score < 0 AND added > $day AND status = 1");

 

Is there away to get an array of rows affected?

 

You could run two queries if you wanted. The first of course would be a select that would check for the records with the same WHERE conditions and then print them to the user in whatever way you are doing it. The second would be the update. The only function that is most like what you need displays only the number of rows affected

http://php.net/manual/en/function.mysql-affected-rows.php

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.