本文整理匯總了PHP中sfDoctrinePager::setTableMethod方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfDoctrinePager::setTableMethod方法的具體用法?PHP sfDoctrinePager::setTableMethod怎麽用?PHP sfDoctrinePager::setTableMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfDoctrinePager
的用法示例。
在下文中一共展示了sfDoctrinePager::setTableMethod方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: WHERE
$pager->init();
$t->is($pager->getQuery()->getSqlQuery(), 'SELECT a.id AS a__id, a.name AS a__name, a.type AS a__type FROM author a WHERE (a.id > 0) LIMIT 25');
$t->ok($pager->isFirstPage());
$pager->setPage(2);
$pager->init();
$t->is($pager->getQuery()->getSqlQuery(), 'SELECT a.id AS a__id, a.name AS a__name, a.type AS a__type FROM author a WHERE (a.id > 0) LIMIT 25 OFFSET 25');
$t->is($pager->getQuery()->count(), $total);
$t->ok($pager->isLastPage());
$results = $pager->getResults();
$t->is(gettype($results), 'object');
$t->is(get_class($results), 'Doctrine_Collection');
$t->is(count($results), $numPerPage);
$t->is($pager->getCountQuery()->count(), $total);
$pager = new sfDoctrinePager('Author', $numPerPage);
$pager->setTableMethod('testTableMethod');
$pager->setPage(1);
$pager->init();
$results = $pager->getResults(Doctrine::HYDRATE_ARRAY);
$t->is(gettype($results), 'array');
$t->is(count($results), $numPerPage);
$pager = new sfDoctrinePager('Author', $numPerPage);
$pager->setTableMethod('testTableMethod2');
$pager->setQuery(Doctrine_Query::create()->from('Author a')->where('a.id < 9999999'));
$pager->setPage(1);
$pager->init();
$t->is($pager->getQuery()->getSqlQuery(), 'SELECT a.id AS a__id, a.name AS a__name, a.type AS a__type FROM author a WHERE (a.id < 9999999 AND a.id > 0) LIMIT 25');
$pager = new sfDoctrinePager('Author', $numPerPage);
$pager->setQuery(Doctrine_Query::create()->from('Author a')->where('a.id < 9999999'));
$pager->setPage(1);
$pager->init();
$t->is($pager->getQuery()->getSqlQuery(), 'SELECT a.id AS a__id, a.name AS a__name, a.type AS a__type FROM author a WHERE (a.id < 9999999) LIMIT 25');
示例2: getPager
protected function getPager($request, $filter)
{
$pager = new sfDoctrinePager('Issue', sfConfig::get('app_max_issues_on_index'));
$pager->setQuery($filter->buildQuery($this->getUser()->getAttribute('issues_filter', $this->getDefaultFilter())));
$pager->setPage($request->getParameter('page', 1));
$pager->setTableMethod('getListQuery');
$pager->init();
return $pager;
}
示例3: sfDoctrinePager
$count = Doctrine_Core::getTable('Article')->createQuery()->count();
$t->is($pager->getNbResults(), $count, '->getNbResults() returns the number of results');
// Countable interface
$t->diag('Countable interface');
$pager = new sfDoctrinePager('Article', 10);
$pager->init();
$t->is(count($pager), $pager->getNbResults(), '"Countable" interface returns the total number of objects');
// Iterator interface
$t->diag('Iterator interface');
$pager = new sfDoctrinePager('Article', 10);
$pager->init();
$normal = 0;
$iterated = 0;
foreach ($pager->getResults() as $object) {
$normal++;
}
foreach ($pager as $object) {
$iterated++;
}
$t->is($iterated, $normal, '"Iterator" interface loops over objects in the current pager');
// ->setTableMethod()
$t->diag('->setTableMethod()');
$pager = new sfDoctrinePager('Article', 10);
$pager->setTableMethod('addOnHomepage');
$pager->init();
$t->is($pager->getNbResults(), count(Doctrine_Core::getTable('Article')->findByIsOnHomepage('1')), '->setTableMethod() update the query');
// Serialization test for defect #7987
$t->diag('Serialization');
$pager = unserialize(serialize($pager));
$pager->init();
$t->is($pager->getNbResults(), count(Doctrine_Core::getTable('Article')->findByIsOnHomepage('1')), 'serialization preserves TableMethod functionality');