當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sfDoctrinePager::getNbResults方法代碼示例

本文整理匯總了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>';
}
開發者ID:RafalJachimczyk,項目名稱:sympal,代碼行數:19,代碼來源:SympalPagerHelper.php

示例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) {
開發者ID:bigcalm,項目名稱:urlcatcher,代碼行數:31,代碼來源:sfDoctrinePagerTest.php

示例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');
開發者ID:sensorsix,項目名稱:app,代碼行數:31,代碼來源:sfDoctrinePagerTest.php


注:本文中的sfDoctrinePager::getNbResults方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。