true来查询就报错Syntax error, unexpected token IDENTIFIER(FOR), near to ' UPDATE'$this->db->begi">
当前位置:Gxlcms > PHP教程 > Phalcon使用行锁for_upade报错?

Phalcon使用行锁for_upade报错?

时间:2021-07-01 10:21:17 帮助过:4人阅读

开启事务后,按照文档说的参数"for_update" => true来查询就报错Syntax error, unexpected token IDENTIFIER(FOR), near to ' UPDATE'

$this->db->begin();
$robots = Robots::find(array(
    "conditions" => "name LIKE %steve%",
    "order" => "name",
    "for_update" => true
));

...

$this->db->commit();

phalcon版本1.3.4
求证,你们的phalcon使用行锁for_upade会报错吗?还是我的代码不对?
http://www.myleftstudio.com/reference/models.html#finding-records

回复内容:

开启事务后,按照文档说的参数"for_update" => true来查询就报错Syntax error, unexpected token IDENTIFIER(FOR), near to ' UPDATE'

$this->db->begin();
$robots = Robots::find(array(
    "conditions" => "name LIKE %steve%",
    "order" => "name",
    "for_update" => true
));

...

$this->db->commit();

phalcon版本1.3.4
求证,你们的phalcon使用行锁for_upade会报错吗?还是我的代码不对?
http://www.myleftstudio.com/reference/models.html#finding-records

是的,phalcon 1.3.X都有这个问题,应该是在今年6月份的时候phalcon 2.0.4解决了这个bug
解决办法,用最新的phalcon,或者使用pdo执行纯sql

人气教程排行