Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

create a model for your database and it will work fine

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top