Simple code for yii to insert database anti-concurrency, and yii to insert database concurrency
Share a piece of useful code of yii:
When you need to auto-increment a field in the database, for example, count the number of queries per day,
Write the following statement:
$ Model-> request_count ++; $ flag = $ model-> save ();
The concurrency may be inaccurate. You can change it:
$ Flag = static: updateAll (['report _ count' => new \ yii \ db \ Expression ("'request _ count' + 1")], ['id' => $ model-> id]);
At the same time, six processes are inserted. Each process is increased by 100 times. The first method is increased to 587, and the second method is increased to 600.
The above is a simple code for yii inserting database anti-concurrency introduced by xiaobian. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!