0

I have an agent i defined a job for that php agent file .but if second agent run after 1 minutes and previous agent work not finished yet .its make a problem ..... i want to flag selected rows in every agent that if another agent runs new query they haven't interference

how i change this query is the best way is make a field in that table for selected or not ?and update that field ?

db::query("SELECT 1000 FROM web-service WHERE `state`= 1 AND `fetch_id`="fetchid"  ")//

1-state = 1 is condition for my products

2-i use fetch id to imputation id to each agent what is the best way ?

user1574533
  • 93
  • 1
  • 6

1 Answers1

0

If I understand your question, you don't want multiple scripts working on the same rows at the same time. This is known as contention and can be solved a number of ways.

One way I have solved this problem in the past is to only run my script if it isn't already running. You can do this through a shell script as defined here: Shell script: Ensure that script isn't executed if already running

Community
  • 1
  • 1
Matt
  • 6,993
  • 4
  • 29
  • 50
  • my friend i want to 2 agnet work at the same time but with that own select products – user1574533 Aug 03 '12 at 15:42
  • You can add a column that flags if the product is "in use", set it after the `SELECT`, then update it once your script finishes. – Matt Aug 03 '12 at 15:44
  • hmm is it the best way ? for example can mysql recognize that witch rows selected now and runing ?or the best way is update a field like you for example `in use`? – user1574533 Aug 03 '12 at 15:48
  • Once your `SELECT` is performed, MySQL's job is done. It has no idea what you're doing until the data is manipulated again using an `UPDATE`. – Matt Aug 03 '12 at 15:49