2

My users table has over 100K rows. I need to fetch them all for export purpose. But, when I use following code, it doesn't return anything. But, if I apply limit then it returns them. It basically returns 10K rows and when I provide 20K on limit, it doesn't return anything.If I use mysqli_query, it returns all well in the same server and DB.

$myRows = DB::table('users')->get();//returns empty
$myRows = DB::table('users')->take(10000);//returns 10,000 rows
$myRows = DB::table('users')->take(20000);//returns empty

I am new to Laravel. Thanks in advance.

1
  • 1
    Try this php -d memory_limit=-1 composer update if it's ok with memory Commented Aug 10, 2016 at 23:56

1 Answer 1

2

I think chunking (scroll to "Chunking Results From A Table" point) would be good option here.

DB::table('users')->chunk(10000, function($users) {
    //some connect code
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.