Skip to content

Instantly share code, notes, and snippets.

@alexlcdee
Last active February 11, 2021 08:50
Show Gist options
  • Save alexlcdee/761135ef078a24b24e959f5d22f710c2 to your computer and use it in GitHub Desktop.
Save alexlcdee/761135ef078a24b24e959f5d22f710c2 to your computer and use it in GitHub Desktop.
batch query
<?php
$itemsPerRequest = 50;
$itemsCriteria = array(
'condition' => 't.type = 2 AND t.isDeleted != 1 AND t.isActive = 1 AND t.itemType = 1000',
'order' => 'id ASC',
'limit' => $itemsPerRequest,
'offset' => 0,
);
$i = 0;
echo 'Adding items list to xml', PHP_EOL;
while (count($items = Catalog::model()->findAll($itemsCriteria)) > 0) {
$yml = $this->insertYmlItems($yml, $items);
$itemsCriteria['offset'] += $itemsPerRequest;
//$i += $itemsPerRequest;
//if ($i > 100) break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment