質問

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