yii怎么更新數(shù)據(jù)
1、使用update()
//runValidation boolen 是否通過(guò)validate()校驗(yàn)字段 默認(rèn)為true //attributeNames array 需要更新的字段 $model->update($runValidation , $attributeNames);
2、使用updateAll();
相關(guān)文章教程推薦:yii教程
//update customer set status = 1 where status = 2 Customer::updateAll(['status' => 1], 'status = 2'); //update customer set status = 1 where status = 2 and uid = 1; Customer::updateAll(['status' => 1], ['status'=> '2','uid'=>'1']);
3、使用save();
$customer = Customer::find() ->where(['id' => 1]) ->one(); $customer->name = 'zhangsan'; $customer->save();
更多YII相關(guān)教程及編程知識(shí),請(qǐng)?jiān)L問(wèn)編程學(xué)習(xí)課程。
以上就是yii怎么更新數(shù)據(jù)的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注php中文網(wǎng)其它相關(guān)文章!
每個(gè)人都需要一臺(tái)速度更快、更穩(wěn)定的 PC。隨著時(shí)間的推移,垃圾文件、舊注冊(cè)表數(shù)據(jù)和不必要的后臺(tái)進(jìn)程會(huì)占用資源并降低性能。幸運(yùn)的是,許多工具可以讓 Windows 保持平穩(wěn)運(yùn)行。
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號(hào)
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://m.miracleart.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號(hào)