<?php


abstract class BaseTblscormcmiinteraction extends BaseObject  implements Persistent {


	
	protected static $peer;

	
	protected $cmi_interaction_id;

	
	protected $cmi_node_id;

	
	protected $description;

	
	protected $id;

	
	protected $latency;

	
	protected $learner_response;

	
	protected $result;

	
	protected $c_timestamp;

	
	protected $c_type;

	
	protected $weighting;

	
	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 getDescription()
	{
		return $this->description;
	}

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

	
	public function getLatency()
	{
		return $this->latency;
	}

	
	public function getLearnerResponse()
	{
		return $this->learner_response;
	}

	
	public function getResult()
	{
		return $this->result;
	}

	
	public function getCTimestamp()
	{
		return $this->c_timestamp;
	}

	
	public function getCType()
	{
		return $this->c_type;
	}

	
	public function getWeighting()
	{
		return $this->weighting;
	}

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

		if ($this->cmi_interaction_id !== $v) {
			$this->cmi_interaction_id = $v;
			$this->modifiedColumns[] = TblscormcmiinteractionPeer::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[] = TblscormcmiinteractionPeer::CMI_NODE_ID;
		}

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

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

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

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

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

		if ($this->latency !== $v) {
			$this->latency = $v;
			$this->modifiedColumns[] = TblscormcmiinteractionPeer::LATENCY;
		}

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

		if ($this->learner_response !== $v) {
			$this->learner_response = $v;
			$this->modifiedColumns[] = TblscormcmiinteractionPeer::LEARNER_RESPONSE;
		}

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

		if ($this->result !== $v) {
			$this->result = $v;
			$this->modifiedColumns[] = TblscormcmiinteractionPeer::RESULT;
		}

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

		if ($this->c_timestamp !== $v) {
			$this->c_timestamp = $v;
			$this->modifiedColumns[] = TblscormcmiinteractionPeer::C_TIMESTAMP;
		}

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

		if ($this->c_type !== $v) {
			$this->c_type = $v;
			$this->modifiedColumns[] = TblscormcmiinteractionPeer::C_TYPE;
		}

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

		if ($this->weighting !== $v) {
			$this->weighting = $v;
			$this->modifiedColumns[] = TblscormcmiinteractionPeer::WEIGHTING;
		}

		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->description = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
			$this->id = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
			$this->latency = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
			$this->learner_response = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
			$this->result = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
			$this->c_timestamp = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
			$this->c_type = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
			$this->weighting = ($row[$startcol + 9] !== null) ? (double) $row[$startcol + 9] : null;
			$this->resetModified();

			$this->setNew(false);

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

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

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

						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = TblscormcmiinteractionPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setCmiInteractionId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += TblscormcmiinteractionPeer::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 = TblscormcmiinteractionPeer::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 = TblscormcmiinteractionPeer::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->getDescription();
				break;
			case 3:
				return $this->getId();
				break;
			case 4:
				return $this->getLatency();
				break;
			case 5:
				return $this->getLearnerResponse();
				break;
			case 6:
				return $this->getResult();
				break;
			case 7:
				return $this->getCTimestamp();
				break;
			case 8:
				return $this->getCType();
				break;
			case 9:
				return $this->getWeighting();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
	{
		$keys = TblscormcmiinteractionPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getCmiInteractionId(),
			$keys[1] => $this->getCmiNodeId(),
			$keys[2] => $this->getDescription(),
			$keys[3] => $this->getId(),
			$keys[4] => $this->getLatency(),
			$keys[5] => $this->getLearnerResponse(),
			$keys[6] => $this->getResult(),
			$keys[7] => $this->getCTimestamp(),
			$keys[8] => $this->getCType(),
			$keys[9] => $this->getWeighting(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = TblscormcmiinteractionPeer::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->setDescription($value);
				break;
			case 3:
				$this->setId($value);
				break;
			case 4:
				$this->setLatency($value);
				break;
			case 5:
				$this->setLearnerResponse($value);
				break;
			case 6:
				$this->setResult($value);
				break;
			case 7:
				$this->setCTimestamp($value);
				break;
			case 8:
				$this->setCType($value);
				break;
			case 9:
				$this->setWeighting($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = TblscormcmiinteractionPeer::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->setDescription($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setId($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setLatency($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setLearnerResponse($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setResult($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setCTimestamp($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setCType($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setWeighting($arr[$keys[9]]);
	}

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

		if ($this->isColumnModified(TblscormcmiinteractionPeer::CMI_INTERACTION_ID)) $criteria->add(TblscormcmiinteractionPeer::CMI_INTERACTION_ID, $this->cmi_interaction_id);
		if ($this->isColumnModified(TblscormcmiinteractionPeer::CMI_NODE_ID)) $criteria->add(TblscormcmiinteractionPeer::CMI_NODE_ID, $this->cmi_node_id);
		if ($this->isColumnModified(TblscormcmiinteractionPeer::DESCRIPTION)) $criteria->add(TblscormcmiinteractionPeer::DESCRIPTION, $this->description);
		if ($this->isColumnModified(TblscormcmiinteractionPeer::ID)) $criteria->add(TblscormcmiinteractionPeer::ID, $this->id);
		if ($this->isColumnModified(TblscormcmiinteractionPeer::LATENCY)) $criteria->add(TblscormcmiinteractionPeer::LATENCY, $this->latency);
		if ($this->isColumnModified(TblscormcmiinteractionPeer::LEARNER_RESPONSE)) $criteria->add(TblscormcmiinteractionPeer::LEARNER_RESPONSE, $this->learner_response);
		if ($this->isColumnModified(TblscormcmiinteractionPeer::RESULT)) $criteria->add(TblscormcmiinteractionPeer::RESULT, $this->result);
		if ($this->isColumnModified(TblscormcmiinteractionPeer::C_TIMESTAMP)) $criteria->add(TblscormcmiinteractionPeer::C_TIMESTAMP, $this->c_timestamp);
		if ($this->isColumnModified(TblscormcmiinteractionPeer::C_TYPE)) $criteria->add(TblscormcmiinteractionPeer::C_TYPE, $this->c_type);
		if ($this->isColumnModified(TblscormcmiinteractionPeer::WEIGHTING)) $criteria->add(TblscormcmiinteractionPeer::WEIGHTING, $this->weighting);

		return $criteria;
	}

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

		$criteria->add(TblscormcmiinteractionPeer::CMI_INTERACTION_ID, $this->cmi_interaction_id);

		return $criteria;
	}

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

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

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

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

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

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

		$copyObj->setLatency($this->latency);

		$copyObj->setLearnerResponse($this->learner_response);

		$copyObj->setResult($this->result);

		$copyObj->setCTimestamp($this->c_timestamp);

		$copyObj->setCType($this->c_type);

		$copyObj->setWeighting($this->weighting);


		$copyObj->setNew(true);

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

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

} 