-
-
Save tiffany-taylor/e73a09c42d7a5eb1efa479735b5db85b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private function iterateSubmissions() | |
{ | |
$nStartFrom = 0; | |
$nLimit = 500; | |
do { | |
$sQuery = 'SELECT blahblah FROM someTable WHERE blahblah = "somecondition" LIMIT ' . $nStartFrom . ', ' . $nLimit; | |
$oResults = $this->oDB->query($sQuery); | |
while ($kRow = $oResults->fetch(\PDO::FETCH_ASSOC)) { | |
yield $kRow; | |
} | |
$nStartFrom += $nLimit; | |
echo 'Start updated to ' . $nStartFrom; | |
} while ($kRow !== false); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private function coworkersMethod() | |
{ | |
$nStartFrom = 0; | |
$nLimit = 500; | |
$bHasResults = true; | |
do { | |
$sQuery = 'SELECT blahblah FROM someTable WHERE blahblah = "somecondition" LIMIT ' . $nStartFrom . ', ' . $nLimit; | |
$oResults = $this->oDB->query($sQuery); | |
if ($oResults->rowCount()) { | |
while ($kRow = $oResults->fetch(\PDO::FETCH_ASSOC)) { | |
yield $kRow; | |
} | |
$nStartFrom += $nLimit; | |
} else { | |
$bHasResults = false; | |
} | |
} while ($bHasResults); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment