The situation is as follows:
$transaction = Yii::app()->db->beginTransaction(); $condition=$model->getCondition(); //обычный select из кучи таблиц if($condition) { //... куча функций, апи вызовов, изменений баланса пользователя, в результате $model->getCondition() уже не вернет прежнего результата } $transaction->commit(); But if the user makes 10-100 requests at the same time, then the code inside the "if ($ condition) {}" will be executed several times, which is unacceptable. Thus, I need a lock for reading inside a transaction, so that the second user request waits until the first transaction is completed, and only then received a response to the $ model-> getCondition () request — an already updated response. I re-read a bunch of things from man, and found only what needs to be written "transaction-isolation = serializable" in the muscle configuration. But this did not help = (Accordingly, the question is: what to do?
PS tables innodb, of course.
LOCK TABLEStables before starting all operations and unlocking them after. But there is an essential minus, requests of all users will be locked for reading. - Finies