thinkphp 模型关联一对一排序
`{
"code": 1,
"msg": "操作成功",
"data": {
"list": [{
"id": 55,
"group_id": 3,
"username": "1142843053",
"nickname": "1142843053",
"status": 1,
"userData": {
"id": 54,
"login_times": 2,
"last_login_ip": "118.114.13.254",
"create_ip": "118.114.13.254",
"last_login_time": "2020-10-15 22:48:31",
"create_time": "2020-10-15 22:45:04",
"uid": 55,
"head_img": "",
"isvip": 0,
"expritime": ""
},
"alphaID": "Taaaab"
}, {
"id": 54,
"group_id": 3,
"username": "2105338330",
"nickname": "2105338330",
"status": 1,
"userData": {
"id": 53,
"login_times": 1,
"last_login_ip": "117.174.79.254",
"create_ip": "117.174.79.254",
"last_login_time": "",
"create_time": "2020-10-15 21:36:00",
"uid": 54,
"head_img": "",
"isvip": 0,
"expritime": ""
},
"alphaID": "Saaaab"
}, {
"id": 53,
"group_id": 3,
"username": "483487396",
"nickname": "483487396",
"status": 1,
"userData": {
"id": 52,
"login_times": 1,
"last_login_ip": "42.102.242.135",
"create_ip": "42.102.242.135",
"last_login_time": "",
"create_time": "2020-10-15 15:54:16",
"uid": 53,
"head_img": "",
"isvip": 0,
"expritime": ""
},
"alphaID": "Raaaab"
}],
"count": 39,
}
}`
以上是数据
用户表 user 用户对应的数据表 userdata
thinkphp框架在model里面hasone关联了
` public function userData()
{
return $this->hasOne('userdata', 'uid', 'id');
}`
业务层怎么根据userdata里面的数据排序
比如怎么根据 create_time创建时间排序呢?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用hasWhere 闭包查询