323 lines
5.6 KiB
Plaintext
323 lines
5.6 KiB
Plaintext
<?php
|
|
|
|
|
|
abstract class BaseReference extends BaseObject implements Persistent {
|
|
|
|
|
|
|
|
protected static $peer;
|
|
|
|
|
|
|
|
protected $id;
|
|
|
|
|
|
|
|
protected $company_name;
|
|
|
|
|
|
protected $alreadyInSave = false;
|
|
|
|
|
|
protected $alreadyInValidation = false;
|
|
|
|
|
|
public function getId()
|
|
{
|
|
|
|
return $this->id;
|
|
}
|
|
|
|
|
|
public function getCompanyName()
|
|
{
|
|
|
|
return $this->company_name;
|
|
}
|
|
|
|
|
|
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[] = ReferencePeer::ID;
|
|
}
|
|
|
|
}
|
|
|
|
public function setCompanyName($v)
|
|
{
|
|
|
|
|
|
|
|
if ($v !== null && !is_string($v)) {
|
|
$v = (string) $v;
|
|
}
|
|
|
|
if ($this->company_name !== $v) {
|
|
$this->company_name = $v;
|
|
$this->modifiedColumns[] = ReferencePeer::COMPANY_NAME;
|
|
}
|
|
|
|
}
|
|
|
|
public function hydrate(ResultSet $rs, $startcol = 1)
|
|
{
|
|
try {
|
|
|
|
$this->id = $rs->getInt($startcol + 0);
|
|
|
|
$this->company_name = $rs->getString($startcol + 1);
|
|
|
|
$this->resetModified();
|
|
|
|
$this->setNew(false);
|
|
|
|
return $startcol + 2;
|
|
} catch (Exception $e) {
|
|
throw new PropelException("Error populating Reference 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(ReferencePeer::DATABASE_NAME);
|
|
}
|
|
|
|
try {
|
|
$con->begin();
|
|
ReferencePeer::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(ReferencePeer::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 = ReferencePeer::doInsert($this, $con);
|
|
$affectedRows += 1;
|
|
$this->setId($pk);
|
|
$this->setNew(false);
|
|
} else {
|
|
$affectedRows += ReferencePeer::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 (($retval = ReferencePeer::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 = ReferencePeer::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->getCompanyName();
|
|
break;
|
|
default:
|
|
return null;
|
|
break;
|
|
} }
|
|
|
|
|
|
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
|
{
|
|
$keys = ReferencePeer::getFieldNames($keyType);
|
|
$result = array(
|
|
$keys[0] => $this->getId(),
|
|
$keys[1] => $this->getCompanyName(),
|
|
);
|
|
return $result;
|
|
}
|
|
|
|
|
|
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
|
{
|
|
$pos = ReferencePeer::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->setCompanyName($value);
|
|
break;
|
|
} }
|
|
|
|
|
|
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
|
{
|
|
$keys = ReferencePeer::getFieldNames($keyType);
|
|
|
|
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
|
if (array_key_exists($keys[1], $arr)) $this->setCompanyName($arr[$keys[1]]);
|
|
}
|
|
|
|
|
|
public function buildCriteria()
|
|
{
|
|
$criteria = new Criteria(ReferencePeer::DATABASE_NAME);
|
|
|
|
if ($this->isColumnModified(ReferencePeer::ID)) $criteria->add(ReferencePeer::ID, $this->id);
|
|
if ($this->isColumnModified(ReferencePeer::COMPANY_NAME)) $criteria->add(ReferencePeer::COMPANY_NAME, $this->company_name);
|
|
|
|
return $criteria;
|
|
}
|
|
|
|
|
|
public function buildPkeyCriteria()
|
|
{
|
|
$criteria = new Criteria(ReferencePeer::DATABASE_NAME);
|
|
|
|
$criteria->add(ReferencePeer::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->setCompanyName($this->company_name);
|
|
|
|
|
|
$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 ReferencePeer();
|
|
}
|
|
return self::$peer;
|
|
}
|
|
|
|
} |