我是 Laravel 新手。我面临的问题是,
When I tried to update a column in table with same data using laravel eloquent the affected rows gives me always 1.
这是我运行更新时运行的查询:
update `table` set `updating_column` = 1, `updated_at` = 2016-09-17 15:56:53;
在上面的查询中,laravel 更新 updated_at
列以及我请求更新的列。
这就是为什么我总是有 1 行受到影响。
有没有办法在没有 updated_at
列的情况下获取实际受影响的行。
编辑:
$modelobj = new Model();
$aftcnt = $modelobj->where(['ssnid'=>Session::get('SSNID')])
->update([updating_column'=>1]);
当我总是刷新页面时,变量$aftcnt
给我1。
最佳答案
对于 Laravel 5
您可能会看到获取受影响行的示例
$ids=[10,20,30,40];
$affectedRow=DB::update('update users set is_archive = 1, status=0 where id != ?', $ids);
echo $affectedRow;
exit;
关于php - Laravel Eloquent 更新受影响的行数始终为 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39545965/