<?php


abstract class BaseTbltestquestion extends BaseObject  implements Persistent {


	
	protected static $peer;

	
	protected $te_id;

	
	protected $te_question;

	
	protected $te_options;

	
	protected $te_result;

	
	protected $te_category;

	
	protected $te_level;

	
	protected $te_user;

	
	protected $te_blog;

	
	protected $te_status;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

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

	
	public function applyDefaultValues()
	{
		$this->te_status = 0;
	}

	
	public function getTeId()
	{
		return $this->te_id;
	}

	
	public function getTeQuestion()
	{
		return $this->te_question;
	}

	
	public function getTeOptions()
	{
		return $this->te_options;
	}

	
	public function getTeResult()
	{
		return $this->te_result;
	}

	
	public function getTeCategory()
	{
		return $this->te_category;
	}

	
	public function getTeLevel()
	{
		return $this->te_level;
	}

	
	public function getTeUser()
	{
		return $this->te_user;
	}

	
	public function getTeBlog()
	{
		return $this->te_blog;
	}

	
	public function getTeStatus()
	{
		return $this->te_status;
	}

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

		if ($this->te_id !== $v) {
			$this->te_id = $v;
			$this->modifiedColumns[] = TbltestquestionPeer::TE_ID;
		}

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

		if ($this->te_question !== $v) {
			$this->te_question = $v;
			$this->modifiedColumns[] = TbltestquestionPeer::TE_QUESTION;
		}

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

		if ($this->te_options !== $v) {
			$this->te_options = $v;
			$this->modifiedColumns[] = TbltestquestionPeer::TE_OPTIONS;
		}

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

		if ($this->te_result !== $v) {
			$this->te_result = $v;
			$this->modifiedColumns[] = TbltestquestionPeer::TE_RESULT;
		}

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

		if ($this->te_category !== $v) {
			$this->te_category = $v;
			$this->modifiedColumns[] = TbltestquestionPeer::TE_CATEGORY;
		}

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

		if ($this->te_level !== $v) {
			$this->te_level = $v;
			$this->modifiedColumns[] = TbltestquestionPeer::TE_LEVEL;
		}

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

		if ($this->te_user !== $v) {
			$this->te_user = $v;
			$this->modifiedColumns[] = TbltestquestionPeer::TE_USER;
		}

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

		if ($this->te_blog !== $v) {
			$this->te_blog = $v;
			$this->modifiedColumns[] = TbltestquestionPeer::TE_BLOG;
		}

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

		if ($this->te_status !== $v || $v === 0) {
			$this->te_status = $v;
			$this->modifiedColumns[] = TbltestquestionPeer::TE_STATUS;
		}

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

			if ($this->te_status !== 0) {
				return false;
			}

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

			$this->te_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
			$this->te_question = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
			$this->te_options = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
			$this->te_result = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
			$this->te_category = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
			$this->te_level = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
			$this->te_user = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
			$this->te_blog = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
			$this->te_status = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null;
			$this->resetModified();

			$this->setNew(false);

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

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

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

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

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getTeId();
				break;
			case 1:
				return $this->getTeQuestion();
				break;
			case 2:
				return $this->getTeOptions();
				break;
			case 3:
				return $this->getTeResult();
				break;
			case 4:
				return $this->getTeCategory();
				break;
			case 5:
				return $this->getTeLevel();
				break;
			case 6:
				return $this->getTeUser();
				break;
			case 7:
				return $this->getTeBlog();
				break;
			case 8:
				return $this->getTeStatus();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
	{
		$keys = TbltestquestionPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getTeId(),
			$keys[1] => $this->getTeQuestion(),
			$keys[2] => $this->getTeOptions(),
			$keys[3] => $this->getTeResult(),
			$keys[4] => $this->getTeCategory(),
			$keys[5] => $this->getTeLevel(),
			$keys[6] => $this->getTeUser(),
			$keys[7] => $this->getTeBlog(),
			$keys[8] => $this->getTeStatus(),
		);
		return $result;
	}

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

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setTeId($value);
				break;
			case 1:
				$this->setTeQuestion($value);
				break;
			case 2:
				$this->setTeOptions($value);
				break;
			case 3:
				$this->setTeResult($value);
				break;
			case 4:
				$this->setTeCategory($value);
				break;
			case 5:
				$this->setTeLevel($value);
				break;
			case 6:
				$this->setTeUser($value);
				break;
			case 7:
				$this->setTeBlog($value);
				break;
			case 8:
				$this->setTeStatus($value);
				break;
		} 	}

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

		if (array_key_exists($keys[0], $arr)) $this->setTeId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setTeQuestion($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setTeOptions($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setTeResult($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setTeCategory($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setTeLevel($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setTeUser($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setTeBlog($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setTeStatus($arr[$keys[8]]);
	}

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

		if ($this->isColumnModified(TbltestquestionPeer::TE_ID)) $criteria->add(TbltestquestionPeer::TE_ID, $this->te_id);
		if ($this->isColumnModified(TbltestquestionPeer::TE_QUESTION)) $criteria->add(TbltestquestionPeer::TE_QUESTION, $this->te_question);
		if ($this->isColumnModified(TbltestquestionPeer::TE_OPTIONS)) $criteria->add(TbltestquestionPeer::TE_OPTIONS, $this->te_options);
		if ($this->isColumnModified(TbltestquestionPeer::TE_RESULT)) $criteria->add(TbltestquestionPeer::TE_RESULT, $this->te_result);
		if ($this->isColumnModified(TbltestquestionPeer::TE_CATEGORY)) $criteria->add(TbltestquestionPeer::TE_CATEGORY, $this->te_category);
		if ($this->isColumnModified(TbltestquestionPeer::TE_LEVEL)) $criteria->add(TbltestquestionPeer::TE_LEVEL, $this->te_level);
		if ($this->isColumnModified(TbltestquestionPeer::TE_USER)) $criteria->add(TbltestquestionPeer::TE_USER, $this->te_user);
		if ($this->isColumnModified(TbltestquestionPeer::TE_BLOG)) $criteria->add(TbltestquestionPeer::TE_BLOG, $this->te_blog);
		if ($this->isColumnModified(TbltestquestionPeer::TE_STATUS)) $criteria->add(TbltestquestionPeer::TE_STATUS, $this->te_status);

		return $criteria;
	}

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

		$criteria->add(TbltestquestionPeer::TE_ID, $this->te_id);

		return $criteria;
	}

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

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

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

		$copyObj->setTeQuestion($this->te_question);

		$copyObj->setTeOptions($this->te_options);

		$copyObj->setTeResult($this->te_result);

		$copyObj->setTeCategory($this->te_category);

		$copyObj->setTeLevel($this->te_level);

		$copyObj->setTeUser($this->te_user);

		$copyObj->setTeBlog($this->te_blog);

		$copyObj->setTeStatus($this->te_status);


		$copyObj->setNew(true);

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

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

} 