本文整理汇总了PHP中sfPropelPager::getResults方法的典型用法代码示例。如果您正苦于以下问题:PHP sfPropelPager::getResults方法的具体用法?PHP sfPropelPager::getResults怎么用?PHP sfPropelPager::getResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfPropelPager
的用法示例。
在下文中一共展示了sfPropelPager::getResults方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeListgridjson
function executeListgridjson()
{
$start = $this->request->getParameterHolder()->has('start') ? $this->request->getParameterHolder()->get('start') : 0;
$limit = $this->request->getParameterHolder()->has('limit') ? $this->request->getParameterHolder()->get('limit') : 20;
$anode = $this->request->getParameterHolder()->has('anode') ? $this->request->getParameterHolder()->get('anode') : null;
$uid = $this->request->getParameterHolder()->get('uid');
$page = $start == 0 ? 1 : ceil($start / $limit) + 1;
$parser = $this->getUser()->getAttributeHolder()->getAll('parser/grid');
$host = "https://" . $this->getRequest()->getHost();
foreach ($parser as $data) {
if ($data["uid"] == $uid) {
$parser = $data;
break;
}
}
$pager = new sfPropelPager($parser["class"], $parser["limit"]);
if ($anode === null) {
$c = $parser["criteria"];
} else {
$parser["datasource"]["method"]["params"]["criteria"] = $parser["criteria"];
$parser["datasource"]["method"]["params"]["gid"] = $anode;
$c = afCall::funcArray(array($parser["datasource"]["class"], $parser["datasource"]["method"]["name"]), $parser["datasource"]["method"]["params"]);
}
$pager->setPeerMethod($parser["select_method"]);
$pager->setPage($page);
$pager->setCriteria($c);
$pager->init();
$grid_data = new afExtjsGridData();
$grid_data->totalCount = $pager->getNbResults();
$items = array();
$i = $j = 0;
foreach ($pager->getResults() as $object) {
foreach ($parser["columns"] as $column) {
$j = 0;
$id = $object->getId();
if (method_exists($object, "get" . $column["phpname"])) {
$tmp = call_user_func(array($object, "get" . $column["phpname"]));
} else {
$tmp = "";
}
if ($tmp && in_array($column["phpname"], $parser["foreign_keys"])) {
$items[$i][$column["column"]] = call_user_func(array($tmp, "__toString"));
} else {
$items[$i][$column["column"]] = $tmp;
}
$items[$i]["_id"] = $anode == null ? $id : rand();
$items[$i]["_parent"] = $anode;
$items[$i]["_is_leaf"] = $anode == null ? false : true;
foreach ($parser["rowactions"] as $k => $action) {
if (!strstr($host . $action["attributes"]["url"], "?")) {
$host . ($action["attributes"]["url"] .= "?");
}
if ($anode !== null) {
$items[$i]["action" . ($j + 1)] = $host . $action["attributes"]["url"] . "id=" . $id . "&";
}
$j++;
}
}
$i++;
}
foreach ($items as $item) {
$grid_data->addRowData($item);
}
return $this->renderText($grid_data->end());
}
示例2: executeListjsonAuditLog
public function executeListjsonAuditLog()
{
$start = $this->request->getParameterHolder()->has('start') ? $this->request->getParameterHolder()->get('start') : 0;
$limit = $this->request->getParameterHolder()->has('limit') ? $this->request->getParameterHolder()->get('limit') : 20;
$page = $start == 0 ? 1 : ceil($start / $limit) + 1;
$c = new Criteria();
$c->addDescendingOrderByColumn(AuditLogPeer::ID);
$pager = new sfPropelPager('AuditLog', $limit);
$pager->setPage($page);
$pager->setCriteria($c);
$pager->init();
$grid_data = new afExtjsGridData();
$grid_data->totalCount = $pager->getNbResults();
foreach ($pager->getResults() as $object) {
$item = Util::getPropelObjectAsArray($object);
$item['user_id'] = $object->getsfGuardUser()->getUsername();
$grid_data->addRowData($item);
}
return $this->renderText($grid_data->end());
}
示例3: getResults
/**
* Override ::getResults() to call ->init() first
*
* @see sfPager
*/
public function getResults()
{
$this->init();
return parent::getResults();
}
示例4: executeJsonactionstree
function executeJsonactionstree()
{
$c = new Criteria();
$start = $this->request->getParameterHolder()->has('start') ? $this->request->getParameterHolder()->get('start') : 0;
$limit = $this->request->getParameterHolder()->has('limit') ? $this->request->getParameterHolder()->get('limit') : 20;
$anode = $this->request->getParameterHolder()->has('anode') ? $this->request->getParameterHolder()->get('anode') : null;
$page = $start == 0 ? 1 : ceil($start / $limit) + 1;
// pager
$pager = new sfPropelPager('afsNotification', $limit);
$pager->setPage($page);
$pager->setCriteria($c);
$pager->init();
$grid_data = new afExtjsGridData();
$grid_data->totalCount = $pager->getNbResults();
foreach ($pager->getResults() as $notification) {
$grid_data->addRowData(array("company" => $notification->getIP(), "lastChange" => '8/1 12:00am', "industry" => 'Manufacturing', "action1" => "https://192.168.0.129/interface/form", "action2" => "https://192.168.0.129/interface/portal", "_id" => $anode == null ? $notification->getId() : rand(), "_parent" => $anode, "_is_leaf" => $anode == null ? false : true, '_color' => $anode == null ? '#ccc000' : '#cc0000', '_selected' => true, "_buttonOnColumn" => "company", "_buttonText" => "Show description", "_buttonDescription" => "It's just a description text 1 " . rand(0, 99) . "!"));
}
if ($anode == null) {
$parent = rand();
$grid_data->addRowData(array("company" => '1 CHILD', "lastChange" => '8/1 12:00am', "industry" => 'Manufacturing', "action1" => "https://192.168.0.129/interface/form", "action2" => "https://192.168.0.129/interface/portal", "_id" => $parent, "_parent" => null, "_is_leaf" => false, '_color' => '#ccc000', '_selected' => true, "_buttonOnColumn" => "company", "_buttonText" => "Show description", "_buttonDescription" => "It's just a description text 2 " . rand(0, 99) . "!"));
$child = rand();
$grid_data->addRowData(array("company" => 'the only CHILD', "lastChange" => '8/1 12:00am', "industry" => 'Manufacturing', "action1" => "https://192.168.0.129/interface/form", "action2" => "https://192.168.0.129/interface/portal", "_id" => $child, "_parent" => $parent, "_is_leaf" => true, '_color' => '#ccc000', '_selected' => true, "_buttonOnColumn" => "company", "_buttonText" => "Show description", "_buttonDescription" => "It's just a description text 3 " . rand(0, 99) . "!"));
$grid_data->addRowData(array("company" => 'the only CHILD 2', "lastChange" => '8/1 12:00am', "industry" => 'Manufacturing', "action1" => "https://192.168.0.129/interface/form", "action2" => "https://192.168.0.129/interface/portal", "_id" => rand(), "_parent" => $child, "_is_leaf" => true, '_color' => '#ccc000', '_selected' => true, "_buttonOnColumn" => "company", "_buttonText" => "Show description", "_buttonDescription" => "It's just a description text 4 " . rand(0, 99) . "!"));
$grid_data->addRowData(array("company" => 'the only CHILD 3', "lastChange" => '8/1 12:00am', "industry" => 'Manufacturing', "action1" => "https://192.168.0.129/interface/form", "action2" => "https://192.168.0.129/interface/portal", "_id" => rand(), "_parent" => $child, "_is_leaf" => true, '_color' => '#ccc000', '_selected' => true, "_buttonOnColumn" => "company", "_buttonText" => "Show description", "_buttonDescription" => "It's just a description text 5 " . rand(0, 99) . "!"));
}
return $this->renderText($grid_data->end());
}
示例5: getMainListPanel
public static function getMainListPanel($documentId, $moduleName, $page = 1)
{
$moduleName = strtolower($moduleName);
try {
if ($moduleName == "tag") {
$moduleName = "admin";
}
$mainList = XMLParser::getXMLdataValues(sfConfig::get('sf_root_dir') . "/apps/panel/modules/" . $moduleName . "/config/mainList.xml");
$displayedObjects = array();
foreach ($mainList as $obj) {
if ($obj['tag'] == 'OBJECT' && $obj['type'] == 'complete') {
$displayedObjects[] = $obj['value'];
}
}
$children = array();
$res = array('children', 'paging');
$c = new Criteria();
if (!$documentId) {
$document = Rootfolder::getRootfolderByModule($moduleName);
if ($document) {
$documentId = $document->getId();
}
}
if ($documentId) {
$pager = new sfPropelPager("Relation", 20);
$c->add(RelationPeer::ID1, $documentId);
$c->add(RelationPeer::DOCUMENT_MODEL2, $displayedObjects, Criteria::IN);
if ($moduleName == 'houses' || $moduleName == 'jobs') {
$c->addDescendingOrderByColumn(RelationPeer::ID2);
} else {
$c->addAscendingOrderByColumn(RelationPeer::SORT_ORDER);
}
$pager->setCriteria($c);
$pager->setPage($page);
$pager->init();
foreach ($pager->getResults() as $relation) {
$id = $relation->getId2();
$res['children'][] = Document::getDocumentInstance($id);
}
}
$res['paging'] = $pager->paging(true);
return $res;
} catch (Exception $e) {
throw $e;
}
}
示例6: createLastYearDivisions
public function createLastYearDivisions()
{
$last_year_school_year = SchoolYearPeer::retrieveLastYearSchoolYear($this->getSchoolYear());
$last_year_career_school_year = CareerSchoolYearPeer::retrieveByCareerAndSchoolYear($this->getCareer(), $last_year_school_year);
SchoolYearPeer::clearInstancePool();
CareerSchoolYearPeer::clearInstancePool();
$con = Propel::getConnection();
try {
$con->beginTransaction();
$criteria = new Criteria();
$criteria->add(DivisionPeer::CAREER_SCHOOL_YEAR_ID, $last_year_career_school_year->getId());
$pager = new sfPropelPager('Division', 10);
$pager->setCriteria($criteria);
$pager->init();
$last_page = $pager->getLastPage();
for ($i = 1; $i <= $last_page; $i++) {
$pager->setPage($i);
$pager->init();
$divisions = $pager->getResults();
//This creates all the divisions, courses and courses subjects of the last year.
foreach ($divisions as $division) {
$division->createCopyForSchoolYear($con, $this);
$division->clearAllReferences(true);
unset($division);
}
DivisionPeer::clearInstancePool();
}
unset($criteria);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
示例7: getMainList
public static function getMainList(&$documentId, $moduleName, $page = 1)
{
$moduleName = strtolower($moduleName);
try {
if ($moduleName == "settings") {
$settingsArr = array();
if (is_readable(sfConfig::get('sf_root_dir') . "/config/settings.xml")) {
$objects = XMLParser::getXMLdataValues(sfConfig::get('sf_root_dir') . "/config/settings.xml");
}
foreach ($objects as $obj) {
if ($obj['tag'] == 'ELEMENT' && $obj['type'] == 'open') {
$objName = $obj['attributes']['LABEL'];
$objDescription = $obj['attributes']['DESCRIPTION'];
}
if ($obj['tag'] == 'ITEM' && $obj['type'] == 'complete') {
//$val = $obj['attributes']['VALUE'];
$settingName = $objName;
//$settingName = strtolower($objName);
$settingsArr[$settingName] = $objDescription;
}
}
$pager = new sfPropelPager("Relation", 20);
$pager->setResults($settingsArr);
$pager->setPage($page);
$pager->init();
foreach ($pager->getResults() as $name => $label) {
$res['children'][$name] = $label;
}
$res['paging'] = $pager->paging(true);
return $res;
}
if ($moduleName == "labels") {
$localesArr = array();
if (is_readable(sfConfig::get('sf_root_dir') . "/config/locales.xml")) {
$objects = XMLParser::getXMLdataValues(sfConfig::get('sf_root_dir') . "/config/locales.xml");
foreach ($objects as $obj) {
if ($obj['tag'] == 'LOCALE' && $obj['type'] == 'open') {
$objName = $obj['attributes']['LABEL'];
if ($obj['attributes']['DESCRIPTION']) {
$objDescription = $obj['attributes']['DESCRIPTION'];
} else {
$objDescription = '[' . $obj['attributes']['LABEL'] . ']';
}
}
if ($obj['tag'] == 'ITEM' && $obj['type'] == 'complete') {
//$val = $obj['attributes']['VALUE'];
$localeName = $objName;
//$localeName = strtolower($objName);
$localesArr[$localeName] = $objDescription;
}
}
}
$pager = new sfPropelPager("Relation", 20);
$pager->setResults($localesArr);
$pager->setPage($page);
$pager->init();
foreach ($pager->getResults() as $name => $label) {
$res['children'][$name] = $label;
}
$res['paging'] = $pager->paging(true);
return $res;
}
$mainList = XMLParser::getXMLdataValues(sfConfig::get('sf_root_dir') . "/apps/panel/modules/" . $moduleName . "/config/mainList.xml");
$displayedObjects = array();
$rootId = null;
foreach ($mainList as $obj) {
if ($obj['tag'] == 'OBJECT' && $obj['type'] == 'complete') {
$displayedObjects[] = $obj['value'];
}
// check overwrite RootID
if ($obj['tag'] == 'OBJECTS' && $obj['type'] == 'open') {
if (array_key_exists("attributes", $obj) && array_key_exists("PARENT", $obj['attributes'])) {
$rootName = $obj['attributes']['PARENT'];
$rootDocument = Rootfolder::getRootfolderByModule($rootName);
if ($rootDocument) {
$rootId = $rootDocument->getId();
}
}
if (array_key_exists("attributes", $obj) && array_key_exists("TAG", $obj['attributes'])) {
$tag = $obj['attributes']['TAG'];
$rootDocument = Document::getDocumentByExclusiveTag($tag);
if ($rootDocument) {
$rootId = $rootDocument->getId();
}
}
}
}
$children = array();
$res = array('children' => array(), 'paging' => '');
$c = new Criteria();
if (!$documentId) {
if ($rootId) {
$documentId = $rootId;
} else {
$document = Rootfolder::getRootfolderByModule($moduleName);
if ($document) {
$documentId = $document->getId();
}
}
}
//.........这里部分代码省略.........
示例8: search
private function search($data)
{
$q = $this->getRequestParameter("q", '');
if (!$q) {
throw new BadRequestException('A search string must be provided.');
}
$page = $this->getRequestParameter("page", '1');
$limit = $this->getRequestParameter("limit", self::PAGE_SIZE);
$culture = $this->getRequestParameter("culture", 'es');
$type = $this->getRequestParameter("type", false);
$cl = new SphinxClient();
$dbConf = Propel::getConfiguration();
$dsn = $dbConf['datasources']['propel']['connection']['dsn'];
$sphinxServer = sfConfig::get('sf_sphinx_server');
$cl->SetServer($sphinxServer, 3312);
$this->limit = 1000;
$cl->SetLimits(0, $this->limit, $this->limit);
$cl->SetArrayResult(true);
$entities = array();
$cl->SetArrayResult(true);
if ($type && $type != 'party' && $type != 'politician' && $type != 'proposal') {
throw new BadRequestException('Invalid type.');
}
if (!$type || $type == 'party') {
$this->res = $cl->Query(SfVoUtil::stripAccents($q), "partido_{$culture}");
if ($this->res !== false) {
if (isset($this->res["matches"]) && is_array($this->res["matches"])) {
$c = new Criteria();
$list = array();
foreach ($this->res["matches"] as $idx => $match) {
$list[] = $match['id'];
}
$c->add(PartidoPeer::ID, $list, Criteria::IN);
//$c->addDescendingOrderByColumn(PartidoPeer::SUMU);
$pager = new sfPropelPager('Partido', $limit);
$pager->setCriteria($c);
$pager->setPage($this->getRequestParameter('page', $page));
$pager->init();
foreach ($pager->getResults() as $partido) {
$entities[] = new Entity($partido);
}
}
}
}
if (!$type || $type == 'politician') {
$this->res = $cl->Query(SfVoUtil::stripAccents($q), "politico_{$culture}");
if ($this->res !== false) {
if (isset($this->res["matches"]) && is_array($this->res["matches"])) {
$c = new Criteria();
$list = array();
foreach ($this->res["matches"] as $idx => $match) {
$list[] = $match['id'];
}
$c = new Criteria();
$c->add(PoliticoPeer::ID, $list, Criteria::IN);
//$c->addDescendingOrderByColumn(PoliticoPeer::SUMU);
$pager = new sfPropelPager('Politico', $limit);
$pager->setCriteria($c);
$pager->setPage($this->getRequestParameter('page', $page));
$pager->init();
foreach ($pager->getResults() as $politico) {
$entities[] = new Entity($politico);
}
}
}
}
if (!$type || $type == 'proposal') {
$this->res = $cl->Query(SfVoUtil::stripAccents($q), "propuesta_{$culture}");
if ($this->res !== false) {
if (isset($this->res["matches"]) && is_array($this->res["matches"])) {
$c = new Criteria();
$list = array();
foreach ($this->res["matches"] as $idx => $match) {
$list[] = $match['id'];
}
$c = new Criteria();
$c->add(PropuestaPeer::ID, $list, Criteria::IN);
//$c->addDescendingOrderByColumn(PropuestaPeer::SUMU);
$pager = new sfPropelPager('Propuesta', $limit);
$pager->setCriteria($c);
$pager->setPage($this->getRequestParameter('page', $page));
$pager->init();
foreach ($pager->getResults() as $propuesta) {
$entities[] = new Entity($propuesta);
}
}
}
}
return $entities;
}
示例9: reloadByAdvancedSearch
private function reloadByAdvancedSearch($params)
{
parse_str($params, $obj);
$arr = array();
$obj = $obj["advancedsearch"];
$page = $obj["page"];
$arr["jobStatus"] = $obj["status_id"];
$arr["dueDateStart"] = $this->getFormattedDate($obj["due_date_start"]);
$arr["dueDateEnd"] = $this->getFormattedDate($obj["due_date_end"]);
$arr["shootDateStart"] = $this->getFormattedDate($obj["shoot_date_start"]);
$arr["shootDateEnd"] = $this->getFormattedDate($obj["shoot_date_end"]);
$arr["clientId"] = $obj["client_id"];
$arr["photographerId"] = $obj["photo_id"];
$arr["sortOn"] = $obj["sort"];
$arr["sortDirection"] = $obj["sort_direction"];
$c = $this->createAdvancedSearchCriteria($arr);
$pager = new sfPropelPager("Job", sfConfig::get("app_items_per_page"));
$pager->setCriteria($c);
$pager->setPage($page);
$pager->setPeerMethod("doSelectJoinAll");
$pager->init();
$results = $pager->getResults();
sfPropelActAsTaggableBehavior::preloadTags($results);
$this->renderPartial("search/advancedRender", array("pager" => $pager));
return sfView::NONE;
}
示例10: closeSchoolYear
/**
* This method check if the students pass the year or not
*
* @param SchoolYear $school_year
* @param PropelPDO $con
*/
public function closeSchoolYear(SchoolYear $school_year, PropelPDO $con = null)
{
$criteria = SchoolYearStudentPeer::retrieveStudentsForSchoolYearCriteria($school_year);
$pager = new sfPropelPager('Student', 100);
$pager->setCriteria($criteria);
$pager->init();
$last_page = $pager->getLastPage();
for ($i = 1; $i <= $last_page; $i++) {
$pager->setPage($i);
$pager->init();
$students = $pager->getResults();
foreach ($students as $student) {
if ($student->getLastStudentCareerSchoolYear()->getStatus() != StudentCareerSchoolYearStatus::WITHDRAWN_WITH_RESERVE) {
$this->stepToNextYear($student, $school_year, $con);
}
}
$school_year->setIsClosed(true);
$school_year->save($con);
StudentPeer::clearInstancePool();
}
}
示例11: execute
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
$c = new Criteria();
$c->add(InstitucionI18nPeer::NOMBRE, 'Ayuntamiento%', Criteria::LIKE);
$c->add(InstitucionI18nPeer::CULTURE, 'es');
$pager = new sfPropelPager('InstitucionI18n', 100);
$pager->setCriteria($c);
$pageNum = 0;
do {
$pageNum++;
echo "\nBlock no. {$pageNum} \n";
$pager->setPage($pageNum);
$pager->init();
$instituciones = $pager->getResults();
foreach ($instituciones as $institucion) {
$geo = GeoPeer::retrieveByPK($institucion->getInstitucion()->getGeoId());
if ($geo) {
echo ".";
$nombreCorto = $geo->getNombre();
//$nombreCorto = $institucion->getInstitucion()->getGeo()->getNombre();
$vanityUrl = SfVoUtil::encodeVanity($nombreCorto);
$c2 = new Criteria();
$c2->add(EleccionPeer::VANITY, "{$vanityUrl}%", Criteria::LIKE);
//$c2->add(EleccionPeer::ID, $id, Criteria::NOT_EQUAL);
$eleccionesLikeMe = EleccionPeer::doSelect($c2);
$counter = 0;
foreach ($eleccionesLikeMe as $eleccionLikeMe) {
$counter++;
}
$vanity = "{$vanityUrl}" . ($counter == 0 ? '' : "-{$counter}");
$eleccion = new Eleccion();
$eleccion->setVanity($vanity);
$eleccion->save();
$ei = new EleccionInstitucion();
$ei->setEleccion($eleccion);
$ei->setInstitucion($institucion->getInstitucion());
$ei->save();
$eleccion_i18n = new EleccionI18n();
$eleccion_i18n->setCulture('es');
$eleccion_i18n->setNombreCorto($nombreCorto);
$eleccion_i18n->setNombre("Elecciones al Ayuntamiento de {$nombreCorto}");
$eleccion_i18n->setEleccion($eleccion);
$eleccion_i18n->save();
$eleccion_i18n = new EleccionI18n();
$eleccion_i18n->setCulture('ca');
$eleccion_i18n->setNombreCorto($nombreCorto);
$eleccion_i18n->setNombre("Eleccions al Ajuntament de {$nombreCorto}");
$eleccion_i18n->setEleccion($eleccion);
$eleccion_i18n->save();
$convocatoria = new Convocatoria();
$convocatoria->setEleccion($eleccion);
$convocatoria->setNombre('2011');
$convocatoria->setFecha('2011/05/22');
$convocatoria->save();
$convocatoria_i18n = new ConvocatoriaI18n();
$convocatoria_i18n->setConvocatoria($convocatoria);
$convocatoria_i18n->setCulture('es');
$convocatoria_i18n->setDescripcion("Las listas y candidatos que se presentan a las elecciones de mayo. Vota y elige al alcalde y a los concejales de {$nombreCorto}. Compara las listas cerradas de los partidos con las listas abiertas de Voota, la lista oficial contra lo que dice la calle.");
$convocatoria_i18n->save();
$convocatoria_i18n = new ConvocatoriaI18n();
$convocatoria_i18n->setConvocatoria($convocatoria);
$convocatoria_i18n->setCulture('ca');
$convocatoria_i18n->setDescripcion("Las listas y candidatos que se presentan a las elecciones de mayo. Vota y elige al alcalde y a los concejales de {$nombreCorto}. Compara las listas cerradas de los partidos con las listas abiertas de Voota, la lista oficial contra lo que dice la calle.");
$convocatoria_i18n->save();
$circu = new Circunscripcion();
$circu->setGeo($geo);
$criteria = new Criteria();
$criteria->add(PoliticoInstitucionPeer::INSTITUCION_ID, $institucion->getId());
$count = PoliticoInstitucionPeer::doCount($criteria);
$circu->setEscanyos($count);
$circu->save();
}
}
} while (!$pager->isLastPage());
}