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

488 lines
9.0 KiB
PHP

<?php
abstract class BaseCourse extends BaseObject implements Persistent {
protected static $peer;
protected $id;
protected $slug;
protected $collCourseI18ns;
protected $lastCourseI18nCriteria = null;
protected $alreadyInSave = false;
protected $alreadyInValidation = false;
protected $culture;
public function getId()
{
return $this->id;
}
public function getSlug()
{
return $this->slug;
}
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[] = CoursePeer::ID;
}
}
public function setSlug($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->slug !== $v) {
$this->slug = $v;
$this->modifiedColumns[] = CoursePeer::SLUG;
}
}
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->id = $rs->getInt($startcol + 0);
$this->slug = $rs->getString($startcol + 1);
$this->resetModified();
$this->setNew(false);
return $startcol + 2;
} catch (Exception $e) {
throw new PropelException("Error populating Course 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(CoursePeer::DATABASE_NAME);
}
try {
$con->begin();
CoursePeer::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(CoursePeer::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 = CoursePeer::doInsert($this, $con);
$affectedRows += 1;
$this->setId($pk);
$this->setNew(false);
} else {
$affectedRows += CoursePeer::doUpdate($this, $con);
}
$this->resetModified(); }
if ($this->collCourseI18ns !== null) {
foreach($this->collCourseI18ns 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 = CoursePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collCourseI18ns !== null) {
foreach($this->collCourseI18ns 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 = CoursePeer::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->getSlug();
break;
default:
return null;
break;
} }
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = CoursePeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getSlug(),
);
return $result;
}
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = CoursePeer::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->setSlug($value);
break;
} }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = CoursePeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setSlug($arr[$keys[1]]);
}
public function buildCriteria()
{
$criteria = new Criteria(CoursePeer::DATABASE_NAME);
if ($this->isColumnModified(CoursePeer::ID)) $criteria->add(CoursePeer::ID, $this->id);
if ($this->isColumnModified(CoursePeer::SLUG)) $criteria->add(CoursePeer::SLUG, $this->slug);
return $criteria;
}
public function buildPkeyCriteria()
{
$criteria = new Criteria(CoursePeer::DATABASE_NAME);
$criteria->add(CoursePeer::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->setSlug($this->slug);
if ($deepCopy) {
$copyObj->setNew(false);
foreach($this->getCourseI18ns() as $relObj) {
$copyObj->addCourseI18n($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 CoursePeer();
}
return self::$peer;
}
public function initCourseI18ns()
{
if ($this->collCourseI18ns === null) {
$this->collCourseI18ns = array();
}
}
public function getCourseI18ns($criteria = null, $con = null)
{
include_once 'lib/model/om/BaseCourseI18nPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collCourseI18ns === null) {
if ($this->isNew()) {
$this->collCourseI18ns = array();
} else {
$criteria->add(CourseI18nPeer::ID, $this->getId());
CourseI18nPeer::addSelectColumns($criteria);
$this->collCourseI18ns = CourseI18nPeer::doSelect($criteria, $con);
}
} else {
if (!$this->isNew()) {
$criteria->add(CourseI18nPeer::ID, $this->getId());
CourseI18nPeer::addSelectColumns($criteria);
if (!isset($this->lastCourseI18nCriteria) || !$this->lastCourseI18nCriteria->equals($criteria)) {
$this->collCourseI18ns = CourseI18nPeer::doSelect($criteria, $con);
}
}
}
$this->lastCourseI18nCriteria = $criteria;
return $this->collCourseI18ns;
}
public function countCourseI18ns($criteria = null, $distinct = false, $con = null)
{
include_once 'lib/model/om/BaseCourseI18nPeer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
$criteria->add(CourseI18nPeer::ID, $this->getId());
return CourseI18nPeer::doCount($criteria, $distinct, $con);
}
public function addCourseI18n(CourseI18n $l)
{
$this->collCourseI18ns[] = $l;
$l->setCourse($this);
}
public function getCulture()
{
return $this->culture;
}
public function setCulture($culture)
{
$this->culture = $culture;
}
public function getTitle()
{
$obj = $this->getCurrentCourseI18n();
return ($obj ? $obj->getTitle() : null);
}
public function setTitle($value)
{
$this->getCurrentCourseI18n()->setTitle($value);
}
public function getDescription()
{
$obj = $this->getCurrentCourseI18n();
return ($obj ? $obj->getDescription() : null);
}
public function setDescription($value)
{
$this->getCurrentCourseI18n()->setDescription($value);
}
protected $current_i18n = array();
public function getCurrentCourseI18n()
{
if (!isset($this->current_i18n[$this->culture]))
{
$obj = CourseI18nPeer::retrieveByPK($this->getId(), $this->culture);
if ($obj)
{
$this->setCourseI18nForCulture($obj, $this->culture);
}
else
{
$this->setCourseI18nForCulture(new CourseI18n(), $this->culture);
$this->current_i18n[$this->culture]->setCulture($this->culture);
}
}
return $this->current_i18n[$this->culture];
}
public function setCourseI18nForCulture($object, $culture)
{
$this->current_i18n[$culture] = $object;
$this->addCourseI18n($object);
}
}