开发者

Is it true that the mysql extension of PHP doesn't support Transactions with "FOR UPDATE"?

开发者 https://www.devze.com 2023-02-08 19:22 出处:网络
If I use the following code my \"row lock\" works fine: mysqli_query($link, \'START TRANSACTION\'); mysqli_query($link, \'SELECT * FROM \'. $table .\' WHERE id开发者_运维问答=1 FOR UPDATE\');

If I use the following code my "row lock" works fine:

mysqli_query($link, 'START TRANSACTION');
mysqli_query($link, 'SELECT * FROM '. $table .' WHERE id开发者_运维问答=1 FOR UPDATE');

Unforunatly my server doesn't support "mysqli". Is it true that the following (with "mysql") doesn't work?

mysql_query($link, 'START TRANSACTION');
mysql_query($link, 'SELECT * FROM '. $table .' WHERE id=1 FOR UPDATE');

Is there a workaround? Thanks


OK - If I use

mysql_query('START TRANSACTION', $link);...

instead of

mysql_query($link, 'START TRANSACTION');...

it works.

0

精彩评论

暂无评论...
验证码 换一张
取 消