zoukankan      html  css  js  c++  java
  • TP5.1数据库链式操作

    TP5.1数据库链式操作

    public function lianshi()// 链式操作
        {
    
        $data= Db::table('attr')
                ->where('status',1)
                ->order('create_time','DESC')
                ->limit(2)
                ->select();
        //链式操作 连贯操作 打印where status=1 的  create_time 倒序排列两条
    
            $data= Db::table('attr')
                     ->where('id',4)
                     ->field('id,name,color,status')
                     ->find();
        //链式操作  打印 where id=4 的 id,name,color,status 的列的值        
    
    
            $data=     Db::table('attr')
                ->where('status',1)
                ->where('id',4)
                ->delete();         
            //链式操作  删除 同时满足这两个条件的那一条数据
    
    
            $attr = Db::table('attr');
            $attr->order('create_time')
                 ->where('status',1)
                 ->select();
            $data=    $attr->where('id','>',0)->select();
            // $attr会自动带上前面的where条件和order排序的值     
    //---两个相近
            $attr = Db::table('attr');
            $attr->order('create_time')
                ->where('status',1)
                ->select();
            $data=$attr->removeOption('where')->where('id', '>', 0)->select();
            // 清空where查询条件值 保留其它链式操作      
    
    
    
               // var_dump($data);
                return json($data);
        }
  • 相关阅读:

    守护线程
    下载图片
    多线程
    self的作用
    设置项目地址环境
    对象 类
    ValueError: urls must start with a leading slash
    mock挡板接口开发
    K&R——第五章 指针与数组
  • 原文地址:https://www.cnblogs.com/79524795-Tian/p/14620347.html
Copyright © 2011-2022 走看看