一 实例化模型对象
①实例化通用模型
例:$goods_model = new \Model\GoodsModel();
$goods_Model = D(‘Goods‘);
②实例化基例模型例: $goods_model = M();
二 模型Model查看数据
$goods_model= D(‘Goods‘);
$info $goods_model ->
field()->
where()->
order()->
limit()->
having()->
select();
$info = $Goods_model ->select();
三 模型model增加数据
$user_model = D(‘User‘);
$data = array(
‘username‘=>‘tom‘,
‘password‘=>‘tom‘,
‘user_email‘=>‘241‘
);
$rzt =$User_model -> add($data);
四 模型model修改数据
$data = array(
‘user_id‘=>5,
‘username‘=>‘tom‘,
‘password‘=>‘5454‘
);
$user_model = D (‘User‘);
$ras = $User_model -> save($data);或者$ras = $user_model ->where (‘user_id=5‘)->save();
五 模型model删除数据
$z= $model -> where ("password=‘1564‘") -> delete();
或者
$moddel -> user_id=8;
$z = $model -> delete();
或者
$z = $model -> delete(10;)