gpt4 book ai didi

php - 使用 Yii 的 updateAll() 更新多行

转载 作者:搜寻专家 更新时间:2023-10-31 21:26:59 27 4
gpt4 key购买 nike

我正在尝试更新 Yii 中的多行:

$list = array(1, 2, 3, 4, 5);

foreach($list as $id) {
$query = "UPDATE products SET photos=crawler.photos, status=crawler.status WHERE id=crawler.product_id AND crawler.product_id=$id;";
}

我是 Yii 的新手。基本上,我想用表 scrape 中的值更新表 products 中的行(使用来自 $ 的特定 id列表)。但不是使用 foreach(),而是使用 updateAll()

最佳答案

事件目录模式。好写模式。

$movies_updated = SomeModel::updateAll([
'language' => 'pl',
'age' => 3,
], ['id' => 1]); # condition

关于php - 使用 Yii 的 updateAll() 更新多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34576873/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com