문제

I am learning about Laravel 4 and I'm trying its pagination. I created a simple query to test the pagination, yet it always end up hanging. If I use get(), it works fine, but when I replace get() with paginate(), it hangs. Here is my code:

DB::table("samp_tbl")
    ->select("id","activity")
    ->whereNull("deleted_at")
    ->orderBy("id","desc")
    ->paginate(5);

Could someone tell me what's wrong with my code?

도움이 되었습니까?

해결책

In case anyone else comes across this issue it's because you are using orderBy. In the Note: area on this page http://laravel.com/docs/4.2/pagination#usage it explains that laravel has issues with groupBy. However I also would assume this would go for orderBy as well. Writing a custom query would be recommended in your case.

다른 팁

create a model for your database and it will work fine

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top