<?php


abstract class BaseTblblog extends BaseObject  implements Persistent {


	
	protected static $peer;

	
	protected $bl_id;

	
	protected $bl_shortname;

	
	protected $bl_title;

	
	protected $bl_user;

	
	protected $bl_module_config;

	
	protected $bl_module_config_isLoaded = false;

	
	protected $bl_category;

	
	protected $bl_hit;

	
	protected $bl_type;

	
	protected $bl_active;

	
	protected $bl_lastupdate;

	
	protected $bl_school;

	
	protected $bl_pageviews;

	
	protected $bl_host;

	
	protected $bl_commexpire;

	
	protected $aTbluser;

	
	protected $collTblblogdependss;

	
	private $lastTblblogdependsCriteria = null;

	
	protected $collTblblogentrys;

	
	private $lastTblblogentryCriteria = null;

	
	protected $collTblblogentrycomments;

	
	private $lastTblblogentrycommentCriteria = null;

	
	protected $collTblblogpolls;

	
	private $lastTblblogpollCriteria = null;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

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

	
	public function applyDefaultValues()
	{
		$this->bl_hit = 0;
		$this->bl_type = 1;
		$this->bl_active = 1;
		$this->bl_pageviews = 0;
	}

	
	public function getBlId()
	{
		return $this->bl_id;
	}

	
	public function getBlShortname()
	{
		return $this->bl_shortname;
	}

	
	public function getBlTitle()
	{
		return $this->bl_title;
	}

	
	public function getBlUser()
	{
		return $this->bl_user;
	}

	
	public function getBlModuleConfig(PropelPDO $con = null)
	{
		if (!$this->bl_module_config_isLoaded && $this->bl_module_config === null && !$this->isNew()) {
			$this->loadBlModuleConfig($con);
		}

		return $this->bl_module_config;
	}

	
	protected function loadBlModuleConfig(PropelPDO $con = null)
	{
		$c = $this->buildPkeyCriteria();
		$c->addSelectColumn(TblblogPeer::BL_MODULE_CONFIG);
		try {
			$stmt = TblblogPeer::doSelectStmt($c, $con);
			$row = $stmt->fetch(PDO::FETCH_NUM);
			$stmt->closeCursor();
			$this->bl_module_config = ($row[0] !== null) ? (string) $row[0] : null;
			$this->bl_module_config_isLoaded = true;
		} catch (Exception $e) {
			throw new PropelException("Error loading value for [bl_module_config] column on demand.", $e);
		}
	}
	
	public function getBlCategory()
	{
		return $this->bl_category;
	}

	
	public function getBlHit()
	{
		return $this->bl_hit;
	}

	
	public function getBlType()
	{
		return $this->bl_type;
	}

	
	public function getBlActive()
	{
		return $this->bl_active;
	}

	
	public function getBlLastupdate($format = 'Y-m-d H:i:s')
	{
		if ($this->bl_lastupdate === null) {
			return null;
		}


		if ($this->bl_lastupdate === '0000-00-00 00:00:00') {
									return null;
		} else {
			try {
				$dt = new DateTime($this->bl_lastupdate);
			} catch (Exception $x) {
				throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->bl_lastupdate, true), $x);
			}
		}

		if ($format === null) {
						return $dt;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $dt->format('U'));
		} else {
			return $dt->format($format);
		}
	}

	
	public function getBlSchool()
	{
		return $this->bl_school;
	}

	
	public function getBlPageviews()
	{
		return $this->bl_pageviews;
	}

	
	public function getBlHost()
	{
		return $this->bl_host;
	}

	
	public function getBlCommexpire($format = 'Y-m-d H:i:s')
	{
		if ($this->bl_commexpire === null) {
			return null;
		}


		if ($this->bl_commexpire === '0000-00-00 00:00:00') {
									return null;
		} else {
			try {
				$dt = new DateTime($this->bl_commexpire);
			} catch (Exception $x) {
				throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->bl_commexpire, true), $x);
			}
		}

		if ($format === null) {
						return $dt;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $dt->format('U'));
		} else {
			return $dt->format($format);
		}
	}

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

		if ($this->bl_id !== $v) {
			$this->bl_id = $v;
			$this->modifiedColumns[] = TblblogPeer::BL_ID;
		}

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

		if ($this->bl_shortname !== $v) {
			$this->bl_shortname = $v;
			$this->modifiedColumns[] = TblblogPeer::BL_SHORTNAME;
		}

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

		if ($this->bl_title !== $v) {
			$this->bl_title = $v;
			$this->modifiedColumns[] = TblblogPeer::BL_TITLE;
		}

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

		if ($this->bl_user !== $v) {
			$this->bl_user = $v;
			$this->modifiedColumns[] = TblblogPeer::BL_USER;
		}

		if ($this->aTbluser !== null && $this->aTbluser->getUsId() !== $v) {
			$this->aTbluser = null;
		}

		return $this;
	} 
	
	public function setBlModuleConfig($v)
	{
										$this->bl_module_config_isLoaded = true;

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

		if ($this->bl_module_config !== $v) {
			$this->bl_module_config = $v;
			$this->modifiedColumns[] = TblblogPeer::BL_MODULE_CONFIG;
		}

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

		if ($this->bl_category !== $v) {
			$this->bl_category = $v;
			$this->modifiedColumns[] = TblblogPeer::BL_CATEGORY;
		}

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

		if ($this->bl_hit !== $v || $v === 0) {
			$this->bl_hit = $v;
			$this->modifiedColumns[] = TblblogPeer::BL_HIT;
		}

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

		if ($this->bl_type !== $v || $v === 1) {
			$this->bl_type = $v;
			$this->modifiedColumns[] = TblblogPeer::BL_TYPE;
		}

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

		if ($this->bl_active !== $v || $v === 1) {
			$this->bl_active = $v;
			$this->modifiedColumns[] = TblblogPeer::BL_ACTIVE;
		}

		return $this;
	} 
	
	public function setBlLastupdate($v)
	{
						if ($v === null || $v === '') {
			$dt = null;
		} elseif ($v instanceof DateTime) {
			$dt = $v;
		} else {
									try {
				if (is_numeric($v)) { 					$dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
															$dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
				} else {
					$dt = new DateTime($v);
				}
			} catch (Exception $x) {
				throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
			}
		}

		if ( $this->bl_lastupdate !== null || $dt !== null ) {
			
			$currNorm = ($this->bl_lastupdate !== null && $tmpDt = new DateTime($this->bl_lastupdate)) ? $tmpDt->format('Y-m-d H:i:s') : null;
			$newNorm = ($dt !== null) ? $dt->format('Y-m-d H:i:s') : null;

			if ( ($currNorm !== $newNorm) 					)
			{
				$this->bl_lastupdate = ($dt ? $dt->format('Y-m-d H:i:s') : null);
				$this->modifiedColumns[] = TblblogPeer::BL_LASTUPDATE;
			}
		} 
		return $this;
	} 
	
	public function setBlSchool($v)
	{
		if ($v !== null) {
			$v = (int) $v;
		}

		if ($this->bl_school !== $v) {
			$this->bl_school = $v;
			$this->modifiedColumns[] = TblblogPeer::BL_SCHOOL;
		}

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

		if ($this->bl_pageviews !== $v || $v === 0) {
			$this->bl_pageviews = $v;
			$this->modifiedColumns[] = TblblogPeer::BL_PAGEVIEWS;
		}

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

		if ($this->bl_host !== $v) {
			$this->bl_host = $v;
			$this->modifiedColumns[] = TblblogPeer::BL_HOST;
		}

		return $this;
	} 
	
	public function setBlCommexpire($v)
	{
						if ($v === null || $v === '') {
			$dt = null;
		} elseif ($v instanceof DateTime) {
			$dt = $v;
		} else {
									try {
				if (is_numeric($v)) { 					$dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
															$dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
				} else {
					$dt = new DateTime($v);
				}
			} catch (Exception $x) {
				throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
			}
		}

		if ( $this->bl_commexpire !== null || $dt !== null ) {
			
			$currNorm = ($this->bl_commexpire !== null && $tmpDt = new DateTime($this->bl_commexpire)) ? $tmpDt->format('Y-m-d H:i:s') : null;
			$newNorm = ($dt !== null) ? $dt->format('Y-m-d H:i:s') : null;

			if ( ($currNorm !== $newNorm) 					)
			{
				$this->bl_commexpire = ($dt ? $dt->format('Y-m-d H:i:s') : null);
				$this->modifiedColumns[] = TblblogPeer::BL_COMMEXPIRE;
			}
		} 
		return $this;
	} 
	
	public function hasOnlyDefaultValues()
	{
						if (array_diff($this->modifiedColumns, array(TblblogPeer::BL_HIT,TblblogPeer::BL_TYPE,TblblogPeer::BL_ACTIVE,TblblogPeer::BL_PAGEVIEWS))) {
				return false;
			}

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

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

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

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

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

			$this->bl_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
			$this->bl_shortname = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
			$this->bl_title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
			$this->bl_user = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
			$this->bl_category = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
			$this->bl_hit = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
			$this->bl_type = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
			$this->bl_active = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
			$this->bl_lastupdate = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
			$this->bl_school = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
			$this->bl_pageviews = ($row[$startcol + 10] !== null) ? (int) $row[$startcol + 10] : null;
			$this->bl_host = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null;
			$this->bl_commexpire = ($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 Tblblog object", $e);
		}
	}

	
	public function ensureConsistency()
	{

		if ($this->aTbluser !== null && $this->bl_user !== $this->aTbluser->getUsId()) {
			$this->aTbluser = null;
		}
	} 
	
	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(TblblogPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

				
		$stmt = TblblogPeer::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); 
				$this->bl_module_config = null;
		$this->bl_module_config_isLoaded = false;

		if ($deep) {  
			$this->aTbluser = null;
			$this->collTblblogdependss = null;
			$this->lastTblblogdependsCriteria = null;

			$this->collTblblogentrys = null;
			$this->lastTblblogentryCriteria = null;

			$this->collTblblogentrycomments = null;
			$this->lastTblblogentrycommentCriteria = null;

			$this->collTblblogpolls = null;
			$this->lastTblblogpollCriteria = null;

		} 	}

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

		if ($con === null) {
			$con = Propel::getConnection(TblblogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			TblblogPeer::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(TblblogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			$affectedRows = $this->doSave($con);
			$con->commit();
			TblblogPeer::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->aTbluser !== null) {
				if ($this->aTbluser->isModified() || $this->aTbluser->isNew()) {
					$affectedRows += $this->aTbluser->save($con);
				}
				$this->setTbluser($this->aTbluser);
			}

			if ($this->isNew() ) {
				$this->modifiedColumns[] = TblblogPeer::BL_ID;
			}

						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = TblblogPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setBlId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += TblblogPeer::doUpdate($this, $con);
				}

				$this->resetModified(); 			}

			if ($this->collTblblogdependss !== null) {
				foreach ($this->collTblblogdependss as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collTblblogentrys !== null) {
				foreach ($this->collTblblogentrys as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collTblblogentrycomments !== null) {
				foreach ($this->collTblblogentrycomments as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collTblblogpolls !== null) {
				foreach ($this->collTblblogpolls 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 ($this->aTbluser !== null) {
				if (!$this->aTbluser->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aTbluser->getValidationFailures());
				}
			}


			if (($retval = TblblogPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}


				if ($this->collTblblogdependss !== null) {
					foreach ($this->collTblblogdependss as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collTblblogentrys !== null) {
					foreach ($this->collTblblogentrys as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collTblblogentrycomments !== null) {
					foreach ($this->collTblblogentrycomments as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collTblblogpolls !== null) {
					foreach ($this->collTblblogpolls 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 = TblblogPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		$field = $this->getByPosition($pos);
		return $field;
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getBlId();
				break;
			case 1:
				return $this->getBlShortname();
				break;
			case 2:
				return $this->getBlTitle();
				break;
			case 3:
				return $this->getBlUser();
				break;
			case 4:
				return $this->getBlModuleConfig();
				break;
			case 5:
				return $this->getBlCategory();
				break;
			case 6:
				return $this->getBlHit();
				break;
			case 7:
				return $this->getBlType();
				break;
			case 8:
				return $this->getBlActive();
				break;
			case 9:
				return $this->getBlLastupdate();
				break;
			case 10:
				return $this->getBlSchool();
				break;
			case 11:
				return $this->getBlPageviews();
				break;
			case 12:
				return $this->getBlHost();
				break;
			case 13:
				return $this->getBlCommexpire();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
	{
		$keys = TblblogPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getBlId(),
			$keys[1] => $this->getBlShortname(),
			$keys[2] => $this->getBlTitle(),
			$keys[3] => $this->getBlUser(),
			$keys[4] => ($includeLazyLoadColumns) ? $this->getBlModuleConfig() : null,
			$keys[5] => $this->getBlCategory(),
			$keys[6] => $this->getBlHit(),
			$keys[7] => $this->getBlType(),
			$keys[8] => $this->getBlActive(),
			$keys[9] => $this->getBlLastupdate(),
			$keys[10] => $this->getBlSchool(),
			$keys[11] => $this->getBlPageviews(),
			$keys[12] => $this->getBlHost(),
			$keys[13] => $this->getBlCommexpire(),
		);
		return $result;
	}

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

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setBlId($value);
				break;
			case 1:
				$this->setBlShortname($value);
				break;
			case 2:
				$this->setBlTitle($value);
				break;
			case 3:
				$this->setBlUser($value);
				break;
			case 4:
				$this->setBlModuleConfig($value);
				break;
			case 5:
				$this->setBlCategory($value);
				break;
			case 6:
				$this->setBlHit($value);
				break;
			case 7:
				$this->setBlType($value);
				break;
			case 8:
				$this->setBlActive($value);
				break;
			case 9:
				$this->setBlLastupdate($value);
				break;
			case 10:
				$this->setBlSchool($value);
				break;
			case 11:
				$this->setBlPageviews($value);
				break;
			case 12:
				$this->setBlHost($value);
				break;
			case 13:
				$this->setBlCommexpire($value);
				break;
		} 	}

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

		if (array_key_exists($keys[0], $arr)) $this->setBlId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setBlShortname($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setBlTitle($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setBlUser($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setBlModuleConfig($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setBlCategory($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setBlHit($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setBlType($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setBlActive($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setBlLastupdate($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setBlSchool($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setBlPageviews($arr[$keys[11]]);
		if (array_key_exists($keys[12], $arr)) $this->setBlHost($arr[$keys[12]]);
		if (array_key_exists($keys[13], $arr)) $this->setBlCommexpire($arr[$keys[13]]);
	}

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

		if ($this->isColumnModified(TblblogPeer::BL_ID)) $criteria->add(TblblogPeer::BL_ID, $this->bl_id);
		if ($this->isColumnModified(TblblogPeer::BL_SHORTNAME)) $criteria->add(TblblogPeer::BL_SHORTNAME, $this->bl_shortname);
		if ($this->isColumnModified(TblblogPeer::BL_TITLE)) $criteria->add(TblblogPeer::BL_TITLE, $this->bl_title);
		if ($this->isColumnModified(TblblogPeer::BL_USER)) $criteria->add(TblblogPeer::BL_USER, $this->bl_user);
		if ($this->isColumnModified(TblblogPeer::BL_MODULE_CONFIG)) $criteria->add(TblblogPeer::BL_MODULE_CONFIG, $this->bl_module_config);
		if ($this->isColumnModified(TblblogPeer::BL_CATEGORY)) $criteria->add(TblblogPeer::BL_CATEGORY, $this->bl_category);
		if ($this->isColumnModified(TblblogPeer::BL_HIT)) $criteria->add(TblblogPeer::BL_HIT, $this->bl_hit);
		if ($this->isColumnModified(TblblogPeer::BL_TYPE)) $criteria->add(TblblogPeer::BL_TYPE, $this->bl_type);
		if ($this->isColumnModified(TblblogPeer::BL_ACTIVE)) $criteria->add(TblblogPeer::BL_ACTIVE, $this->bl_active);
		if ($this->isColumnModified(TblblogPeer::BL_LASTUPDATE)) $criteria->add(TblblogPeer::BL_LASTUPDATE, $this->bl_lastupdate);
		if ($this->isColumnModified(TblblogPeer::BL_SCHOOL)) $criteria->add(TblblogPeer::BL_SCHOOL, $this->bl_school);
		if ($this->isColumnModified(TblblogPeer::BL_PAGEVIEWS)) $criteria->add(TblblogPeer::BL_PAGEVIEWS, $this->bl_pageviews);
		if ($this->isColumnModified(TblblogPeer::BL_HOST)) $criteria->add(TblblogPeer::BL_HOST, $this->bl_host);
		if ($this->isColumnModified(TblblogPeer::BL_COMMEXPIRE)) $criteria->add(TblblogPeer::BL_COMMEXPIRE, $this->bl_commexpire);

		return $criteria;
	}

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

		$criteria->add(TblblogPeer::BL_ID, $this->bl_id);

		return $criteria;
	}

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

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

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

		$copyObj->setBlShortname($this->bl_shortname);

		$copyObj->setBlTitle($this->bl_title);

		$copyObj->setBlUser($this->bl_user);

		$copyObj->setBlModuleConfig($this->bl_module_config);

		$copyObj->setBlCategory($this->bl_category);

		$copyObj->setBlHit($this->bl_hit);

		$copyObj->setBlType($this->bl_type);

		$copyObj->setBlActive($this->bl_active);

		$copyObj->setBlLastupdate($this->bl_lastupdate);

		$copyObj->setBlSchool($this->bl_school);

		$copyObj->setBlPageviews($this->bl_pageviews);

		$copyObj->setBlHost($this->bl_host);

		$copyObj->setBlCommexpire($this->bl_commexpire);


		if ($deepCopy) {
									$copyObj->setNew(false);

			foreach ($this->getTblblogdependss() as $relObj) {
				if ($relObj !== $this) {  					$copyObj->addTblblogdepends($relObj->copy($deepCopy));
				}
			}

			foreach ($this->getTblblogentrys() as $relObj) {
				if ($relObj !== $this) {  					$copyObj->addTblblogentry($relObj->copy($deepCopy));
				}
			}

			foreach ($this->getTblblogentrycomments() as $relObj) {
				if ($relObj !== $this) {  					$copyObj->addTblblogentrycomment($relObj->copy($deepCopy));
				}
			}

			foreach ($this->getTblblogpolls() as $relObj) {
				if ($relObj !== $this) {  					$copyObj->addTblblogpoll($relObj->copy($deepCopy));
				}
			}

		} 

		$copyObj->setNew(true);

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

	
	public function setTbluser(Tbluser $v = null)
	{
		if ($v === null) {
			$this->setBlUser(NULL);
		} else {
			$this->setBlUser($v->getUsId());
		}

		$this->aTbluser = $v;

						if ($v !== null) {
			$v->addTblblog($this);
		}

		return $this;
	}


	
	public function getTbluser(PropelPDO $con = null)
	{
		if ($this->aTbluser === null && ($this->bl_user !== null)) {
			$this->aTbluser = TbluserPeer::retrieveByPK($this->bl_user, $con);
			
		}
		return $this->aTbluser;
	}

	
	public function clearTblblogdependss()
	{
		$this->collTblblogdependss = null; 	}

	
	public function initTblblogdependss()
	{
		$this->collTblblogdependss = array();
	}

	
	public function getTblblogdependss($criteria = null, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TblblogPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTblblogdependss === null) {
			if ($this->isNew()) {
			   $this->collTblblogdependss = array();
			} else {

				$criteria->add(TblblogdependsPeer::DP_BLOG, $this->bl_id);

				TblblogdependsPeer::addSelectColumns($criteria);
				$this->collTblblogdependss = TblblogdependsPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TblblogdependsPeer::DP_BLOG, $this->bl_id);

				TblblogdependsPeer::addSelectColumns($criteria);
				if (!isset($this->lastTblblogdependsCriteria) || !$this->lastTblblogdependsCriteria->equals($criteria)) {
					$this->collTblblogdependss = TblblogdependsPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastTblblogdependsCriteria = $criteria;
		return $this->collTblblogdependss;
	}

	
	public function countTblblogdependss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TblblogPeer::DATABASE_NAME);
		} else {
			$criteria = clone $criteria;
		}

		if ($distinct) {
			$criteria->setDistinct();
		}

		$count = null;

		if ($this->collTblblogdependss === null) {
			if ($this->isNew()) {
				$count = 0;
			} else {

				$criteria->add(TblblogdependsPeer::DP_BLOG, $this->bl_id);

				$count = TblblogdependsPeer::doCount($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TblblogdependsPeer::DP_BLOG, $this->bl_id);

				if (!isset($this->lastTblblogdependsCriteria) || !$this->lastTblblogdependsCriteria->equals($criteria)) {
					$count = TblblogdependsPeer::doCount($criteria, $con);
				} else {
					$count = count($this->collTblblogdependss);
				}
			} else {
				$count = count($this->collTblblogdependss);
			}
		}
		$this->lastTblblogdependsCriteria = $criteria;
		return $count;
	}

	
	public function addTblblogdepends(Tblblogdepends $l)
	{
		if ($this->collTblblogdependss === null) {
			$this->initTblblogdependss();
		}
		if (!in_array($l, $this->collTblblogdependss, true)) { 			array_push($this->collTblblogdependss, $l);
			$l->setTblblog($this);
		}
	}

	
	public function clearTblblogentrys()
	{
		$this->collTblblogentrys = null; 	}

	
	public function initTblblogentrys()
	{
		$this->collTblblogentrys = array();
	}

	
	public function getTblblogentrys($criteria = null, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TblblogPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTblblogentrys === null) {
			if ($this->isNew()) {
			   $this->collTblblogentrys = array();
			} else {

				$criteria->add(TblblogentryPeer::ENTRY_BLOG, $this->bl_id);

				TblblogentryPeer::addSelectColumns($criteria);
				$this->collTblblogentrys = TblblogentryPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TblblogentryPeer::ENTRY_BLOG, $this->bl_id);

				TblblogentryPeer::addSelectColumns($criteria);
				if (!isset($this->lastTblblogentryCriteria) || !$this->lastTblblogentryCriteria->equals($criteria)) {
					$this->collTblblogentrys = TblblogentryPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastTblblogentryCriteria = $criteria;
		return $this->collTblblogentrys;
	}

	
	public function countTblblogentrys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TblblogPeer::DATABASE_NAME);
		} else {
			$criteria = clone $criteria;
		}

		if ($distinct) {
			$criteria->setDistinct();
		}

		$count = null;

		if ($this->collTblblogentrys === null) {
			if ($this->isNew()) {
				$count = 0;
			} else {

				$criteria->add(TblblogentryPeer::ENTRY_BLOG, $this->bl_id);

				$count = TblblogentryPeer::doCount($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TblblogentryPeer::ENTRY_BLOG, $this->bl_id);

				if (!isset($this->lastTblblogentryCriteria) || !$this->lastTblblogentryCriteria->equals($criteria)) {
					$count = TblblogentryPeer::doCount($criteria, $con);
				} else {
					$count = count($this->collTblblogentrys);
				}
			} else {
				$count = count($this->collTblblogentrys);
			}
		}
		$this->lastTblblogentryCriteria = $criteria;
		return $count;
	}

	
	public function addTblblogentry(Tblblogentry $l)
	{
		if ($this->collTblblogentrys === null) {
			$this->initTblblogentrys();
		}
		if (!in_array($l, $this->collTblblogentrys, true)) { 			array_push($this->collTblblogentrys, $l);
			$l->setTblblog($this);
		}
	}


	
	public function getTblblogentrysJoinTblpresentation($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TblblogPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTblblogentrys === null) {
			if ($this->isNew()) {
				$this->collTblblogentrys = array();
			} else {

				$criteria->add(TblblogentryPeer::ENTRY_BLOG, $this->bl_id);

				$this->collTblblogentrys = TblblogentryPeer::doSelectJoinTblpresentation($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TblblogentryPeer::ENTRY_BLOG, $this->bl_id);

			if (!isset($this->lastTblblogentryCriteria) || !$this->lastTblblogentryCriteria->equals($criteria)) {
				$this->collTblblogentrys = TblblogentryPeer::doSelectJoinTblpresentation($criteria, $con, $join_behavior);
			}
		}
		$this->lastTblblogentryCriteria = $criteria;

		return $this->collTblblogentrys;
	}


	
	public function getTblblogentrysJoinTbldocument($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TblblogPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTblblogentrys === null) {
			if ($this->isNew()) {
				$this->collTblblogentrys = array();
			} else {

				$criteria->add(TblblogentryPeer::ENTRY_BLOG, $this->bl_id);

				$this->collTblblogentrys = TblblogentryPeer::doSelectJoinTbldocument($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TblblogentryPeer::ENTRY_BLOG, $this->bl_id);

			if (!isset($this->lastTblblogentryCriteria) || !$this->lastTblblogentryCriteria->equals($criteria)) {
				$this->collTblblogentrys = TblblogentryPeer::doSelectJoinTbldocument($criteria, $con, $join_behavior);
			}
		}
		$this->lastTblblogentryCriteria = $criteria;

		return $this->collTblblogentrys;
	}


	
	public function getTblblogentrysJoinTblblogcategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TblblogPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTblblogentrys === null) {
			if ($this->isNew()) {
				$this->collTblblogentrys = array();
			} else {

				$criteria->add(TblblogentryPeer::ENTRY_BLOG, $this->bl_id);

				$this->collTblblogentrys = TblblogentryPeer::doSelectJoinTblblogcategory($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TblblogentryPeer::ENTRY_BLOG, $this->bl_id);

			if (!isset($this->lastTblblogentryCriteria) || !$this->lastTblblogentryCriteria->equals($criteria)) {
				$this->collTblblogentrys = TblblogentryPeer::doSelectJoinTblblogcategory($criteria, $con, $join_behavior);
			}
		}
		$this->lastTblblogentryCriteria = $criteria;

		return $this->collTblblogentrys;
	}


	
	public function getTblblogentrysJoinTbluser($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TblblogPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTblblogentrys === null) {
			if ($this->isNew()) {
				$this->collTblblogentrys = array();
			} else {

				$criteria->add(TblblogentryPeer::ENTRY_BLOG, $this->bl_id);

				$this->collTblblogentrys = TblblogentryPeer::doSelectJoinTbluser($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TblblogentryPeer::ENTRY_BLOG, $this->bl_id);

			if (!isset($this->lastTblblogentryCriteria) || !$this->lastTblblogentryCriteria->equals($criteria)) {
				$this->collTblblogentrys = TblblogentryPeer::doSelectJoinTbluser($criteria, $con, $join_behavior);
			}
		}
		$this->lastTblblogentryCriteria = $criteria;

		return $this->collTblblogentrys;
	}

	
	public function clearTblblogentrycomments()
	{
		$this->collTblblogentrycomments = null; 	}

	
	public function initTblblogentrycomments()
	{
		$this->collTblblogentrycomments = array();
	}

	
	public function getTblblogentrycomments($criteria = null, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TblblogPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTblblogentrycomments === null) {
			if ($this->isNew()) {
			   $this->collTblblogentrycomments = array();
			} else {

				$criteria->add(TblblogentrycommentPeer::CM_BLOG, $this->bl_id);

				TblblogentrycommentPeer::addSelectColumns($criteria);
				$this->collTblblogentrycomments = TblblogentrycommentPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TblblogentrycommentPeer::CM_BLOG, $this->bl_id);

				TblblogentrycommentPeer::addSelectColumns($criteria);
				if (!isset($this->lastTblblogentrycommentCriteria) || !$this->lastTblblogentrycommentCriteria->equals($criteria)) {
					$this->collTblblogentrycomments = TblblogentrycommentPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastTblblogentrycommentCriteria = $criteria;
		return $this->collTblblogentrycomments;
	}

	
	public function countTblblogentrycomments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TblblogPeer::DATABASE_NAME);
		} else {
			$criteria = clone $criteria;
		}

		if ($distinct) {
			$criteria->setDistinct();
		}

		$count = null;

		if ($this->collTblblogentrycomments === null) {
			if ($this->isNew()) {
				$count = 0;
			} else {

				$criteria->add(TblblogentrycommentPeer::CM_BLOG, $this->bl_id);

				$count = TblblogentrycommentPeer::doCount($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TblblogentrycommentPeer::CM_BLOG, $this->bl_id);

				if (!isset($this->lastTblblogentrycommentCriteria) || !$this->lastTblblogentrycommentCriteria->equals($criteria)) {
					$count = TblblogentrycommentPeer::doCount($criteria, $con);
				} else {
					$count = count($this->collTblblogentrycomments);
				}
			} else {
				$count = count($this->collTblblogentrycomments);
			}
		}
		$this->lastTblblogentrycommentCriteria = $criteria;
		return $count;
	}

	
	public function addTblblogentrycomment(Tblblogentrycomment $l)
	{
		if ($this->collTblblogentrycomments === null) {
			$this->initTblblogentrycomments();
		}
		if (!in_array($l, $this->collTblblogentrycomments, true)) { 			array_push($this->collTblblogentrycomments, $l);
			$l->setTblblog($this);
		}
	}


	
	public function getTblblogentrycommentsJoinTbluser($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TblblogPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTblblogentrycomments === null) {
			if ($this->isNew()) {
				$this->collTblblogentrycomments = array();
			} else {

				$criteria->add(TblblogentrycommentPeer::CM_BLOG, $this->bl_id);

				$this->collTblblogentrycomments = TblblogentrycommentPeer::doSelectJoinTbluser($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TblblogentrycommentPeer::CM_BLOG, $this->bl_id);

			if (!isset($this->lastTblblogentrycommentCriteria) || !$this->lastTblblogentrycommentCriteria->equals($criteria)) {
				$this->collTblblogentrycomments = TblblogentrycommentPeer::doSelectJoinTbluser($criteria, $con, $join_behavior);
			}
		}
		$this->lastTblblogentrycommentCriteria = $criteria;

		return $this->collTblblogentrycomments;
	}


	
	public function getTblblogentrycommentsJoinTblblogentry($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TblblogPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTblblogentrycomments === null) {
			if ($this->isNew()) {
				$this->collTblblogentrycomments = array();
			} else {

				$criteria->add(TblblogentrycommentPeer::CM_BLOG, $this->bl_id);

				$this->collTblblogentrycomments = TblblogentrycommentPeer::doSelectJoinTblblogentry($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TblblogentrycommentPeer::CM_BLOG, $this->bl_id);

			if (!isset($this->lastTblblogentrycommentCriteria) || !$this->lastTblblogentrycommentCriteria->equals($criteria)) {
				$this->collTblblogentrycomments = TblblogentrycommentPeer::doSelectJoinTblblogentry($criteria, $con, $join_behavior);
			}
		}
		$this->lastTblblogentrycommentCriteria = $criteria;

		return $this->collTblblogentrycomments;
	}

	
	public function clearTblblogpolls()
	{
		$this->collTblblogpolls = null; 	}

	
	public function initTblblogpolls()
	{
		$this->collTblblogpolls = array();
	}

	
	public function getTblblogpolls($criteria = null, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TblblogPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTblblogpolls === null) {
			if ($this->isNew()) {
			   $this->collTblblogpolls = array();
			} else {

				$criteria->add(TblblogpollPeer::POLL_BLOG, $this->bl_id);

				TblblogpollPeer::addSelectColumns($criteria);
				$this->collTblblogpolls = TblblogpollPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TblblogpollPeer::POLL_BLOG, $this->bl_id);

				TblblogpollPeer::addSelectColumns($criteria);
				if (!isset($this->lastTblblogpollCriteria) || !$this->lastTblblogpollCriteria->equals($criteria)) {
					$this->collTblblogpolls = TblblogpollPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastTblblogpollCriteria = $criteria;
		return $this->collTblblogpolls;
	}

	
	public function countTblblogpolls(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TblblogPeer::DATABASE_NAME);
		} else {
			$criteria = clone $criteria;
		}

		if ($distinct) {
			$criteria->setDistinct();
		}

		$count = null;

		if ($this->collTblblogpolls === null) {
			if ($this->isNew()) {
				$count = 0;
			} else {

				$criteria->add(TblblogpollPeer::POLL_BLOG, $this->bl_id);

				$count = TblblogpollPeer::doCount($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TblblogpollPeer::POLL_BLOG, $this->bl_id);

				if (!isset($this->lastTblblogpollCriteria) || !$this->lastTblblogpollCriteria->equals($criteria)) {
					$count = TblblogpollPeer::doCount($criteria, $con);
				} else {
					$count = count($this->collTblblogpolls);
				}
			} else {
				$count = count($this->collTblblogpolls);
			}
		}
		$this->lastTblblogpollCriteria = $criteria;
		return $count;
	}

	
	public function addTblblogpoll(Tblblogpoll $l)
	{
		if ($this->collTblblogpolls === null) {
			$this->initTblblogpolls();
		}
		if (!in_array($l, $this->collTblblogpolls, true)) { 			array_push($this->collTblblogpolls, $l);
			$l->setTblblog($this);
		}
	}

	
	public function clearAllReferences($deep = false)
	{
		if ($deep) {
			if ($this->collTblblogdependss) {
				foreach ((array) $this->collTblblogdependss as $o) {
					$o->clearAllReferences($deep);
				}
			}
			if ($this->collTblblogentrys) {
				foreach ((array) $this->collTblblogentrys as $o) {
					$o->clearAllReferences($deep);
				}
			}
			if ($this->collTblblogentrycomments) {
				foreach ((array) $this->collTblblogentrycomments as $o) {
					$o->clearAllReferences($deep);
				}
			}
			if ($this->collTblblogpolls) {
				foreach ((array) $this->collTblblogpolls as $o) {
					$o->clearAllReferences($deep);
				}
			}
		} 
		$this->collTblblogdependss = null;
		$this->collTblblogentrys = null;
		$this->collTblblogentrycomments = null;
		$this->collTblblogpolls = null;
			$this->aTbluser = null;
	}

} 