zoukankan      html  css  js  c++  java
  • thinkphp5 模型的 查询操作

    public function index()
    {
      //模型实列化调用get()和find()方法
      $ad = new Destoon_ad;
      $where = function($query){
      $query->field(['pid','url'])->where('aid',1);
      };
      $result = $ad->find($where);    //get()方法
      dump($result->getData());
    }

    public function index()
    {
      //模型实列化调用select()方法
      $ad = new Destoon_ad;
      $where = function($query){
      $query->field(['pid','url'])->where('aid','>',1);
      };
      $result = $ad->select($where);

      foreach ($result as $value){
      dump($value->getData());
      }

    }

    静态方法

    public function index()
    {
      //模型静态find()和get()方法
      $where = function($query){
      $query->where(['aid'=>1]);
      };

      $result = Destoon_ad::get($where);
      dump($result->getData());
    }

  • 相关阅读:
    Python生成器
    Python迭代器
    模块
    列表推倒式
    内置函数 lambda表达式
    函数
    global、nonlocal、迭代器
    练习
    编码数组字典
    字典
  • 原文地址:https://www.cnblogs.com/my2018/p/8849238.html
Copyright © 2011-2022 走看看