09 06 2020
//分组统计数量
    $res = Db::table('table')
            ->field('a_id,count(*) as sum')
            ->group('a_id')
            ->select();
            
//时间区间查询
    $listInfo = Db::table('table')
            ->whereTime('time', 'between', [$startTime, $endTime])
            ->select();

//多表联查
    $res = DB::name('table1')->alias('t1')
            ->join('table2 t2','t1.id = t2.tid')
            //->join(....)
            ...
            ->field('t1.*,t2.id)       
            ->where($where)  
            ->select();
    
//分页查询  
     查询第20到30条
     $res = Db::table('article_tag')
            ->order('id desc')
            ->limit(20,30)
             ->select();

//多条件查询
     $where['name'] = 'name';
     $where['status'] = '1';
     $res = Db::table('article_tag')
            ->where($where)  
            ->select(20);

//in查询
    $id = ['1','2','3' ...];
     $res = Db::table('article_tag')
         ->where('id','in',$id)
         ->select();

//模糊查询
    $where['title'] = ["like","%$title%"];

    $res = Db::table('article_tag')
         ->where($where)
         ->select();
         
 //or查询        
 $data['map']['b1.received'] = array(array('<','b.quantity'),array('not null',''),'or');
 
 
 //exp 同一数据库两个字段值比较
 $res2 = Db::name('resignation')
    ->where('contents_status','exp','<> staff_id')
    ->select();


延伸阅读
  1. 用threejs展示stl格式3D模型
  2. TP5自带图形验证码