Skip to content

Instantly share code, notes, and snippets.

@yohangdev
Created March 25, 2015 17:16
Show Gist options
  • Save yohangdev/a29177575336fc143658 to your computer and use it in GitHub Desktop.
Save yohangdev/a29177575336fc143658 to your computer and use it in GitHub Desktop.
PHP Laravel PDO Fetch (Memory save)
<?php
$query = DB::table('users')->where('name', 'John'); //Pretend this is a huge data set
$statement = $query->getConnection()->getPdo()->prepare($query->toSql());
$statement->execute($query->getBindings());
while ($record = $statement->fetch(PDO::FETCH_ASSOC)) {
//Do whatever you want, one row at a time
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment