/oiserver/plugins/sfGuardPlugin/lib/model/om/BasesfGuardUserPermission.php
PHP | 508 lines | 359 code | 149 blank | 0 comment | 57 complexity | f3f423fb77579bfc282d7338e57f2d1a MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-3.0
- <?php
- abstract class BasesfGuardUserPermission extends BaseObject implements Persistent {
- const PEER = 'sfGuardUserPermissionPeer';
-
- protected static $peer;
-
- protected $user_id;
-
- protected $permission_id;
-
- protected $asfGuardUser;
-
- protected $asfGuardPermission;
-
- protected $alreadyInSave = false;
-
- protected $alreadyInValidation = false;
-
- public function __construct()
- {
- parent::__construct();
- $this->applyDefaultValues();
- }
-
- public function applyDefaultValues()
- {
- }
-
- public function getUserId()
- {
- return $this->user_id;
- }
-
- public function getPermissionId()
- {
- return $this->permission_id;
- }
-
- public function setUserId($v)
- {
- if ($v !== null) {
- $v = (int) $v;
- }
- if ($this->user_id !== $v) {
- $this->user_id = $v;
- $this->modifiedColumns[] = sfGuardUserPermissionPeer::USER_ID;
- }
- if ($this->asfGuardUser !== null && $this->asfGuardUser->getId() !== $v) {
- $this->asfGuardUser = null;
- }
- return $this;
- }
-
- public function setPermissionId($v)
- {
- if ($v !== null) {
- $v = (int) $v;
- }
- if ($this->permission_id !== $v) {
- $this->permission_id = $v;
- $this->modifiedColumns[] = sfGuardUserPermissionPeer::PERMISSION_ID;
- }
- if ($this->asfGuardPermission !== null && $this->asfGuardPermission->getId() !== $v) {
- $this->asfGuardPermission = null;
- }
- return $this;
- }
-
- public function hasOnlyDefaultValues()
- {
- if (array_diff($this->modifiedColumns, array())) {
- return false;
- }
- return true;
- }
-
- public function hydrate($row, $startcol = 0, $rehydrate = false)
- {
- try {
- $this->user_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
- $this->permission_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
- $this->resetModified();
- $this->setNew(false);
- if ($rehydrate) {
- $this->ensureConsistency();
- }
- return $startcol + 2;
- } catch (Exception $e) {
- throw new PropelException("Error populating sfGuardUserPermission object", $e);
- }
- }
-
- public function ensureConsistency()
- {
- if ($this->asfGuardUser !== null && $this->user_id !== $this->asfGuardUser->getId()) {
- $this->asfGuardUser = null;
- }
- if ($this->asfGuardPermission !== null && $this->permission_id !== $this->asfGuardPermission->getId()) {
- $this->asfGuardPermission = null;
- }
- }
-
- public function reload($deep = false, PropelPDO $con = null)
- {
- if ($this->isDeleted()) {
- throw new PropelException("Cannot reload a deleted object.");
- }
- if ($this->isNew()) {
- throw new PropelException("Cannot reload an unsaved object.");
- }
- if ($con === null) {
- $con = Propel::getConnection(sfGuardUserPermissionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $stmt = sfGuardUserPermissionPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
- $row = $stmt->fetch(PDO::FETCH_NUM);
- $stmt->closeCursor();
- if (!$row) {
- throw new PropelException('Cannot find matching row in the database to reload object values.');
- }
- $this->hydrate($row, 0, true);
- if ($deep) {
- $this->asfGuardUser = null;
- $this->asfGuardPermission = null;
- } }
-
- public function delete(PropelPDO $con = null)
- {
- if ($this->isDeleted()) {
- throw new PropelException("This object has already been deleted.");
- }
- if ($con === null) {
- $con = Propel::getConnection(sfGuardUserPermissionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
- }
-
- $con->beginTransaction();
- try {
- sfGuardUserPermissionPeer::doDelete($this, $con);
- $this->setDeleted(true);
- $con->commit();
- } catch (PropelException $e) {
- $con->rollBack();
- throw $e;
- }
- }
-
- public function save(PropelPDO $con = null)
- {
- if ($this->isDeleted()) {
- throw new PropelException("You cannot save an object that has been deleted.");
- }
- if ($con === null) {
- $con = Propel::getConnection(sfGuardUserPermissionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
- }
-
- $con->beginTransaction();
- try {
- $affectedRows = $this->doSave($con);
- $con->commit();
- sfGuardUserPermissionPeer::addInstanceToPool($this);
- return $affectedRows;
- } catch (PropelException $e) {
- $con->rollBack();
- throw $e;
- }
- }
-
- protected function doSave(PropelPDO $con)
- {
- $affectedRows = 0; if (!$this->alreadyInSave) {
- $this->alreadyInSave = true;
-
- if ($this->asfGuardUser !== null) {
- if ($this->asfGuardUser->isModified() || $this->asfGuardUser->isNew()) {
- $affectedRows += $this->asfGuardUser->save($con);
- }
- $this->setsfGuardUser($this->asfGuardUser);
- }
- if ($this->asfGuardPermission !== null) {
- if ($this->asfGuardPermission->isModified() || $this->asfGuardPermission->isNew()) {
- $affectedRows += $this->asfGuardPermission->save($con);
- }
- $this->setsfGuardPermission($this->asfGuardPermission);
- }
- if ($this->isModified()) {
- if ($this->isNew()) {
- $pk = sfGuardUserPermissionPeer::doInsert($this, $con);
- $affectedRows += 1;
- $this->setNew(false);
- } else {
- $affectedRows += sfGuardUserPermissionPeer::doUpdate($this, $con);
- }
- $this->resetModified(); }
- $this->alreadyInSave = false;
- }
- return $affectedRows;
- }
-
- protected $validationFailures = array();
-
- public function getValidationFailures()
- {
- return $this->validationFailures;
- }
-
- public function validate($columns = null)
- {
- $res = $this->doValidate($columns);
- if ($res === true) {
- $this->validationFailures = array();
- return true;
- } else {
- $this->validationFailures = $res;
- return false;
- }
- }
-
- protected function doValidate($columns = null)
- {
- if (!$this->alreadyInValidation) {
- $this->alreadyInValidation = true;
- $retval = null;
- $failureMap = array();
-
- if ($this->asfGuardUser !== null) {
- if (!$this->asfGuardUser->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->asfGuardUser->getValidationFailures());
- }
- }
- if ($this->asfGuardPermission !== null) {
- if (!$this->asfGuardPermission->validate($columns)) {
- $failureMap = array_merge($failureMap, $this->asfGuardPermission->getValidationFailures());
- }
- }
- if (($retval = sfGuardUserPermissionPeer::doValidate($this, $columns)) !== true) {
- $failureMap = array_merge($failureMap, $retval);
- }
- $this->alreadyInValidation = false;
- }
- return (!empty($failureMap) ? $failureMap : true);
- }
-
- public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
- {
- $pos = sfGuardUserPermissionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
- $field = $this->getByPosition($pos);
- return $field;
- }
-
- public function getByPosition($pos)
- {
- switch($pos) {
- case 0:
- return $this->getUserId();
- break;
- case 1:
- return $this->getPermissionId();
- break;
- default:
- return null;
- break;
- } }
-
- public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
- {
- $keys = sfGuardUserPermissionPeer::getFieldNames($keyType);
- $result = array(
- $keys[0] => $this->getUserId(),
- $keys[1] => $this->getPermissionId(),
- );
- return $result;
- }
-
- public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
- {
- $pos = sfGuardUserPermissionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
- return $this->setByPosition($pos, $value);
- }
-
- public function setByPosition($pos, $value)
- {
- switch($pos) {
- case 0:
- $this->setUserId($value);
- break;
- case 1:
- $this->setPermissionId($value);
- break;
- } }
-
- public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
- {
- $keys = sfGuardUserPermissionPeer::getFieldNames($keyType);
- if (array_key_exists($keys[0], $arr)) $this->setUserId($arr[$keys[0]]);
- if (array_key_exists($keys[1], $arr)) $this->setPermissionId($arr[$keys[1]]);
- }
-
- public function buildCriteria()
- {
- $criteria = new Criteria(sfGuardUserPermissionPeer::DATABASE_NAME);
- if ($this->isColumnModified(sfGuardUserPermissionPeer::USER_ID)) $criteria->add(sfGuardUserPermissionPeer::USER_ID, $this->user_id);
- if ($this->isColumnModified(sfGuardUserPermissionPeer::PERMISSION_ID)) $criteria->add(sfGuardUserPermissionPeer::PERMISSION_ID, $this->permission_id);
- return $criteria;
- }
-
- public function buildPkeyCriteria()
- {
- $criteria = new Criteria(sfGuardUserPermissionPeer::DATABASE_NAME);
- $criteria->add(sfGuardUserPermissionPeer::USER_ID, $this->user_id);
- $criteria->add(sfGuardUserPermissionPeer::PERMISSION_ID, $this->permission_id);
- return $criteria;
- }
-
- public function getPrimaryKey()
- {
- $pks = array();
- $pks[0] = $this->getUserId();
- $pks[1] = $this->getPermissionId();
- return $pks;
- }
-
- public function setPrimaryKey($keys)
- {
- $this->setUserId($keys[0]);
- $this->setPermissionId($keys[1]);
- }
-
- public function copyInto($copyObj, $deepCopy = false)
- {
- $copyObj->setUserId($this->user_id);
- $copyObj->setPermissionId($this->permission_id);
- $copyObj->setNew(true);
- }
-
- public function copy($deepCopy = false)
- {
- $clazz = get_class($this);
- $copyObj = new $clazz();
- $this->copyInto($copyObj, $deepCopy);
- return $copyObj;
- }
-
- public function getPeer()
- {
- if (self::$peer === null) {
- self::$peer = new sfGuardUserPermissionPeer();
- }
- return self::$peer;
- }
-
- public function setsfGuardUser(sfGuardUser $v = null)
- {
- if ($v === null) {
- $this->setUserId(NULL);
- } else {
- $this->setUserId($v->getId());
- }
- $this->asfGuardUser = $v;
- if ($v !== null) {
- $v->addsfGuardUserPermission($this);
- }
- return $this;
- }
-
- public function getsfGuardUser(PropelPDO $con = null)
- {
- if ($this->asfGuardUser === null && ($this->user_id !== null)) {
- $c = new Criteria(sfGuardUserPeer::DATABASE_NAME);
- $c->add(sfGuardUserPeer::ID, $this->user_id);
- $this->asfGuardUser = sfGuardUserPeer::doSelectOne($c, $con);
-
- }
- return $this->asfGuardUser;
- }
-
- public function setsfGuardPermission(sfGuardPermission $v = null)
- {
- if ($v === null) {
- $this->setPermissionId(NULL);
- } else {
- $this->setPermissionId($v->getId());
- }
- $this->asfGuardPermission = $v;
- if ($v !== null) {
- $v->addsfGuardUserPermission($this);
- }
- return $this;
- }
-
- public function getsfGuardPermission(PropelPDO $con = null)
- {
- if ($this->asfGuardPermission === null && ($this->permission_id !== null)) {
- $c = new Criteria(sfGuardPermissionPeer::DATABASE_NAME);
- $c->add(sfGuardPermissionPeer::ID, $this->permission_id);
- $this->asfGuardPermission = sfGuardPermissionPeer::doSelectOne($c, $con);
-
- }
- return $this->asfGuardPermission;
- }
-
- public function clearAllReferences($deep = false)
- {
- if ($deep) {
- }
- $this->asfGuardUser = null;
- $this->asfGuardPermission = null;
- }
- }