本文整理汇总了PHP中sfDoctrinePager::getNbResults方法的典型用法代码示例。如果您正苦于以下问题:PHP sfDoctrinePager::getNbResults方法的具体用法?PHP sfDoctrinePager::getNbResults怎么用?PHP sfDoctrinePager::getNbResults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfDoctrinePager
的用法示例。
在下文中一共展示了sfDoctrinePager::getNbResults方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_sympal_pager_header
/**
* Get a Sympal pager header <h3>
*
* @param sfDoctrinePager $pager
* @return string $html
*/
function get_sympal_pager_header($pager)
{
if ($pager->getNbResults() == 0) {
$txt = __('No results found.');
} elseif ($pager->getNbResults() == 1) {
$txt = __('One result found.');
} elseif ($pager->getLastPage() == 1) {
$txt = __('Showing all %count% total results.', array('%count%' => $pager->getNbResults()));
} else {
$txt = __('Showing %first% to %last% of %count% total results.', array('%first%' => $pager->getFirstIndice(), '%last%' => $pager->getLastIndice(), '%count%' => $pager->getNbResults()));
}
return '<div class="sympal_pager_header"><h3>' . $txt . '</h3></div>';
}
示例2: dirname
include dirname(__FILE__) . '/../../bootstrap/functional.php';
$t = new lime_test(4);
// ->getResults()
$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) {
示例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');