<?php


abstract class BaseTblscormcmiobjective extends BaseObject  implements Persistent {


	
	protected static $peer;

	
	protected $cmi_interaction_id;

	
	protected $cmi_node_id;

	
	protected $cmi_objective_id;

	
	protected $completion_status;

	
	protected $description;

	
	protected $id;

	
	protected $c_max;

	
	protected $c_min;

	
	protected $c_raw;

	
	protected $scaled;

	
	protected $progress_measure;

	
	protected $success_status;

	
	protected $scope;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

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

	
	public function applyDefaultValues()
	{
	}

	
	public function getCmiInteractionId()
	{
		return $this->cmi_interaction_id;
	}

	
	public function getCmiNodeId()
	{
		return $this->cmi_node_id;
	}

	
	public function getCmiObjectiveId()
	{
		return $this->cmi_objective_id;
	}

	
	public function getCompletionStatus()
	{
		return $this->completion_status;
	}

	
	public function getDescription()
	{
		return $this->description;
	}

	
	public function getId()
	{
		return $this->id;
	}

	
	public function getCMax()
	{
		return $this->c_max;
	}

	
	public function getCMin()
	{
		return $this->c_min;
	}

	
	public function getCRaw()
	{
		return $this->c_raw;
	}

	
	public function getScaled()
	{
		return $this->scaled;
	}

	
	public function getProgressMeasure()
	{
		return $this->progress_measure;
	}

	
	public function getSuccessStatus()
	{
		return $this->success_status;
	}

	
	public function getScope()
	{
		return $this->scope;
	}

	
	public function setCmiInteractionId($v)
	{
		if ($v !== null) {
			$v = (int) $v;
		}

		if ($this->cmi_interaction_id !== $v) {
			$this->cmi_interaction_id = $v;
			$this->modifiedColumns[] = TblscormcmiobjectivePeer::CMI_INTERACTION_ID;
		}

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

		if ($this->cmi_node_id !== $v) {
			$this->cmi_node_id = $v;
			$this->modifiedColumns[] = TblscormcmiobjectivePeer::CMI_NODE_ID;
		}

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

		if ($this->cmi_objective_id !== $v) {
			$this->cmi_objective_id = $v;
			$this->modifiedColumns[] = TblscormcmiobjectivePeer::CMI_OBJECTIVE_ID;
		}

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

		if ($this->completion_status !== $v) {
			$this->completion_status = $v;
			$this->modifiedColumns[] = TblscormcmiobjectivePeer::COMPLETION_STATUS;
		}

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

		if ($this->description !== $v) {
			$this->description = $v;
			$this->modifiedColumns[] = TblscormcmiobjectivePeer::DESCRIPTION;
		}

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

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = TblscormcmiobjectivePeer::ID;
		}

		return $this;
	} 
	
	public function setCMax($v)
	{
		if ($v !== null) {
			$v = (double) $v;
		}

		if ($this->c_max !== $v) {
			$this->c_max = $v;
			$this->modifiedColumns[] = TblscormcmiobjectivePeer::C_MAX;
		}

		return $this;
	} 
	
	public function setCMin($v)
	{
		if ($v !== null) {
			$v = (double) $v;
		}

		if ($this->c_min !== $v) {
			$this->c_min = $v;
			$this->modifiedColumns[] = TblscormcmiobjectivePeer::C_MIN;
		}

		return $this;
	} 
	
	public function setCRaw($v)
	{
		if ($v !== null) {
			$v = (double) $v;
		}

		if ($this->c_raw !== $v) {
			$this->c_raw = $v;
			$this->modifiedColumns[] = TblscormcmiobjectivePeer::C_RAW;
		}

		return $this;
	} 
	
	public function setScaled($v)
	{
		if ($v !== null) {
			$v = (double) $v;
		}

		if ($this->scaled !== $v) {
			$this->scaled = $v;
			$this->modifiedColumns[] = TblscormcmiobjectivePeer::SCALED;
		}

		return $this;
	} 
	
	public function setProgressMeasure($v)
	{
		if ($v !== null) {
			$v = (double) $v;
		}

		if ($this->progress_measure !== $v) {
			$this->progress_measure = $v;
			$this->modifiedColumns[] = TblscormcmiobjectivePeer::PROGRESS_MEASURE;
		}

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

		if ($this->success_status !== $v) {
			$this->success_status = $v;
			$this->modifiedColumns[] = TblscormcmiobjectivePeer::SUCCESS_STATUS;
		}

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

		if ($this->scope !== $v) {
			$this->scope = $v;
			$this->modifiedColumns[] = TblscormcmiobjectivePeer::SCOPE;
		}

		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->cmi_interaction_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
			$this->cmi_node_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
			$this->cmi_objective_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
			$this->completion_status = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
			$this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
			$this->id = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
			$this->c_max = ($row[$startcol + 6] !== null) ? (double) $row[$startcol + 6] : null;
			$this->c_min = ($row[$startcol + 7] !== null) ? (double) $row[$startcol + 7] : null;
			$this->c_raw = ($row[$startcol + 8] !== null) ? (double) $row[$startcol + 8] : null;
			$this->scaled = ($row[$startcol + 9] !== null) ? (double) $row[$startcol + 9] : null;
			$this->progress_measure = ($row[$startcol + 10] !== null) ? (double) $row[$startcol + 10] : null;
			$this->success_status = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null;
			$this->scope = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null;
			$this->resetModified();

			$this->setNew(false);

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

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

				
		$stmt = TblscormcmiobjectivePeer::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(TblscormcmiobjectivePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			TblscormcmiobjectivePeer::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(TblscormcmiobjectivePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			$affectedRows = $this->doSave($con);
			$con->commit();
			TblscormcmiobjectivePeer::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[] = TblscormcmiobjectivePeer::CMI_OBJECTIVE_ID;
			}

						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = TblscormcmiobjectivePeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setCmiObjectiveId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += TblscormcmiobjectivePeer::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 = TblscormcmiobjectivePeer::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 = TblscormcmiobjectivePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		$field = $this->getByPosition($pos);
		return $field;
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getCmiInteractionId();
				break;
			case 1:
				return $this->getCmiNodeId();
				break;
			case 2:
				return $this->getCmiObjectiveId();
				break;
			case 3:
				return $this->getCompletionStatus();
				break;
			case 4:
				return $this->getDescription();
				break;
			case 5:
				return $this->getId();
				break;
			case 6:
				return $this->getCMax();
				break;
			case 7:
				return $this->getCMin();
				break;
			case 8:
				return $this->getCRaw();
				break;
			case 9:
				return $this->getScaled();
				break;
			case 10:
				return $this->getProgressMeasure();
				break;
			case 11:
				return $this->getSuccessStatus();
				break;
			case 12:
				return $this->getScope();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
	{
		$keys = TblscormcmiobjectivePeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getCmiInteractionId(),
			$keys[1] => $this->getCmiNodeId(),
			$keys[2] => $this->getCmiObjectiveId(),
			$keys[3] => $this->getCompletionStatus(),
			$keys[4] => $this->getDescription(),
			$keys[5] => $this->getId(),
			$keys[6] => $this->getCMax(),
			$keys[7] => $this->getCMin(),
			$keys[8] => $this->getCRaw(),
			$keys[9] => $this->getScaled(),
			$keys[10] => $this->getProgressMeasure(),
			$keys[11] => $this->getSuccessStatus(),
			$keys[12] => $this->getScope(),
		);
		return $result;
	}

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

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setCmiInteractionId($value);
				break;
			case 1:
				$this->setCmiNodeId($value);
				break;
			case 2:
				$this->setCmiObjectiveId($value);
				break;
			case 3:
				$this->setCompletionStatus($value);
				break;
			case 4:
				$this->setDescription($value);
				break;
			case 5:
				$this->setId($value);
				break;
			case 6:
				$this->setCMax($value);
				break;
			case 7:
				$this->setCMin($value);
				break;
			case 8:
				$this->setCRaw($value);
				break;
			case 9:
				$this->setScaled($value);
				break;
			case 10:
				$this->setProgressMeasure($value);
				break;
			case 11:
				$this->setSuccessStatus($value);
				break;
			case 12:
				$this->setScope($value);
				break;
		} 	}

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

		if (array_key_exists($keys[0], $arr)) $this->setCmiInteractionId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setCmiNodeId($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setCmiObjectiveId($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setCompletionStatus($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setId($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setCMax($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setCMin($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setCRaw($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setScaled($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setProgressMeasure($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setSuccessStatus($arr[$keys[11]]);
		if (array_key_exists($keys[12], $arr)) $this->setScope($arr[$keys[12]]);
	}

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

		if ($this->isColumnModified(TblscormcmiobjectivePeer::CMI_INTERACTION_ID)) $criteria->add(TblscormcmiobjectivePeer::CMI_INTERACTION_ID, $this->cmi_interaction_id);
		if ($this->isColumnModified(TblscormcmiobjectivePeer::CMI_NODE_ID)) $criteria->add(TblscormcmiobjectivePeer::CMI_NODE_ID, $this->cmi_node_id);
		if ($this->isColumnModified(TblscormcmiobjectivePeer::CMI_OBJECTIVE_ID)) $criteria->add(TblscormcmiobjectivePeer::CMI_OBJECTIVE_ID, $this->cmi_objective_id);
		if ($this->isColumnModified(TblscormcmiobjectivePeer::COMPLETION_STATUS)) $criteria->add(TblscormcmiobjectivePeer::COMPLETION_STATUS, $this->completion_status);
		if ($this->isColumnModified(TblscormcmiobjectivePeer::DESCRIPTION)) $criteria->add(TblscormcmiobjectivePeer::DESCRIPTION, $this->description);
		if ($this->isColumnModified(TblscormcmiobjectivePeer::ID)) $criteria->add(TblscormcmiobjectivePeer::ID, $this->id);
		if ($this->isColumnModified(TblscormcmiobjectivePeer::C_MAX)) $criteria->add(TblscormcmiobjectivePeer::C_MAX, $this->c_max);
		if ($this->isColumnModified(TblscormcmiobjectivePeer::C_MIN)) $criteria->add(TblscormcmiobjectivePeer::C_MIN, $this->c_min);
		if ($this->isColumnModified(TblscormcmiobjectivePeer::C_RAW)) $criteria->add(TblscormcmiobjectivePeer::C_RAW, $this->c_raw);
		if ($this->isColumnModified(TblscormcmiobjectivePeer::SCALED)) $criteria->add(TblscormcmiobjectivePeer::SCALED, $this->scaled);
		if ($this->isColumnModified(TblscormcmiobjectivePeer::PROGRESS_MEASURE)) $criteria->add(TblscormcmiobjectivePeer::PROGRESS_MEASURE, $this->progress_measure);
		if ($this->isColumnModified(TblscormcmiobjectivePeer::SUCCESS_STATUS)) $criteria->add(TblscormcmiobjectivePeer::SUCCESS_STATUS, $this->success_status);
		if ($this->isColumnModified(TblscormcmiobjectivePeer::SCOPE)) $criteria->add(TblscormcmiobjectivePeer::SCOPE, $this->scope);

		return $criteria;
	}

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

		$criteria->add(TblscormcmiobjectivePeer::CMI_OBJECTIVE_ID, $this->cmi_objective_id);

		return $criteria;
	}

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

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

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

		$copyObj->setCmiInteractionId($this->cmi_interaction_id);

		$copyObj->setCmiNodeId($this->cmi_node_id);

		$copyObj->setCompletionStatus($this->completion_status);

		$copyObj->setDescription($this->description);

		$copyObj->setId($this->id);

		$copyObj->setCMax($this->c_max);

		$copyObj->setCMin($this->c_min);

		$copyObj->setCRaw($this->c_raw);

		$copyObj->setScaled($this->scaled);

		$copyObj->setProgressMeasure($this->progress_measure);

		$copyObj->setSuccessStatus($this->success_status);

		$copyObj->setScope($this->scope);


		$copyObj->setNew(true);

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

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

} 