如何在laravel
中将其转换为雄辩的ORMSELECT * FROM (
SELECT * FROM chat
WHERE (userID = $session AND toID = $friendID)
OR (userID = $friendID AND toID = $session)
ORDER BY id DESC
LIMIT 10
) AS `table` ORDER by id ASC
答案 0 :(得分:0)
你可以试试这个:
$sql = "SELECT * FROM ( SELECT * FROM chat WHERE (userID = $session AND toID = $friendID) OR (userID = $friendID AND toID = $session)
ORDER BY id DESC LIMIT 10 ) AS table ORDER by id ASC";
$result = DB::select(DB::raw($sql))
$ result变量包含您的输出。您必须使用数据库类
use DB;