I agree that I am not 100% engaged in the internal development of PDO and MySQL, so I will give an example to make my question more clear.
I am making a pretty crude browser based strategy because I find this an interesting way to learn PHP and databases. I made a mistake testing the battle script when I came across a rather unexpected error. I use Cron Jobs to call the script every minute, looking something like this:
$ sql = "SELECT army_id FROM activearmy WHERE arrival = 0;"
foreach($dbh->query($sql) as $row)
{
battleEngine($row["army_id"]);
}
When the basic calculations are performed (attacking the army against the army of defense), six tables in the database are updated. The problem I am facing is that when I make several attacks on the same target in one minute, from time to time one of these attacks retrieves outdated database information (in one extreme case, attack number 10 brought that same table as attack number 5),
I assume this happens because the script is faster than the database? Is there a way to make PHP wait until all the relevant information appears before repeating the function with the next line of $?
EDIT: , , . , , , PDO , beginTransaction() commit(). , , InnoDB "REPEATABLE READ". Google , REPEATABLE READ . , , , . UPDATE script, ( UPDATE) . while() - loop, , 0. , 0.01 . , while , , ? , , . . , , , . = P