zoukankan      html  css  js  c++  java
  • tp3.1.3 各种查询语句

    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();
        }
  • 相关阅读:
    python_函数
    初始python第三天(三)
    python入门练习题2
    python开发进阶之路(一)
    python入门练习题1
    初识Python第三天(二)
    初识Python第三天(一)
    初识Python第二天(4)
    初识python第二天(3)
    c windows控制台输出颜色文字
  • 原文地址:https://www.cnblogs.com/xm666/p/11434117.html
Copyright © 2011-2022 走看看