/** * Return all targeting groups of specified entity and role * * @param Sppc_Entity $entity * @param Sppc_Role $role * @param string $status * @param string $order * @return Sppc_Db_Table_Rowset_Abstract */ public function findAllByEntityRoleAndStatus(Sppc_Entity $entity, Sppc_Role $role, $status = 'active', $order = 'title ASC') { $select = $this->select(self::SELECT_WITH_FROM_PART)->where('id_entity = ?', $entity->getId())->where('id_role = ?', $role->getId())->where('status = ?', $status); if (!is_null($order)) { $select->order($order); } return $this->fetchAll($select); }
/** * Get specified role from rowset * @param Sppc_Role $role * @return Sppc_Entity_Role_Abstract */ public function getRole(Sppc_Role $role) { $entityRole = null; $position = null; foreach ($this->_data as $key => $row) { if ($row['id_role'] == $role->getId()) { $position = $key; break; } } if (!is_null($position)) { $this->seek($position); $entityRole = $this->current(); } return $entityRole; }
/** * Find row by enity and role * @param Sppc_Entity $entity * @param Sppc_Role $role * @return Sppc_Db_Table_Row */ public function findByEntityAndRole(Sppc_Entity $entity, Sppc_Role $role) { $where = array('id_entity = ?' => $entity->getId(), 'id_role = ?' => $role->getId()); return $this->fetchRow($where); }