public function executeIndex(sfWebRequest $request) { $this->step = sfConfig::get('app_max_usergroups_on_usergrouplist'); $this->getUser()->syncParameters($this, 'usergroup', 'index', array('offset', 'limit', 'sort_column', 'sort_direction'), $request); if (is_null($this->sort_column)) { $this->sort_column = 'name'; $this->sort_direction = 'up'; } if (is_null($this->offset)) { $this->offset = 0; } if (is_null($this->limit) || $this->limit <= 0) { $this->limit = $this->step; } $c = new Criteria(); SortCriteria::addSortCriteria($c, $this->sort_column, UsergroupPeer::getSortAliases(), $this->sort_direction); $c->setOffset($this->offset); if ($this->limit >= 0) { $c->setLimit($this->limit); } $this->usergroup_list = UsergroupPeer::doSelect($c); $c2 = new Criteria(); $this->count = UsergroupPeer::doCount($c2); if ($this->offset < 0 || $this->offset >= $this->count && $this->count > 0) { $this->forward404(); } }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(UsergroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(UsergroupPeer::DATABASE_NAME); $criteria->add(UsergroupPeer::ID, $pks, Criteria::IN); $objs = UsergroupPeer::doSelect($criteria, $con); } return $objs; }
public function getGroups() { $c = new Criteria(); $c->addJoin(UsergroupPeer::ID, UsergroupHasUserPeer::USERGROUP_ID); $c->addJoin(UsergroupPeer::ID, UsergroupHasChiefPeer::USERGROUP_ID); $cGroupsAsMember = $c->getNewCriterion(UsergroupHasUserPeer::USER_ID, $this->getId(), Criteria::EQUAL); $cGroupsAsLeader = $c->getNewCriterion(UsergroupHasChiefPeer::USER_ID, $this->getId(), Criteria::EQUAL); $cGroupsAsMember->addOr($cGroupsAsLeader); $c->addGroupByColumn(UsergroupPeer::ID); $c->add($cGroupsAsMember); return UsergroupPeer::doSelect($c); }