我的 CakePHP 应用程序中有一个操作,它通过模型中的方法运行一个简单的更新语句,如下所示:
public function remove_nasties(){
$query = 'UPDATE holdings
SET holdings.account_id = CONCAT(account_id, "n")
WHERE holdings.nasty = 1 AND Right(holdings.account_id,1) != "n";';
return $this->query($query);
}
查询运行正常,但如何获取受影响的行数?返回的只是一个空数组。
最佳答案
模型方法:getAffectedRows()
:
http://book.cakephp.org/2.0/en/models/additional-methods-and-properties.html#model-getaffectedrows
关于php - CakePHP 获取受影响的原始 SQL 语句行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19683953/