nginx - Transactions about phpmysql

WBOY
Release: 2016-08-04 09:20:59
Original
1171 people have browsed it

Question: I found that when the transaction has no commit or rollback, it will automatically rollback after the http request ends

Code example:

<code>$this->db->begin();

// 这时候user表这条记录就已经被锁住了。。。
$user = \Users::findFirst($id);
$user->name = '写锁啊!';
sleep(15);

$user->save();
return ;
</code>
Copy after login
Copy after login

But when this request ends, the record in the database can be edited again. . .
I want to ask whether it is nginx, fpm or phalcon that automatically calls PDO->rollback(); ??????

Reply content:

Question: I found that when the transaction has no commit or rollback, it will automatically rollback after the http request ends

Code example:

<code>$this->db->begin();

// 这时候user表这条记录就已经被锁住了。。。
$user = \Users::findFirst($id);
$user->name = '写锁啊!';
sleep(15);

$user->save();
return ;
</code>
Copy after login
Copy after login

But when this request ends, the record in the database can be edited again. . .
I want to ask whether it is nginx, fpm or phalcon that automatically calls PDO->rollback(); ??????

MySQL's AUTOCOMMIT automatic submission parameter is turned on by default. It will only be submitted when a commit command is encountered in the transaction.
If it is operated through a MySQL driver in other languages, the MySQL driver will automatically ROLLBACK has no processed transactions.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!