<?php


abstract class BaseTblscormcppackage extends BaseObject  implements Persistent {


	
	protected static $peer;

	
	protected $created;

	
	protected $c_identifier;

	
	protected $jsdata;

	
	protected $modified;

	
	protected $obj_id;

	
	protected $persistprevattempts;

	
	protected $c_settings;

	
	protected $xmldata;

	
	protected $activitytree;

	
	protected $global_to_system;

	
	protected $shared_data_global_to_system;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function __construct()
	{
		parent::__construct();
		$this->applyDefaultValues();
	}

	
	public function applyDefaultValues()
	{
		$this->global_to_system = 1;
		$this->shared_data_global_to_system = 1;
	}

	
	public function getCreated()
	{
		return $this->created;
	}

	
	public function getCIdentifier()
	{
		return $this->c_identifier;
	}

	
	public function getJsdata()
	{
		return $this->jsdata;
	}

	
	public function getModified()
	{
		return $this->modified;
	}

	
	public function getObjId()
	{
		return $this->obj_id;
	}

	
	public function getPersistprevattempts()
	{
		return $this->persistprevattempts;
	}

	
	public function getCSettings()
	{
		return $this->c_settings;
	}

	
	public function getXmldata()
	{
		return $this->xmldata;
	}

	
	public function getActivitytree()
	{
		return $this->activitytree;
	}

	
	public function getGlobalToSystem()
	{
		return $this->global_to_system;
	}

	
	public function getSharedDataGlobalToSystem()
	{
		return $this->shared_data_global_to_system;
	}

	
	public function setCreated($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->created !== $v) {
			$this->created = $v;
			$this->modifiedColumns[] = TblscormcppackagePeer::CREATED;
		}

		return $this;
	} 
	
	public function setCIdentifier($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->c_identifier !== $v) {
			$this->c_identifier = $v;
			$this->modifiedColumns[] = TblscormcppackagePeer::C_IDENTIFIER;
		}

		return $this;
	} 
	
	public function setJsdata($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->jsdata !== $v) {
			$this->jsdata = $v;
			$this->modifiedColumns[] = TblscormcppackagePeer::JSDATA;
		}

		return $this;
	} 
	
	public function setModified($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->modified !== $v) {
			$this->modified = $v;
			$this->modifiedColumns[] = TblscormcppackagePeer::MODIFIED;
		}

		return $this;
	} 
	
	public function setObjId($v)
	{
		if ($v !== null) {
			$v = (int) $v;
		}

		if ($this->obj_id !== $v) {
			$this->obj_id = $v;
			$this->modifiedColumns[] = TblscormcppackagePeer::OBJ_ID;
		}

		return $this;
	} 
	
	public function setPersistprevattempts($v)
	{
		if ($v !== null) {
			$v = (int) $v;
		}

		if ($this->persistprevattempts !== $v) {
			$this->persistprevattempts = $v;
			$this->modifiedColumns[] = TblscormcppackagePeer::PERSISTPREVATTEMPTS;
		}

		return $this;
	} 
	
	public function setCSettings($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->c_settings !== $v) {
			$this->c_settings = $v;
			$this->modifiedColumns[] = TblscormcppackagePeer::C_SETTINGS;
		}

		return $this;
	} 
	
	public function setXmldata($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->xmldata !== $v) {
			$this->xmldata = $v;
			$this->modifiedColumns[] = TblscormcppackagePeer::XMLDATA;
		}

		return $this;
	} 
	
	public function setActivitytree($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->activitytree !== $v) {
			$this->activitytree = $v;
			$this->modifiedColumns[] = TblscormcppackagePeer::ACTIVITYTREE;
		}

		return $this;
	} 
	
	public function setGlobalToSystem($v)
	{
		if ($v !== null) {
			$v = (int) $v;
		}

		if ($this->global_to_system !== $v || $v === 1) {
			$this->global_to_system = $v;
			$this->modifiedColumns[] = TblscormcppackagePeer::GLOBAL_TO_SYSTEM;
		}

		return $this;
	} 
	
	public function setSharedDataGlobalToSystem($v)
	{
		if ($v !== null) {
			$v = (int) $v;
		}

		if ($this->shared_data_global_to_system !== $v || $v === 1) {
			$this->shared_data_global_to_system = $v;
			$this->modifiedColumns[] = TblscormcppackagePeer::SHARED_DATA_GLOBAL_TO_SYSTEM;
		}

		return $this;
	} 
	
	public function hasOnlyDefaultValues()
	{
						if (array_diff($this->modifiedColumns, array(TblscormcppackagePeer::GLOBAL_TO_SYSTEM,TblscormcppackagePeer::SHARED_DATA_GLOBAL_TO_SYSTEM))) {
				return false;
			}

			if ($this->global_to_system !== 1) {
				return false;
			}

			if ($this->shared_data_global_to_system !== 1) {
				return false;
			}

				return true;
	} 
	
	public function hydrate($row, $startcol = 0, $rehydrate = false)
	{
		try {

			$this->created = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null;
			$this->c_identifier = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
			$this->jsdata = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
			$this->modified = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
			$this->obj_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
			$this->persistprevattempts = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
			$this->c_settings = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
			$this->xmldata = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
			$this->activitytree = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
			$this->global_to_system = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
			$this->shared_data_global_to_system = ($row[$startcol + 10] !== null) ? (int) $row[$startcol + 10] : null;
			$this->resetModified();

			$this->setNew(false);

			if ($rehydrate) {
				$this->ensureConsistency();
			}

						return $startcol + 11; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Tblscormcppackage 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(TblscormcppackagePeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

				
		$stmt = TblscormcppackagePeer::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) {  
		} 	}

	
	public function delete(PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(TblscormcppackagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			TblscormcppackagePeer::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(TblscormcppackagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			$affectedRows = $this->doSave($con);
			$con->commit();
			TblscormcppackagePeer::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->isModified()) {
				if ($this->isNew()) {
					$pk = TblscormcppackagePeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setNew(false);
				} else {
					$affectedRows += TblscormcppackagePeer::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 = TblscormcppackagePeer::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 = TblscormcppackagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		$field = $this->getByPosition($pos);
		return $field;
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getCreated();
				break;
			case 1:
				return $this->getCIdentifier();
				break;
			case 2:
				return $this->getJsdata();
				break;
			case 3:
				return $this->getModified();
				break;
			case 4:
				return $this->getObjId();
				break;
			case 5:
				return $this->getPersistprevattempts();
				break;
			case 6:
				return $this->getCSettings();
				break;
			case 7:
				return $this->getXmldata();
				break;
			case 8:
				return $this->getActivitytree();
				break;
			case 9:
				return $this->getGlobalToSystem();
				break;
			case 10:
				return $this->getSharedDataGlobalToSystem();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
	{
		$keys = TblscormcppackagePeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getCreated(),
			$keys[1] => $this->getCIdentifier(),
			$keys[2] => $this->getJsdata(),
			$keys[3] => $this->getModified(),
			$keys[4] => $this->getObjId(),
			$keys[5] => $this->getPersistprevattempts(),
			$keys[6] => $this->getCSettings(),
			$keys[7] => $this->getXmldata(),
			$keys[8] => $this->getActivitytree(),
			$keys[9] => $this->getGlobalToSystem(),
			$keys[10] => $this->getSharedDataGlobalToSystem(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = TblscormcppackagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setCreated($value);
				break;
			case 1:
				$this->setCIdentifier($value);
				break;
			case 2:
				$this->setJsdata($value);
				break;
			case 3:
				$this->setModified($value);
				break;
			case 4:
				$this->setObjId($value);
				break;
			case 5:
				$this->setPersistprevattempts($value);
				break;
			case 6:
				$this->setCSettings($value);
				break;
			case 7:
				$this->setXmldata($value);
				break;
			case 8:
				$this->setActivitytree($value);
				break;
			case 9:
				$this->setGlobalToSystem($value);
				break;
			case 10:
				$this->setSharedDataGlobalToSystem($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = TblscormcppackagePeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setCreated($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setCIdentifier($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setJsdata($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setModified($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setObjId($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setPersistprevattempts($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setCSettings($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setXmldata($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setActivitytree($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setGlobalToSystem($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setSharedDataGlobalToSystem($arr[$keys[10]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(TblscormcppackagePeer::DATABASE_NAME);

		if ($this->isColumnModified(TblscormcppackagePeer::CREATED)) $criteria->add(TblscormcppackagePeer::CREATED, $this->created);
		if ($this->isColumnModified(TblscormcppackagePeer::C_IDENTIFIER)) $criteria->add(TblscormcppackagePeer::C_IDENTIFIER, $this->c_identifier);
		if ($this->isColumnModified(TblscormcppackagePeer::JSDATA)) $criteria->add(TblscormcppackagePeer::JSDATA, $this->jsdata);
		if ($this->isColumnModified(TblscormcppackagePeer::MODIFIED)) $criteria->add(TblscormcppackagePeer::MODIFIED, $this->modified);
		if ($this->isColumnModified(TblscormcppackagePeer::OBJ_ID)) $criteria->add(TblscormcppackagePeer::OBJ_ID, $this->obj_id);
		if ($this->isColumnModified(TblscormcppackagePeer::PERSISTPREVATTEMPTS)) $criteria->add(TblscormcppackagePeer::PERSISTPREVATTEMPTS, $this->persistprevattempts);
		if ($this->isColumnModified(TblscormcppackagePeer::C_SETTINGS)) $criteria->add(TblscormcppackagePeer::C_SETTINGS, $this->c_settings);
		if ($this->isColumnModified(TblscormcppackagePeer::XMLDATA)) $criteria->add(TblscormcppackagePeer::XMLDATA, $this->xmldata);
		if ($this->isColumnModified(TblscormcppackagePeer::ACTIVITYTREE)) $criteria->add(TblscormcppackagePeer::ACTIVITYTREE, $this->activitytree);
		if ($this->isColumnModified(TblscormcppackagePeer::GLOBAL_TO_SYSTEM)) $criteria->add(TblscormcppackagePeer::GLOBAL_TO_SYSTEM, $this->global_to_system);
		if ($this->isColumnModified(TblscormcppackagePeer::SHARED_DATA_GLOBAL_TO_SYSTEM)) $criteria->add(TblscormcppackagePeer::SHARED_DATA_GLOBAL_TO_SYSTEM, $this->shared_data_global_to_system);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(TblscormcppackagePeer::DATABASE_NAME);

		$criteria->add(TblscormcppackagePeer::OBJ_ID, $this->obj_id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getObjId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setObjId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setCreated($this->created);

		$copyObj->setCIdentifier($this->c_identifier);

		$copyObj->setJsdata($this->jsdata);

		$copyObj->setModified($this->modified);

		$copyObj->setObjId($this->obj_id);

		$copyObj->setPersistprevattempts($this->persistprevattempts);

		$copyObj->setCSettings($this->c_settings);

		$copyObj->setXmldata($this->xmldata);

		$copyObj->setActivitytree($this->activitytree);

		$copyObj->setGlobalToSystem($this->global_to_system);

		$copyObj->setSharedDataGlobalToSystem($this->shared_data_global_to_system);


		$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 TblscormcppackagePeer();
		}
		return self::$peer;
	}

	
	public function clearAllReferences($deep = false)
	{
		if ($deep) {
		} 
	}

} 