本文整理汇总了PHP中Am_Query::selectPageRecords方法的典型用法代码示例。如果您正苦于以下问题:PHP Am_Query::selectPageRecords方法的具体用法?PHP Am_Query::selectPageRecords怎么用?PHP Am_Query::selectPageRecords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Am_Query
的用法示例。
在下文中一共展示了Am_Query::selectPageRecords方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteProductCategories
protected function deleteProductCategories($demoId)
{
$query = new Am_Query(new ProductCategoryTable());
$query->add(new Am_Query_Condition_Field('code', 'LIKE', $demoId . ':%'));
$count = $query->getFoundRows() ? $query->getFoundRows() : 1;
foreach ($query->selectPageRecords(0, $count) as $pCategory) {
$pCategory->delete();
}
}
示例2: batchProcess
public function batchProcess(&$context, Am_BatchProcessor $batch)
{
@(list($step, $start) = explode('-', $context));
$pageCount = 30;
switch ($step) {
case 0:
$q = new Am_Query($this->getTable());
$count = 0;
$updated = array();
foreach ($q->selectPageRecords($start / $pageCount, $pageCount) as $r) {
$count++;
if (!$this->canUpdate($r)) {
continue;
}
/* @var $r Am_Record */
$user = $this->_table->findAmember($r);
if (!$user) {
// no such records in aMember, disable user record ?
$this->_table->disableRecord($r, $this->calculateGroups(null, true));
} else {
$updated[] = $user->user_id;
$this->getTable()->updateFromAmember($r, $user, $this->calculateGroups($user, true));
$pass = $this->getDi()->savedPassTable->findSaved($user, $this->getPasswordFormat());
if ($pass) {
$this->getTable()->updatePassword($r, $pass);
}
}
}
if (!$count) {
$step++;
$context = "{$step}-0";
} else {
$store = array();
foreach ($updated as $v) {
$store[] = $v;
}
$this->getDi()->storeRebuild->setArray($this->_rebuildName, $this->_sessionId, $store, '+3 hour');
$start += $count;
$context = "{$step}-{$start}";
}
break;
case 1:
/// now select aMember users not exists in plugin db
$count = 0;
$db = $this->getDi()->db;
$r = $db->queryResultOnly("SELECT t.* from ?_user t left join ?_store_rebuild s on s.user_id = t.user_id and s.rebuild_name = ? and s.session_id = ? \n WHERE s.user_id is null LIMIT ?d , ?d", $this->_rebuildName, $this->_sessionId, $start, $pageCount);
while ($row = $db->fetchRow($r)) {
$records[] = $this->getDi()->userTable->createRecord($row);
}
foreach ($records as $user) {
$count++;
/* @var $user User */
$this->onSubscriptionChanged(new Am_Event_SubscriptionChanged($user, array(), array()));
}
if (!$count) {
$context = null;
return true;
}
$start += $count;
$context = "{$step}-{$start}";
break;
default:
throw new Am_Exception_InputError(___('Wrong step'));
}
}
示例3: batchProcess
public function batchProcess(&$context, Am_BatchProcessor $batch)
{
@(list($step, $start) = explode('-', $context));
$pageCount = 30;
switch ($step) {
case 0:
$q = new Am_Query($this->getTable());
$count = 0;
$updated = array();
foreach ($q->selectPageRecords($start / $pageCount, $pageCount) as $r) {
$count++;
if (!$this->canUpdate($r)) {
continue;
}
/* @var $r Am_Record */
$user = $this->_table->findAmember($r);
if (!$user) {
// no such records in aMember, disable user record ?
$this->_table->disableRecord($r, $this->calculateGroups(null, true));
} else {
$updated[] = $user->user_id;
$this->getTable()->updateFromAmember($r, $user, $this->calculateGroups($user));
$pass = $this->getDi()->savedPassTable->findSaved($user, $this->getPasswordFormat());
if ($pass) {
$this->getTable()->updatePassword($r, $pass);
}
}
}
if (!$count) {
$step++;
$context = "{$step}-0";
} else {
$this->getDi()->store->appendBlob($this->_batchStoreId, implode(",", $updated) . ",");
$start += $count;
$context = "{$step}-{$start}";
}
break;
case 1:
/// now select aMember users not exists in plugin db
$q = new Am_Query(new UserTable());
$q->addWhere("(select not find_in_set(t.user_id, s.`blob_value`) \n from ?_store s \n where s.name=?)", $this->_batchStoreId);
$count = 0;
$records = $q->selectPageRecords($start / $pageCount, $pageCount);
foreach ($records as $user) {
$count++;
/* @var $user User */
$this->onSubscriptionChanged(new Am_Event_SubscriptionChanged($user, array(), array()));
}
if (!$count) {
$context = null;
return true;
}
$start += $count;
$context = "{$step}-{$start}";
break;
default:
throw new Am_Exception_InputError("Wrong step");
}
}