【发布时间】:2016-08-28 10:34:35
【问题描述】:
我在我的应用程序中使用 Laravel 5.1。我的 MySQL 查询是
"Select * from "
. "(Select u.* from "
. "( "
. "SELECT u2.id as user_id, u2.fname as fname, u2.lname as lname, u2.uname as uname, u2.email as email, u2.address as address, u2.city_id as city_id, u2.website as website FROM users u1, users u2 where u1.city_id = u2.city_id && u1.id = '$this->current_user_id' )
u left join follows f on u.user_id = f.following_id where f.following_id is null
UNION
Select uu.id as user_id, uu.fname as fname, uu.lname as lname, uu.uname as uname, uu.email as email, uu.address as address, uu.city_id as city_id, uu.website as website from users uu where uu.id in (Select u.user_id from (SELECT user_id FROM reviews group by user_id order by count(user_id) desc5
) u left join follows f on u.user_id=f.following_id where f.following_id is null
)
)
T LIMIT 5"
如何将其转换为 Laravel Eloquent?
【问题讨论】:
-
你试过转换它吗?
-
desc5??那是什么
-
Eloquent 是一个 ORM。所以你需要create the appropriate models和relationships。