Browse Source

DbManager some Db fields renaming

tags/2.0.0-beta
Alexander Kochetov 12 years ago
parent
commit
9d3a3b3ebe
  1. 40
      yii/rbac/DbManager.php

40
yii/rbac/DbManager.php

@ -254,8 +254,8 @@ class DbManager extends Manager
} }
$this->db->createCommand() $this->db->createCommand()
->insert($this->assignmentTable, array( ->insert($this->assignmentTable, array(
'userid' => $userId, 'user_id' => $userId,
'itemname' => $itemName, 'item_name' => $itemName,
'bizrule' => $bizRule, 'bizrule' => $bizRule,
'data' => serialize($data) 'data' => serialize($data)
)); ));
@ -272,8 +272,8 @@ class DbManager extends Manager
{ {
return $this->db->createCommand() return $this->db->createCommand()
->delete($this->assignmentTable, array( ->delete($this->assignmentTable, array(
'userid' => $userId, 'user_id' => $userId,
'itemname' => $itemName 'item_name' => $itemName
)) > 0; )) > 0;
} }
@ -286,11 +286,11 @@ class DbManager extends Manager
public function isAssigned($itemName, $userId) public function isAssigned($itemName, $userId)
{ {
$query = new Query; $query = new Query;
return $query->select(array('itemname')) return $query->select(array('item_name'))
->from($this->assignmentTable) ->from($this->assignmentTable)
->where(array( ->where(array(
'userid' => $userId, 'user_id' => $userId,
'itemname' => $itemName 'item_name' => $itemName
)) ))
->createCommand($this->db) ->createCommand($this->db)
->queryScalar() !== false; ->queryScalar() !== false;
@ -308,8 +308,8 @@ class DbManager extends Manager
$query = new Query; $query = new Query;
$row = $query->from($this->assignmentTable) $row = $query->from($this->assignmentTable)
->where(array( ->where(array(
'userid' => $userId, 'user_id' => $userId,
'itemname' => $itemName 'item_name' => $itemName
)) ))
->createCommand($this->db) ->createCommand($this->db)
->queryRow(); ->queryRow();
@ -317,7 +317,7 @@ class DbManager extends Manager
if (($data = @unserialize($row['data'])) === false) { if (($data = @unserialize($row['data'])) === false) {
$data = null; $data = null;
} }
return new Assignment($this, $row['userid'], $row['itemname'], $row['bizrule'], $data); return new Assignment($this, $row['user_id'], $row['item_name'], $row['bizrule'], $data);
} else { } else {
return null; return null;
} }
@ -333,7 +333,7 @@ class DbManager extends Manager
{ {
$query = new Query; $query = new Query;
$rows = $query->from($this->assignmentTable) $rows = $query->from($this->assignmentTable)
->where(array('userid' => $userId)) ->where(array('user_id' => $userId))
->createCommand($this->db) ->createCommand($this->db)
->queryAll(); ->queryAll();
$assignments = array(); $assignments = array();
@ -341,7 +341,7 @@ class DbManager extends Manager
if (($data = @unserialize($row['data'])) === false) { if (($data = @unserialize($row['data'])) === false) {
$data = null; $data = null;
} }
$assignments[$row['itemname']] = new Assignment($this, $row['userid'], $row['itemname'], $row['bizrule'], $data); $assignments[$row['item_name']] = new Assignment($this, $row['user_id'], $row['item_name'], $row['bizrule'], $data);
} }
return $assignments; return $assignments;
} }
@ -357,8 +357,8 @@ class DbManager extends Manager
'bizrule' => $assignment->getBizRule(), 'bizrule' => $assignment->getBizRule(),
'data' => serialize($assignment->getData()), 'data' => serialize($assignment->getData()),
), array( ), array(
'userid' => $assignment->getUserId(), 'user_id' => $assignment->getUserId(),
'itemname' => $assignment->getItemName() 'item_name' => $assignment->getItemName()
)); ));
} }
@ -386,7 +386,7 @@ class DbManager extends Manager
$this->itemTable . ' t1', $this->itemTable . ' t1',
$this->assignmentTable . ' t2' $this->assignmentTable . ' t2'
)) ))
->where(array('userid' => $userId, 'name' => new Expression('itemname'))) ->where(array('user_id' => $userId, 'name' => new Expression('item_name')))
->createCommand($this->db); ->createCommand($this->db);
} else { } else {
$command = $query->select('name', 'type', 'description', 't1.bizrule', 't1.data') $command = $query->select('name', 'type', 'description', 't1.bizrule', 't1.data')
@ -395,9 +395,9 @@ class DbManager extends Manager
$this->assignmentTable . ' t2' $this->assignmentTable . ' t2'
)) ))
->where(array( ->where(array(
'userid' => $userId, 'user_id' => $userId,
'type' => $type, 'type' => $type,
'name' => new Expression('itemname'), 'name' => new Expression('item_name'),
)) ))
->createCommand($this->db); ->createCommand($this->db);
} }
@ -452,7 +452,7 @@ class DbManager extends Manager
':name1' => $name, ':name1' => $name,
':name2' => $name ':name2' => $name
)); ));
$this->db->createCommand()->delete($this->assignmentTable, array('itemname' => $name)); $this->db->createCommand()->delete($this->assignmentTable, array('item_name' => $name));
} }
return $this->db->createCommand()->delete($this->itemTable, array('name' => $name)) > 0; return $this->db->createCommand()->delete($this->itemTable, array('name' => $name)) > 0;
} }
@ -501,9 +501,9 @@ class DbManager extends Manager
)); ));
$this->db->createCommand() $this->db->createCommand()
->update($this->assignmentTable, array( ->update($this->assignmentTable, array(
'itemname' => $item->getName(), 'item_name' => $item->getName(),
), array( ), array(
'itemname' => $oldName, 'item_name' => $oldName,
)); ));
} }

Loading…
Cancel
Save