summaryrefslogtreecommitdiffstats
path: root/application/models/RightRolesMapper.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/models/RightRolesMapper.php')
-rw-r--r--application/models/RightRolesMapper.php52
1 files changed, 26 insertions, 26 deletions
diff --git a/application/models/RightRolesMapper.php b/application/models/RightRolesMapper.php
index e2adff5..d6610f5 100644
--- a/application/models/RightRolesMapper.php
+++ b/application/models/RightRolesMapper.php
@@ -2,23 +2,23 @@
class Application_Model_RightRolesMapper
{
-
+
protected $_dbTable;
- public function findBy($criteria, $value)
- {
- try{
+ public function findBy($criteria, $value)
+ {
+ try{
$db = Zend_Db_Table::getDefaultAdapter();
- $select = $this->getDbTable()->select()
- ->from($this->_dbTable)
- ->where($criteria . ' = ?', $value);
+ $select = $this->getDbTable()->select()
+ ->from($this->_dbTable)
+ ->where($criteria . ' = ?', $value);
$stmt = $select->query();
$result = $stmt->fetchAll();
return $result;
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
}
- }
+ }
public function setDbTable($dbTable)
{
@@ -31,7 +31,7 @@ class Application_Model_RightRolesMapper
}
$this->_dbTable = $dbTable;
-
+
return $this;
}
@@ -40,42 +40,42 @@ class Application_Model_RightRolesMapper
if (null === $this->_dbTable) {
$this->setDbTable('Application_Model_DbTable_RightRoles');
}
-
+
return $this->_dbTable;
}
public function save(Application_Model_RightRoles $rightroles)
{
-
$data = array('roleID'=> $rightroles->getRoleID() ,'rightID'=> $rightroles->getRightID() );
- if (null === ($id = $rightroles->getID()) ) {
- unset($data['rightrolesID']);
- $this->getDbTable()->insert($data);
+ if (null === $rightroles->getRoleID() || null === $rightroles->getRightID()) {
+ return;
} else {
- $this->getDbTable()->update($data, array('rightrolesID = ?' => $id));
+ $this->getDbTable()->insert($data);
}
}
-
+
public function delete(Application_Model_RightRoles $rightroles)
{
- if (null === ($id = $rightroles->getID()) ) {
+ if (null === ($roleID = $rightroles->getRoleID()) || null === ($rightID = $rightroles->getRightID())) {
return;
} else {
- $this->getDbTable()->delete(array('rightrolesID = ?' => $id));
+ $this->getDbTable()->delete(array('roleID = ?' => $roleID, 'rightID = ?' => $roleID));
}
}
- public function find($id, Application_Model_RightRoles $rightroles)
+ public function find($roleID, $rightID)
{
- $result = $this->getDbTable()->find($id);
+ $result = $this->getDbTable()->find($roleID, $rightID);
if (0 == count($result)) {
return;
}
$row = $result->current();
-
+
+ $rightroles = new Application_Model_RightRoles();
$rightroles->setRoleID($row->roleID)->setRightID($row->rightID);
+ return $rightroles;
}
public function fetchAll()
@@ -84,8 +84,8 @@ class Application_Model_RightRolesMapper
$entries = array();
foreach ($resultSet as $row) {
$entry = new Application_Model_RightRoles();
-
- $entry->setRoleID($row->roleID)->setRightID($row->rightID);
+
+ $entry->setRoleID($row->roleID)->setRightID($row->rightID);
$entries[] = $entry;
}
@@ -93,6 +93,6 @@ class Application_Model_RightRolesMapper
}
-
+
}