美文网首页程序员
tp5分组查询最新的数据

tp5分组查询最新的数据

作者: 牛逼_5596 | 来源:发表于2019-03-07 21:51 被阅读0次

```

$subQuery = Db::table('zhi_user_profit a')

                ->where('group',5)

                ->order('create_time desc')

                ->limit(10000000000)//不加这一行代码就有可能出现不是最新的代码

                ->buildSql();//构建查询语句

            $lists =  Db::table($subQuery.' a')

                ->join(config('prefix').'user_info b','a.user_id=b.id')

                ->where( "a.user_name_old|b.phone",'like',"%{$keyword}%" )

                ->field('a.*,b.phone')

                ->order('create_time','desc')

                ->group('user_id')->fetchSql(true)

                // ->paginate(15,null,['query'=>$param]);

                ->select();

```

相关文章

网友评论

    本文标题:tp5分组查询最新的数据

    本文链接:https://www.haomeiwen.com/subject/hukkpqtx.html