Immediately after the UPDATE statement follows the SELECT statement, which is supposed to select a new value of the updated cell. However, the old value is returned. How to solve this with MySQL.

if($q = mysql_query("UPDATE `table-1` SET `cell-1` = '1', `last_load` = IF(`last_load` = '0000-00-00 00:00:00', DATE_ADD(NOW(), INTERVAL 10 DAY), IF(`last_load` < CURDATE(), DATE_ADD(NOW(), INTERVAL 10 DAY), DATE_ADD(`last_load`, INTERVAL 10 DAY) ) ) WHERE `column_id` = '$column_id'")) { $q = mysql_query("SELECT `last_load` FROM `table-1` WHERE `column_id` = '$column_id'"); send(true,mysql_fetch_assoc($q)['last_load']); } 
  • Are you sure that the value is updated? - jashka
  • Is MySQL server one or are we talking about multiple replication related? - cheops
  • Not. MySQL only. As shown in the code, I write to the table, and I want, after computing and updating the line, to get from it a new value that I have to write there. If I refresh the page, I see that everything is updated correctly. There is a suspicion on the queue of requests. Those. I get the result of the select earlier than updating the string. - LuckyMen 8:50 pm
  • There is no queue in php. select must return updated data. Look for a mistake somewhere else. for example, this send does not send or send anything, but the browser does not receive. Before send, write to some info file that you were in this place when and what at the same time came back from the select - Mike
  • Mr. Mike))) Read pzh carefully. I wrote that it returns the value that is in the table before it is updated. Of course, there are no queues in php, the queue (stack) of requests is formed in MySQL, which are executed instantly, which are not. And I understand that perfectly. Php is only a script implementation language. Here is only the sequence of operations in php (template). And directly this code naturally will not return anything. In general, the code is working, except for the problem described. - LuckyMen

0