依崇稀

导航

 
Db::table('think_user')
    ->where('id','>',1)
    ->where('name','thinkphp')
    ->select(); 

Db::field('user.name,role.title')
->table('think_user user,think_role role')
->limit(10)->select();
Db::table('think_user')
->alias(['think_user'=>'user','think_dept'=>'dept'])
->join('think_dept','dept.user_id= user.id')->select();
等于
SELECT * FROM think_user user INNER JOIN think_dept dept ON dept.user_id= user.id
可以给某个字段设置别名,例如:
Db::table('think_user')->field('id,title,content')->select();
排序
Db::table('think_user')->where('status=1')->order('id desc')->limit(5)->select();

限制数量
Db::table('think_user')
    ->where('status=1')
    ->field('id,name')
    ->limit(10)
    ->select();

分页查询

Db::table('think_article')->limit('10,25')->select();
表示查询文章数据,从第10行开始的25条数据
 
 
posted on 2020-05-08 09:03  依崇稀  阅读(125)  评论(0编辑  收藏  举报