微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

thinkphp 5.0 基础知识4

//更新数据
//public function update()
//{
// $user=new usermodel();
// $user= usermodel::get(1);
////方法一查找并更新数据
// $user->name = ‘安迪’;
// user>emall=andi@qq.com;//if(user->emall = '[email protected]'; // if (user−>emall=′[email protected]′;//if(user->save()){
// return ‘用户跟新成功’;
// }else{
// return ‘用户跟新失败’;
// }
//
//// 方法二直接跟新数据
//// 修改的id和上面的get()括号里面的有关
//// 后缀id可删除
// $user->save([‘name’=>‘刘涛’,‘emall’=>‘[email protected]’],[‘id’=>1]);
//}

//批量更新数据
//public function update()
//{
// $user=new usermodel();
//
// $list=[
//
// [‘id’=>2,‘name’=>‘张杰’,‘emall’=>‘[email protected]’,‘birthday’=>strtotime(‘1988-7-5’)],
// [‘id’=>3,‘name’=>‘谢娜’,‘emall’=>‘[email protected]’,‘birthday’=>strtotime(‘1988-7-4’)]
//
// ];
// user>saveAll(user->saveAll(user−>saveAll(list);
//
//
//}

//通过数据库类跟新数据
//public function update()
//{
// $user=new usermodel();
// //方法
//// $user->where(‘id’,4)->update([‘name’=>‘刘德华’,‘emall’=>‘[email protected]’]);
//
// //方法
// $user->update([‘id’=>5,‘name’=>‘古天乐’,‘emall’=>‘[email protected]’]);
//
//}
//静态方法
// public function update()
// {
// $user=new usermodel();
// //方法
//// usermodel::where(‘id’,6)->update([‘name’=>‘刘德华’,‘emall’=>‘[email protected]’]);
//
// //方法
// usermodel::update([‘id’=>7,‘name’=>‘古天乐’,‘emall’=>‘[email protected]’]);
// }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐