#### 数据新增
use app\index\model\user as userModel;
userModel::create($user);
$user->save();
$user->saveAll($list);
#### 数据查询
$user = userModel::get($id); // id必须是主键
$user = userModel::get(['name'=>'jim']);
echo $user->create_time;
$user = userModel::getByName($name);
$user = userModel::where('age',18)->find();
$user = userModel::all(); // 返回所有的数据
$user = userModel::all(['age'=>29]);
$user = userModel::where(['age','>',18])->select();
#### 更新和删除数据
$user = userModel::get($id);
$user->name = "小明";
$user->age= 21;
$user->save(); // 更新
userModel::update($user); // 更新
userModel::destroy($id); // 删除
$user = userModel::get($id);
if($user){
$user->delete();
}
#### 读取器 和 修改器
一定在定义在Model里面
namespace app\index\Model;
user think\Modle;
class User extends Model{
// create_time读取器
publice function getCreateTimeAttr($createTime){
return date('Y-m-d',$createTime);
}
}