在CakePHP中使用WHERE IN子句更新 [英] Update with WHERE IN clause in CakePHP

查看:276
本文介绍了在CakePHP中使用WHERE IN子句更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用相同的值更新数据库中的多个记录。是否可能有 WHERE IN('1','2','3','4','5'...); WHERE id = 1 OR id = 2 ...
,这样可以很快发生。

I'm trying to update multiple records in the database with the same value. Is it possible to have WHERE IN('1','2','3','4','5' ...); kind of query or maybe WHERE id = 1 OR id = 2 ... so that this can happen quickly.

我目前正尝试使用 saveAll 更新130行相同的值, p>

I'm currently trying to update 130 rows with the same value using saveAll and it's pretty slow.

推荐答案

您尝试过 updateAll

$this->updateAll(
    array(
       // new values
    ),
    array('id' => array(1,2,3,4,5,6))
);

这篇关于在CakePHP中使用WHERE IN子句更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆