本文整理匯總了PHP中sfDoctrinePager::getResults方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfDoctrinePager::getResults方法的具體用法?PHP sfDoctrinePager::getResults怎麽用?PHP sfDoctrinePager::getResults使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfDoctrinePager
的用法示例。
在下文中一共展示了sfDoctrinePager::getResults方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getResults
public function getResults($hydrationMode = Doctrine::HYDRATE_RECORD)
{
if (!$this->getQuery()->getConnection() instanceof Doctrine_Connection_Mysql) {
return parent::getResults($hydrationMode);
}
return $this->results;
}
示例2: getResults
public function getResults()
{
if (is_null($this->results)) {
$this->getQuery()->orderBy($this->sqlOrderColumn . ' ' . $this->sqlOrder);
$this->results = parent::getResults();
if ($this->sqlOrder !== $this->listOrder) {
$obj = new Doctrine_Collection($this->results->getTable(), $this->results->getKeyColumn());
$obj->fromArray(array_reverse($this->results->toArray(true)));
$this->results = $obj;
}
}
return $this->results;
}
示例3: executeIndex
public function executeIndex(sfWebRequest $request)
{
$this->buildParams();
$pager = new sfDoctrinePager($this->modelClass, 10);
$pager->setQuery($this->buildQuery($request));
$pager->setPage($this->getRequestParameter('page', 1));
$pager->init();
$this->pager = $pager;
aBlogItemTable::populatePages($pager->getResults());
if ($this->getRequestParameter('feed', false)) {
$this->getFeed();
return sfView::NONE;
}
}
示例4: getResults
/**
* Get results
*
* @param mixed $hydrationMode Doctrine hydration mode
* @return array|Doctrine_Collection Results
* @author relo_san
* @since march 10, 2010
*/
public function getResults($hydrationMode = null)
{
if ($this->useCache) {
if (isset($this->cache['data'])) {
return $this->cache['data'];
}
$this->setTableMethod($this->cacheManager->getQueryMethod($this->cacheRoute));
$hydrationMode = Doctrine::HYDRATE_ARRAY;
}
$results = parent::getResults($hydrationMode);
if ($this->useCache && isset($this->cache['pager'])) {
$results = $this->cacheManager->prepareTranslations($results);
$this->cache['data'] = $results;
$this->cacheManager->setContent($this->cacheRoute, $this->cache, $this->getClass(), array_merge(array('page' => $this->getPage()), $this->queryParams));
}
return $results;
}
示例5: executeIndex
public function executeIndex(sfWebRequest $request)
{
$this->buildParams();
$this->max_per_page = $this->getUser()->getAttribute('max_per_page', sfConfig::get('app_aBlog_max_per_page', 20), 'apostropheBlog_prefs');
$pager = new sfDoctrinePager($this->modelClass);
$pager->setMaxPerPage($this->max_per_page);
$pager->setQuery($this->buildQuery($request));
$pager->setPage($this->getRequestParameter('page', 1));
$pager->init();
$this->pager = $pager;
aBlogItemTable::populatePages($pager->getResults());
if ($request->hasParameter('year') || $request->hasParameter('month') || $request->hasParameter('day') || $request->hasParameter('cat') || $request->hasParameter('tag')) {
// Forbid combinations of filters for bots like Google. This prevents aggressive overspidering
// of the same data
$this->getResponse()->addMeta('robots', 'noarchive, nofollow');
}
if ($this->getRequestParameter('feed', false)) {
$this->getFeed();
return sfView::NONE;
}
return $this->pageTemplate;
}
示例6: getResults
/**
* Get results for the pager instance
*
* @param integer $hydrationMode Doctrine::HYDRATE_* constants
* @return mixed Doctrine_Collection/array
*/
public function getResults($hydrationMode = Doctrine::HYDRATE_RECORD)
{
if ($this->results) {
return $this->results;
} else {
return parent::getResults($hydrationMode);
}
}
示例7: 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');
示例8: getResultsWithoutCache
/**
* Get all the results for the pager instance
*
* @param mixed $hydrationMode A hydration mode identifier
*
* @return Doctrine_Collection|array
*/
public function getResultsWithoutCache($hydrationMode = null)
{
return parent::getResults($hydrationMode)->getData();
}
示例9: sfDoctrinePager
$t->diag('->getResults()');
$query = Doctrine_Core::getTable('Article')->createQuery();
$query->setHydrationMode(Doctrine_Core::HYDRATE_NONE);
$pager = new sfDoctrinePager('Article', 10);
$pager->setQuery($query);
$pager->init();
$t->isa_ok($pager->getResults(), 'array', '->getResults() uses the hydration mode set on the query');
// ->getNbResults()
$t->diag('->getNbResults()');
$pager = new sfDoctrinePager('Article', 10);
$pager->init();
$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), count($pager->getResults()), '"Countable" interface returns the number of objects in the current pager');
// 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');
示例10: sfDoctrinePager
$pager->setTableMethod('testTableMethod');
$pager->setPage(1);
$pager->init();
$t->is($pager->getQuery()->getSql(), 'SELECT a.id AS a__id, a.name AS a__name FROM author a WHERE a.id > 0 LIMIT 25');
$pager->setPage(2);
$pager->init();
$t->is($pager->getQuery()->getSql(), 'SELECT a.id AS a__id, a.name AS a__name FROM author a WHERE a.id > 0 LIMIT 25 OFFSET 25');
$results = $pager->getResults();
$t->is(gettype($results), 'object');
$t->is(get_class($results), 'Doctrine_Collection');
$t->is(count($results), $numPerPage);
$t->is($pager->getQuery()->count(), $total);
$t->is($pager->getCountQuery()->count(), $total);
$pager = new sfDoctrinePager('Author', $numPerPage);
$pager->setTableMethod('testTableMethod');
$pager->setPage(1);
$pager->init();
$results = $pager->getResults('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()->getSql(), 'SELECT a.id AS a__id, a.name AS a__name 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()->getSql(), 'SELECT a.id AS a__id, a.name AS a__name FROM author a WHERE a.id < 9999999 LIMIT 25');