请帮助我将laravel的Paginate类与DB原始复杂查询一起使用...
尝试了一些技巧来获得laravel paginate的结果,但是由于查询的复杂性,这给我带来了麻烦
$data = DB::select(DB::raw("SELECT DISTINCT c.id, c.name, c.active, c.image, c.created_at, (SELECT COUNT(*) FROM categories WHERE c.id=parent_id) AS subcat_count, (SELECT COUNT(*) FROM post_ads WHERE c.id=cat_id) AS postad_count FROM categories AS c LEFT OUTER JOIN categories AS subc ON c.id = subc.parent_id LEFT OUTER JOIN post_ads AS postadc ON c.id = postadc.cat_id WHERE c.parent_id=0 ORDER BY c.name ASC LIMIT 9"));
答案 0 :(得分:0)
您可以使用长度感知型分页器进行分页,在您的控制器中做到这样,
@Echo Off
SetLocal DisableDelayedExpansion
Title VHACK!
Echo(
Echo ^| ^| ^| ^| /î\ /îîî\ ^| / ³
Echo ^| ^| ^| ^| / \ ^| ^| / ³
Echo ` ' ^|-----^| '-----` ^| ^|---^< ³
Echo \ / ^| ^| ^| ^| ^| ^| \
Echo \_/ ^| ^| ^| ^| \___/ ^| \ þ
Echo(
Echo Welcome to VHACK!
Pause
GoTo :EOF