yii更新数据的示例

这篇文章主要介绍yii更新数据的示例,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:网站设计、成都网站建设、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的巴宜网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

yii怎么更新数据

1、使用update()

//runValidation boolen 是否通过validate()校验字段 默认为true 
//attributeNames array 需要更新的字段 
$model->update($runValidation , $attributeNames);

2、使用updateAll();

相关文章教程推荐: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更新数据的示例”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!


新闻标题:yii更新数据的示例
URL标题:http://csruizhi.cn/article/gpeojg.html

其他资讯

Copyright © 2007-2024 成都优众联杰科技有限公司 All Rights Reserved 蜀ICP备2024116266号
友情链接: 营销网站建设 成都网站制作 成都定制网站建设 企业网站设计 网站制作报价 成都网站设计公司 成都做网站建设公司 重庆外贸网站建设 营销型网站建设 网站建设方案 成都网站建设 LED网站设计方案 重庆手机网站建设 营销网站建设 成都网站建设 成都网站建设 成都网站建设 外贸营销网站建设 成都网站建设 网站建设公司 移动网站建设 响应式网站设计方案