I am using postgres database in my cakephp project.
I have a table with some data and a column called “status”.
“Status” it’s enum and can be “waiting”, “in_progress”, “completed”.
My script has to get the first found record with status=waiting, change the status to “in_progress” and also get the id of this record and all this in one atomic procedure.
The id is needed after the computation to change status to “completed”.
There will be many such scripts working in parrallel thats why I need this simple “row locking”.
I am using postgres db for the first time – is there any easy way to accomplish this?
Maybe cake supports some convinient way of doing this?
with cakePHP it has no diffrence what kind of DB you have, simply use
$this->Model->find...modify your status and then ‘$this->Model->save….`propably you want to run it in loop and put some kind of const as statuses…