/oiserver/lib/model/om/BasePcgroup.php
PHP | 528 lines | 383 code | 145 blank | 0 comment | 59 complexity | 23349fd4fa2c7ff3badd62adf1442a5c MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-3.0
- <?php
- abstract class BasePcgroup extends BaseObject implements Persistent {
- const PEER = 'PcgroupPeer';
-
- protected static $peer;
-
- protected $id;
-
- protected $name;
-
- protected $collPcs;
-
- private $lastPcCriteria = null;
-
- protected $alreadyInSave = false;
-
- protected $alreadyInValidation = false;
-
- public function __construct()
- {
- parent::__construct();
- $this->applyDefaultValues();
- }
-
- public function applyDefaultValues()
- {
- }
-
- public function getId()
- {
- return $this->id;
- }
-
- public function getName()
- {
- return $this->name;
- }
-
- public function setId($v)
- {
- if ($v !== null) {
- $v = (int) $v;
- }
- if ($this->id !== $v) {
- $this->id = $v;
- $this->modifiedColumns[] = PcgroupPeer::ID;
- }
- return $this;
- }
-
- public function setName($v)
- {
- if ($v !== null) {
- $v = (string) $v;
- }
- if ($this->name !== $v) {
- $this->name = $v;
- $this->modifiedColumns[] = PcgroupPeer::NAME;
- }
- 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->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
- $this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
- $this->resetModified();
- $this->setNew(false);
- if ($rehydrate) {
- $this->ensureConsistency();
- }
- return $startcol + 2;
- } catch (Exception $e) {
- throw new PropelException("Error populating Pcgroup object", $e);
- }
- }
-
- public function ensureConsistency()
- {
- }
-
- 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(PcgroupPeer::DATABASE_NAME, Propel::CONNECTION_READ);
- }
-
- $stmt = PcgroupPeer::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->collPcs = null;
- $this->lastPcCriteria = 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(PcgroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
- }
-
- $con->beginTransaction();
- try {
- PcgroupPeer::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(PcgroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
- }
-
- $con->beginTransaction();
- try {
- $affectedRows = $this->doSave($con);
- $con->commit();
- PcgroupPeer::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->isNew() ) {
- $this->modifiedColumns[] = PcgroupPeer::ID;
- }
- if ($this->isModified()) {
- if ($this->isNew()) {
- $pk = PcgroupPeer::doInsert($this, $con);
- $affectedRows += 1;
- $this->setId($pk);
- $this->setNew(false);
- } else {
- $affectedRows += PcgroupPeer::doUpdate($this, $con);
- }
- $this->resetModified(); }
- if ($this->collPcs !== null) {
- foreach ($this->collPcs as $referrerFK) {
- if (!$referrerFK->isDeleted()) {
- $affectedRows += $referrerFK->save($con);
- }
- }
- }
- $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 (($retval = PcgroupPeer::doValidate($this, $columns)) !== true) {
- $failureMap = array_merge($failureMap, $retval);
- }
- if ($this->collPcs !== null) {
- foreach ($this->collPcs as $referrerFK) {
- if (!$referrerFK->validate($columns)) {
- $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
- }
- }
- }
- $this->alreadyInValidation = false;
- }
- return (!empty($failureMap) ? $failureMap : true);
- }
-
- public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
- {
- $pos = PcgroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
- $field = $this->getByPosition($pos);
- return $field;
- }
-
- public function getByPosition($pos)
- {
- switch($pos) {
- case 0:
- return $this->getId();
- break;
- case 1:
- return $this->getName();
- break;
- default:
- return null;
- break;
- } }
-
- public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
- {
- $keys = PcgroupPeer::getFieldNames($keyType);
- $result = array(
- $keys[0] => $this->getId(),
- $keys[1] => $this->getName(),
- );
- return $result;
- }
-
- public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
- {
- $pos = PcgroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
- return $this->setByPosition($pos, $value);
- }
-
- public function setByPosition($pos, $value)
- {
- switch($pos) {
- case 0:
- $this->setId($value);
- break;
- case 1:
- $this->setName($value);
- break;
- } }
-
- public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
- {
- $keys = PcgroupPeer::getFieldNames($keyType);
- if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
- if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
- }
-
- public function buildCriteria()
- {
- $criteria = new Criteria(PcgroupPeer::DATABASE_NAME);
- if ($this->isColumnModified(PcgroupPeer::ID)) $criteria->add(PcgroupPeer::ID, $this->id);
- if ($this->isColumnModified(PcgroupPeer::NAME)) $criteria->add(PcgroupPeer::NAME, $this->name);
- return $criteria;
- }
-
- public function buildPkeyCriteria()
- {
- $criteria = new Criteria(PcgroupPeer::DATABASE_NAME);
- $criteria->add(PcgroupPeer::ID, $this->id);
- return $criteria;
- }
-
- public function getPrimaryKey()
- {
- return $this->getId();
- }
-
- public function setPrimaryKey($key)
- {
- $this->setId($key);
- }
-
- public function copyInto($copyObj, $deepCopy = false)
- {
- $copyObj->setName($this->name);
- if ($deepCopy) {
- $copyObj->setNew(false);
- foreach ($this->getPcs() as $relObj) {
- if ($relObj !== $this) { $copyObj->addPc($relObj->copy($deepCopy));
- }
- }
- }
- $copyObj->setNew(true);
- $copyObj->setId(NULL);
- }
-
- 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 PcgroupPeer();
- }
- return self::$peer;
- }
-
- public function clearPcs()
- {
- $this->collPcs = null; }
-
- public function initPcs()
- {
- $this->collPcs = array();
- }
-
- public function getPcs($criteria = null, PropelPDO $con = null)
- {
- if ($criteria === null) {
- $criteria = new Criteria(PcgroupPeer::DATABASE_NAME);
- }
- elseif ($criteria instanceof Criteria)
- {
- $criteria = clone $criteria;
- }
- if ($this->collPcs === null) {
- if ($this->isNew()) {
- $this->collPcs = array();
- } else {
- $criteria->add(PcPeer::PCGROUP_ID, $this->id);
- PcPeer::addSelectColumns($criteria);
- $this->collPcs = PcPeer::doSelect($criteria, $con);
- }
- } else {
- if (!$this->isNew()) {
-
- $criteria->add(PcPeer::PCGROUP_ID, $this->id);
- PcPeer::addSelectColumns($criteria);
- if (!isset($this->lastPcCriteria) || !$this->lastPcCriteria->equals($criteria)) {
- $this->collPcs = PcPeer::doSelect($criteria, $con);
- }
- }
- }
- $this->lastPcCriteria = $criteria;
- return $this->collPcs;
- }
-
- public function countPcs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
- {
- if ($criteria === null) {
- $criteria = new Criteria(PcgroupPeer::DATABASE_NAME);
- } else {
- $criteria = clone $criteria;
- }
- if ($distinct) {
- $criteria->setDistinct();
- }
- $count = null;
- if ($this->collPcs === null) {
- if ($this->isNew()) {
- $count = 0;
- } else {
- $criteria->add(PcPeer::PCGROUP_ID, $this->id);
- $count = PcPeer::doCount($criteria, $con);
- }
- } else {
- if (!$this->isNew()) {
-
- $criteria->add(PcPeer::PCGROUP_ID, $this->id);
- if (!isset($this->lastPcCriteria) || !$this->lastPcCriteria->equals($criteria)) {
- $count = PcPeer::doCount($criteria, $con);
- } else {
- $count = count($this->collPcs);
- }
- } else {
- $count = count($this->collPcs);
- }
- }
- $this->lastPcCriteria = $criteria;
- return $count;
- }
-
- public function addPc(Pc $l)
- {
- if ($this->collPcs === null) {
- $this->initPcs();
- }
- if (!in_array($l, $this->collPcs, true)) { array_push($this->collPcs, $l);
- $l->setPcgroup($this);
- }
- }
-
- public function clearAllReferences($deep = false)
- {
- if ($deep) {
- if ($this->collPcs) {
- foreach ((array) $this->collPcs as $o) {
- $o->clearAllReferences($deep);
- }
- }
- }
- $this->collPcs = null;
- }
- }