<?php //查询器新增一条记录 public function save(){ $data = [ 'name' => '李大嘴' 'sex' => 0, 'age' => 27, 'salary => 2100 ]; StaffModel::insert($data); } //新增多条记录 public function saveAll(){ $data = [ ['name'=>'佟掌柜',sex=>0,'age'=25,salary=10000], ['name'=>'莫小贝',sex=>0,'age'=12,salary=500], ['name'=>'白展堂',sex=>0,'age'=27,salary=4000], ['name'=>'李秀才',sex=>0,'age'=22,salary=3500], ]; StaffModel::insertAll($data); } //查询器删除ID为2的记录 public fucntion delete(){ StaffModel::delete(2); } //修改年龄大于30的工资增加500 public function update(){ StaffModel::where('age','>',30) ->data(['salary'=>\think\Db::raw('salary+500')]) ->update(); } //查询所有记录 public function select(){ StaffModel::all() ->field('name','age','sex','salary') ->order(DESC) ->limit(10) ->select(); } >