Files
pae.co.at/trunk/proactiveenglish/lib/model/om/BaseLuEmployeePosition.php
2017-03-02 21:57:21 -06:00

424 lines
8.0 KiB
PHP

<?php
abstract class BaseLuEmployeePosition extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $position;
protected $collEmployees;
protected $lastEmployeeCriteria = null;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
public function getId()
{
return $this->id;
}
public function getPosition()
{
return $this->position;
}
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = LuEmployeePositionPeer::ID;
}
}
public function setPosition($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->position !== $v) {
$this->position = $v;
$this->modifiedColumns[] = LuEmployeePositionPeer::POSITION;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->position = $rs->getString($startcol + 1);
$this->resetModified();
$this->setNew(false);
return $startcol + 2;
} catch (Exception $e) {
throw new PropelException("Error populating LuEmployeePosition object", $e);
}
}
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(LuEmployeePositionPeer::DATABASE_NAME);
}
try {
$con->begin();
LuEmployeePositionPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
public function save($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(LuEmployeePositionPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
protected function doSave($con)
{
$affectedRows = 0; if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isModified()) {
if ($this->isNew()) {
$pk = LuEmployeePositionPeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += LuEmployeePositionPeer::doUpdate($this, $con);
}
$this->resetModified(); }
if ($this->collEmployees !== null) {
foreach($this->collEmployees 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 = LuEmployeePositionPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collEmployees !== null) {
foreach($this->collEmployees 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 = LuEmployeePositionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getPosition();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = LuEmployeePositionPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getPosition(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = LuEmployeePositionPeer::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->setPosition($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = LuEmployeePositionPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setPosition($arr[$keys[1]]);
}
public function buildCriteria()
{
$criteria = new Criteria(LuEmployeePositionPeer::DATABASE_NAME);
if ($this->isColumnModified(LuEmployeePositionPeer::ID)) $criteria->add(LuEmployeePositionPeer::ID, $this->id);
if ($this->isColumnModified(LuEmployeePositionPeer::POSITION)) $criteria->add(LuEmployeePositionPeer::POSITION, $this->position);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(LuEmployeePositionPeer::DATABASE_NAME);
$criteria->add(LuEmployeePositionPeer::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->setPosition($this->position);
if ($deepCopy) {
$copyObj->setNew(false);
foreach($this->getEmployees() as $relObj) {
$copyObj->addEmployee($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 LuEmployeePositionPeer();
}
return self::$peer;
}
public function initEmployees()
{
if ($this->collEmployees === null) {
$this->collEmployees = array();
}
}
public function getEmployees($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseEmployeePeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collEmployees === null) {
if ($this->isNew()) {
$this->collEmployees = array();
} else {
$criteria->add(EmployeePeer::POSITION, $this->getId());
EmployeePeer::addSelectColumns($criteria);
$this->collEmployees = EmployeePeer::doSelect($criteria, $con);
}
} else {
if (!$this->isNew()) {
$criteria->add(EmployeePeer::POSITION, $this->getId());
EmployeePeer::addSelectColumns($criteria);
if (!isset($this->lastEmployeeCriteria) || !$this->lastEmployeeCriteria->equals($criteria)) {
$this->collEmployees = EmployeePeer::doSelect($criteria, $con);
}
}
}
$this->lastEmployeeCriteria = $criteria;
return $this->collEmployees;
}
public function countEmployees($criteria = null, $distinct = false, $con = null)
{
include_once 'lib/model/om/BaseEmployeePeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
$criteria->add(EmployeePeer::POSITION, $this->getId());
return EmployeePeer::doCount($criteria, $distinct, $con);
}
public function addEmployee(Employee $l)
{
$this->collEmployees[] = $l;
$l->setLuEmployeePosition($this);
}
}