SQL语句怎么换成模型

浏览:121 发布日期:2020/01/28 分类:ThinkPHP6专区 关键字: 原生SQL语句
Select *,(SELECT COUNT(*) From tp_users_signin WHERE userid=b.user and to_days(now()) - to_days(FROM_UNIXTIME(tp_users_signin.create_time,"%Y-%m-%d")) <= 1) as scount from tp_users b group by b.id HAVING scount >0

原生SQL语句怎么转换成 下面这样的?下面的有问题,谢谢各位了。

$list = Db::name('Users')
->alias('b')
->field('Select *,(SELECT COUNT(*) From tp_users_signin WHERE userid=b.user and to_days(now()) - to_days(FROM_UNIXTIME(tp_users_signin.create_time,"%Y-%m-%d")) <= 1) as total')
->group('b.id')
->having('total > 0')
->paginate([
'query' => Request::get(),
'list_rows' => $pageSize,
]);
最佳答案
评论( 相关
后面还有条评论,点击查看>>

页面底部区域 foot.htm