Skip to content

Instantly share code, notes, and snippets.

View dschniepp's full-sized avatar
👷‍♂️
Building

Daniel Schniepp dschniepp

👷‍♂️
Building
View GitHub Profile
<?php
/* This gist is offered as is, make sure to test in your environment
*
* This class can be used to iterate over a large Eloquent query. It uses a combination of the PDO Fetch and
* the chunk methods to collect a series of items in memory. The chunk part was necessary in order to implement
* eager loading options. You can set the CHUNK_SIZE in the code to set how many rows to load in memory at a time
* again for the eager loading purposes.
*
* I am sure there are other ways to implement this technique more effectively