public function showList(){ // $goods = new GoodsModel(); // $goods = D("category"); $goods = M("goods"); // $res = $goods->select(); //查询所有 // $res = $goods->find(1); //查询一条 // $res = $goods->field("goods_name,goods_price")->select(); //想看什么字段就看什么字段 // $res = $goods->limit(5)->select(); //查询5条 limit限制条数 // $res = $goods->limit(5,5)->select(); //查询5条 limit限制条数 第一个值是偏移量,第二个是限制条数 // $res = $goods->order("goods_id asc")->select(); //按照某字段排序,然后查找 // $res = $goods->order("goods_id asc")->limit(5)->select(); //按照某字段排序,5条,然后查找 // $res = $goods->where("goods_price > 5900")->select(); //where goods_price 小于5900的值,然后查找 // $res = $goods->having("goods_name like '%N%' ")->select(); 模糊查询 // $res = $goods->where("goods_id < 4")->count(); //聚合查询 goods_id小于4的有多少个 // $res = $goods->where("goods_id < 9")->max('goods_price'); //id小于9的 goods_price最大值 // $res = $goods->where("goods_id < 9")->min('goods_price'); //id小于9的 goods_price最小值 // $res = $goods->where("goods_id < 9")->avg('goods_price'); //id小于9的 goods_price平均数 $res = $goods->where("goods_id < 9")->sum('goods_price'); //id小于9的 goods_price总和 var_dump($res); $this->assign('goodsinfo',$res); $this->display(); }