<?php


abstract class BaseTbldocument extends BaseObject  implements Persistent {


	
	protected static $peer;

	
	protected $doc_id;

	
	protected $doc_category;

	
	protected $doc_name;

	
	protected $doc_desc;

	
	protected $doc_desc_isLoaded = false;

	
	protected $doc_source;

	
	protected $doc_keyword;

	
	protected $doc_type;

	
	protected $doc_filename;

	
	protected $doc_user;

	
	protected $doc_date;

	
	protected $doc_hit;

	
	protected $doc_rating;

	
	protected $doc_status;

	
	protected $doc_width;

	
	protected $doc_height;

	
	protected $doc_view;

	
	protected $doc_manager;

	
	protected $doc_report;

	
	protected $doc_filesize;

	
	protected $doc_thumbnail;

	
	protected $aTbluser;

	
	protected $collTblblogcategoryentrys;

	
	private $lastTblblogcategoryentryCriteria = null;

	
	protected $collTblblogentrys;

	
	private $lastTblblogentryCriteria = null;

	
	protected $collTbluserdocuments;

	
	private $lastTbluserdocumentCriteria = null;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

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

	
	public function applyDefaultValues()
	{
		$this->doc_hit = 0;
		$this->doc_rating = 0;
		$this->doc_status = 0;
		$this->doc_width = 0;
		$this->doc_height = 0;
		$this->doc_view = 0;
		$this->doc_manager = 0;
		$this->doc_report = 0;
		$this->doc_thumbnail = 0;
	}

	
	public function getDocId()
	{
		return $this->doc_id;
	}

	
	public function getDocCategory()
	{
		return $this->doc_category;
	}

	
	public function getDocName()
	{
		return $this->doc_name;
	}

	
	public function getDocDesc(PropelPDO $con = null)
	{
		if (!$this->doc_desc_isLoaded && $this->doc_desc === null && !$this->isNew()) {
			$this->loadDocDesc($con);
		}

		return $this->doc_desc;
	}

	
	protected function loadDocDesc(PropelPDO $con = null)
	{
		$c = $this->buildPkeyCriteria();
		$c->addSelectColumn(TbldocumentPeer::DOC_DESC);
		try {
			$stmt = TbldocumentPeer::doSelectStmt($c, $con);
			$row = $stmt->fetch(PDO::FETCH_NUM);
			$stmt->closeCursor();
			$this->doc_desc = ($row[0] !== null) ? (string) $row[0] : null;
			$this->doc_desc_isLoaded = true;
		} catch (Exception $e) {
			throw new PropelException("Error loading value for [doc_desc] column on demand.", $e);
		}
	}
	
	public function getDocSource()
	{
		return $this->doc_source;
	}

	
	public function getDocKeyword()
	{
		return $this->doc_keyword;
	}

	
	public function getDocType()
	{
		return $this->doc_type;
	}

	
	public function getDocFilename()
	{
		return $this->doc_filename;
	}

	
	public function getDocUser()
	{
		return $this->doc_user;
	}

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


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

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

	
	public function getDocHit()
	{
		return $this->doc_hit;
	}

	
	public function getDocRating()
	{
		return $this->doc_rating;
	}

	
	public function getDocStatus()
	{
		return $this->doc_status;
	}

	
	public function getDocWidth()
	{
		return $this->doc_width;
	}

	
	public function getDocHeight()
	{
		return $this->doc_height;
	}

	
	public function getDocView()
	{
		return $this->doc_view;
	}

	
	public function getDocManager()
	{
		return $this->doc_manager;
	}

	
	public function getDocReport()
	{
		return $this->doc_report;
	}

	
	public function getDocFilesize()
	{
		return $this->doc_filesize;
	}

	
	public function getDocThumbnail()
	{
		return $this->doc_thumbnail;
	}

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

		if ($this->doc_id !== $v) {
			$this->doc_id = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_ID;
		}

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

		if ($this->doc_category !== $v) {
			$this->doc_category = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_CATEGORY;
		}

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

		if ($this->doc_name !== $v) {
			$this->doc_name = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_NAME;
		}

		return $this;
	} 
	
	public function setDocDesc($v)
	{
										$this->doc_desc_isLoaded = true;

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

		if ($this->doc_desc !== $v) {
			$this->doc_desc = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_DESC;
		}

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

		if ($this->doc_source !== $v) {
			$this->doc_source = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_SOURCE;
		}

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

		if ($this->doc_keyword !== $v) {
			$this->doc_keyword = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_KEYWORD;
		}

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

		if ($this->doc_type !== $v) {
			$this->doc_type = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_TYPE;
		}

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

		if ($this->doc_filename !== $v) {
			$this->doc_filename = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_FILENAME;
		}

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

		if ($this->doc_user !== $v) {
			$this->doc_user = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_USER;
		}

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

		return $this;
	} 
	
	public function setDocDate($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->doc_date !== null || $dt !== null ) {
			
			$currNorm = ($this->doc_date !== null && $tmpDt = new DateTime($this->doc_date)) ? $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->doc_date = ($dt ? $dt->format('Y-m-d H:i:s') : null);
				$this->modifiedColumns[] = TbldocumentPeer::DOC_DATE;
			}
		} 
		return $this;
	} 
	
	public function setDocHit($v)
	{
		if ($v !== null) {
			$v = (int) $v;
		}

		if ($this->doc_hit !== $v || $v === 0) {
			$this->doc_hit = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_HIT;
		}

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

		if ($this->doc_rating !== $v || $v === 0) {
			$this->doc_rating = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_RATING;
		}

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

		if ($this->doc_status !== $v || $v === 0) {
			$this->doc_status = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_STATUS;
		}

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

		if ($this->doc_width !== $v || $v === 0) {
			$this->doc_width = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_WIDTH;
		}

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

		if ($this->doc_height !== $v || $v === 0) {
			$this->doc_height = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_HEIGHT;
		}

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

		if ($this->doc_view !== $v || $v === 0) {
			$this->doc_view = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_VIEW;
		}

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

		if ($this->doc_manager !== $v || $v === 0) {
			$this->doc_manager = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_MANAGER;
		}

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

		if ($this->doc_report !== $v || $v === 0) {
			$this->doc_report = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_REPORT;
		}

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

		if ($this->doc_filesize !== $v) {
			$this->doc_filesize = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_FILESIZE;
		}

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

		if ($this->doc_thumbnail !== $v || $v === 0) {
			$this->doc_thumbnail = $v;
			$this->modifiedColumns[] = TbldocumentPeer::DOC_THUMBNAIL;
		}

		return $this;
	} 
	
	public function hasOnlyDefaultValues()
	{
						if (array_diff($this->modifiedColumns, array(TbldocumentPeer::DOC_HIT,TbldocumentPeer::DOC_RATING,TbldocumentPeer::DOC_STATUS,TbldocumentPeer::DOC_WIDTH,TbldocumentPeer::DOC_HEIGHT,TbldocumentPeer::DOC_VIEW,TbldocumentPeer::DOC_MANAGER,TbldocumentPeer::DOC_REPORT,TbldocumentPeer::DOC_THUMBNAIL))) {
				return false;
			}

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

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

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

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

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

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

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

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

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

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

			$this->doc_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
			$this->doc_category = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
			$this->doc_name = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
			$this->doc_source = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
			$this->doc_keyword = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
			$this->doc_type = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
			$this->doc_filename = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
			$this->doc_user = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
			$this->doc_date = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
			$this->doc_hit = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
			$this->doc_rating = ($row[$startcol + 10] !== null) ? (int) $row[$startcol + 10] : null;
			$this->doc_status = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null;
			$this->doc_width = ($row[$startcol + 12] !== null) ? (int) $row[$startcol + 12] : null;
			$this->doc_height = ($row[$startcol + 13] !== null) ? (int) $row[$startcol + 13] : null;
			$this->doc_view = ($row[$startcol + 14] !== null) ? (int) $row[$startcol + 14] : null;
			$this->doc_manager = ($row[$startcol + 15] !== null) ? (int) $row[$startcol + 15] : null;
			$this->doc_report = ($row[$startcol + 16] !== null) ? (int) $row[$startcol + 16] : null;
			$this->doc_filesize = ($row[$startcol + 17] !== null) ? (int) $row[$startcol + 17] : null;
			$this->doc_thumbnail = ($row[$startcol + 18] !== null) ? (int) $row[$startcol + 18] : null;
			$this->resetModified();

			$this->setNew(false);

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

						return $startcol + 19; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Tbldocument object", $e);
		}
	}

	
	public function ensureConsistency()
	{

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

				
		$stmt = TbldocumentPeer::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->doc_desc = null;
		$this->doc_desc_isLoaded = false;

		if ($deep) {  
			$this->aTbluser = null;
			$this->collTblblogcategoryentrys = null;
			$this->lastTblblogcategoryentryCriteria = null;

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

			$this->collTbluserdocuments = null;
			$this->lastTbluserdocumentCriteria = 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(TbldocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			TbldocumentPeer::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(TbldocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			$affectedRows = $this->doSave($con);
			$con->commit();
			TbldocumentPeer::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[] = TbldocumentPeer::DOC_ID;
			}

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

				$this->resetModified(); 			}

			if ($this->collTblblogcategoryentrys !== null) {
				foreach ($this->collTblblogcategoryentrys 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->collTbluserdocuments !== null) {
				foreach ($this->collTbluserdocuments 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 = TbldocumentPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}


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

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getDocId();
				break;
			case 1:
				return $this->getDocCategory();
				break;
			case 2:
				return $this->getDocName();
				break;
			case 3:
				return $this->getDocDesc();
				break;
			case 4:
				return $this->getDocSource();
				break;
			case 5:
				return $this->getDocKeyword();
				break;
			case 6:
				return $this->getDocType();
				break;
			case 7:
				return $this->getDocFilename();
				break;
			case 8:
				return $this->getDocUser();
				break;
			case 9:
				return $this->getDocDate();
				break;
			case 10:
				return $this->getDocHit();
				break;
			case 11:
				return $this->getDocRating();
				break;
			case 12:
				return $this->getDocStatus();
				break;
			case 13:
				return $this->getDocWidth();
				break;
			case 14:
				return $this->getDocHeight();
				break;
			case 15:
				return $this->getDocView();
				break;
			case 16:
				return $this->getDocManager();
				break;
			case 17:
				return $this->getDocReport();
				break;
			case 18:
				return $this->getDocFilesize();
				break;
			case 19:
				return $this->getDocThumbnail();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
	{
		$keys = TbldocumentPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getDocId(),
			$keys[1] => $this->getDocCategory(),
			$keys[2] => $this->getDocName(),
			$keys[3] => ($includeLazyLoadColumns) ? $this->getDocDesc() : null,
			$keys[4] => $this->getDocSource(),
			$keys[5] => $this->getDocKeyword(),
			$keys[6] => $this->getDocType(),
			$keys[7] => $this->getDocFilename(),
			$keys[8] => $this->getDocUser(),
			$keys[9] => $this->getDocDate(),
			$keys[10] => $this->getDocHit(),
			$keys[11] => $this->getDocRating(),
			$keys[12] => $this->getDocStatus(),
			$keys[13] => $this->getDocWidth(),
			$keys[14] => $this->getDocHeight(),
			$keys[15] => $this->getDocView(),
			$keys[16] => $this->getDocManager(),
			$keys[17] => $this->getDocReport(),
			$keys[18] => $this->getDocFilesize(),
			$keys[19] => $this->getDocThumbnail(),
		);
		return $result;
	}

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

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setDocId($value);
				break;
			case 1:
				$this->setDocCategory($value);
				break;
			case 2:
				$this->setDocName($value);
				break;
			case 3:
				$this->setDocDesc($value);
				break;
			case 4:
				$this->setDocSource($value);
				break;
			case 5:
				$this->setDocKeyword($value);
				break;
			case 6:
				$this->setDocType($value);
				break;
			case 7:
				$this->setDocFilename($value);
				break;
			case 8:
				$this->setDocUser($value);
				break;
			case 9:
				$this->setDocDate($value);
				break;
			case 10:
				$this->setDocHit($value);
				break;
			case 11:
				$this->setDocRating($value);
				break;
			case 12:
				$this->setDocStatus($value);
				break;
			case 13:
				$this->setDocWidth($value);
				break;
			case 14:
				$this->setDocHeight($value);
				break;
			case 15:
				$this->setDocView($value);
				break;
			case 16:
				$this->setDocManager($value);
				break;
			case 17:
				$this->setDocReport($value);
				break;
			case 18:
				$this->setDocFilesize($value);
				break;
			case 19:
				$this->setDocThumbnail($value);
				break;
		} 	}

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

		if (array_key_exists($keys[0], $arr)) $this->setDocId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setDocCategory($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setDocName($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setDocDesc($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setDocSource($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setDocKeyword($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setDocType($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setDocFilename($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setDocUser($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setDocDate($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setDocHit($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setDocRating($arr[$keys[11]]);
		if (array_key_exists($keys[12], $arr)) $this->setDocStatus($arr[$keys[12]]);
		if (array_key_exists($keys[13], $arr)) $this->setDocWidth($arr[$keys[13]]);
		if (array_key_exists($keys[14], $arr)) $this->setDocHeight($arr[$keys[14]]);
		if (array_key_exists($keys[15], $arr)) $this->setDocView($arr[$keys[15]]);
		if (array_key_exists($keys[16], $arr)) $this->setDocManager($arr[$keys[16]]);
		if (array_key_exists($keys[17], $arr)) $this->setDocReport($arr[$keys[17]]);
		if (array_key_exists($keys[18], $arr)) $this->setDocFilesize($arr[$keys[18]]);
		if (array_key_exists($keys[19], $arr)) $this->setDocThumbnail($arr[$keys[19]]);
	}

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

		if ($this->isColumnModified(TbldocumentPeer::DOC_ID)) $criteria->add(TbldocumentPeer::DOC_ID, $this->doc_id);
		if ($this->isColumnModified(TbldocumentPeer::DOC_CATEGORY)) $criteria->add(TbldocumentPeer::DOC_CATEGORY, $this->doc_category);
		if ($this->isColumnModified(TbldocumentPeer::DOC_NAME)) $criteria->add(TbldocumentPeer::DOC_NAME, $this->doc_name);
		if ($this->isColumnModified(TbldocumentPeer::DOC_DESC)) $criteria->add(TbldocumentPeer::DOC_DESC, $this->doc_desc);
		if ($this->isColumnModified(TbldocumentPeer::DOC_SOURCE)) $criteria->add(TbldocumentPeer::DOC_SOURCE, $this->doc_source);
		if ($this->isColumnModified(TbldocumentPeer::DOC_KEYWORD)) $criteria->add(TbldocumentPeer::DOC_KEYWORD, $this->doc_keyword);
		if ($this->isColumnModified(TbldocumentPeer::DOC_TYPE)) $criteria->add(TbldocumentPeer::DOC_TYPE, $this->doc_type);
		if ($this->isColumnModified(TbldocumentPeer::DOC_FILENAME)) $criteria->add(TbldocumentPeer::DOC_FILENAME, $this->doc_filename);
		if ($this->isColumnModified(TbldocumentPeer::DOC_USER)) $criteria->add(TbldocumentPeer::DOC_USER, $this->doc_user);
		if ($this->isColumnModified(TbldocumentPeer::DOC_DATE)) $criteria->add(TbldocumentPeer::DOC_DATE, $this->doc_date);
		if ($this->isColumnModified(TbldocumentPeer::DOC_HIT)) $criteria->add(TbldocumentPeer::DOC_HIT, $this->doc_hit);
		if ($this->isColumnModified(TbldocumentPeer::DOC_RATING)) $criteria->add(TbldocumentPeer::DOC_RATING, $this->doc_rating);
		if ($this->isColumnModified(TbldocumentPeer::DOC_STATUS)) $criteria->add(TbldocumentPeer::DOC_STATUS, $this->doc_status);
		if ($this->isColumnModified(TbldocumentPeer::DOC_WIDTH)) $criteria->add(TbldocumentPeer::DOC_WIDTH, $this->doc_width);
		if ($this->isColumnModified(TbldocumentPeer::DOC_HEIGHT)) $criteria->add(TbldocumentPeer::DOC_HEIGHT, $this->doc_height);
		if ($this->isColumnModified(TbldocumentPeer::DOC_VIEW)) $criteria->add(TbldocumentPeer::DOC_VIEW, $this->doc_view);
		if ($this->isColumnModified(TbldocumentPeer::DOC_MANAGER)) $criteria->add(TbldocumentPeer::DOC_MANAGER, $this->doc_manager);
		if ($this->isColumnModified(TbldocumentPeer::DOC_REPORT)) $criteria->add(TbldocumentPeer::DOC_REPORT, $this->doc_report);
		if ($this->isColumnModified(TbldocumentPeer::DOC_FILESIZE)) $criteria->add(TbldocumentPeer::DOC_FILESIZE, $this->doc_filesize);
		if ($this->isColumnModified(TbldocumentPeer::DOC_THUMBNAIL)) $criteria->add(TbldocumentPeer::DOC_THUMBNAIL, $this->doc_thumbnail);

		return $criteria;
	}

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

		$criteria->add(TbldocumentPeer::DOC_ID, $this->doc_id);

		return $criteria;
	}

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

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

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

		$copyObj->setDocCategory($this->doc_category);

		$copyObj->setDocName($this->doc_name);

		$copyObj->setDocDesc($this->doc_desc);

		$copyObj->setDocSource($this->doc_source);

		$copyObj->setDocKeyword($this->doc_keyword);

		$copyObj->setDocType($this->doc_type);

		$copyObj->setDocFilename($this->doc_filename);

		$copyObj->setDocUser($this->doc_user);

		$copyObj->setDocDate($this->doc_date);

		$copyObj->setDocHit($this->doc_hit);

		$copyObj->setDocRating($this->doc_rating);

		$copyObj->setDocStatus($this->doc_status);

		$copyObj->setDocWidth($this->doc_width);

		$copyObj->setDocHeight($this->doc_height);

		$copyObj->setDocView($this->doc_view);

		$copyObj->setDocManager($this->doc_manager);

		$copyObj->setDocReport($this->doc_report);

		$copyObj->setDocFilesize($this->doc_filesize);

		$copyObj->setDocThumbnail($this->doc_thumbnail);


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

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

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

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

		} 

		$copyObj->setNew(true);

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

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

		$this->aTbluser = $v;

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

		return $this;
	}


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

	
	public function clearTblblogcategoryentrys()
	{
		$this->collTblblogcategoryentrys = null; 	}

	
	public function initTblblogcategoryentrys()
	{
		$this->collTblblogcategoryentrys = array();
	}

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

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

				$criteria->add(TblblogcategoryentryPeer::CE_LINK, $this->doc_id);

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

				$criteria->add(TblblogcategoryentryPeer::CE_LINK, $this->doc_id);

				TblblogcategoryentryPeer::addSelectColumns($criteria);
				if (!isset($this->lastTblblogcategoryentryCriteria) || !$this->lastTblblogcategoryentryCriteria->equals($criteria)) {
					$this->collTblblogcategoryentrys = TblblogcategoryentryPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastTblblogcategoryentryCriteria = $criteria;
		return $this->collTblblogcategoryentrys;
	}

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

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

		$count = null;

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

				$criteria->add(TblblogcategoryentryPeer::CE_LINK, $this->doc_id);

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

				$criteria->add(TblblogcategoryentryPeer::CE_LINK, $this->doc_id);

				if (!isset($this->lastTblblogcategoryentryCriteria) || !$this->lastTblblogcategoryentryCriteria->equals($criteria)) {
					$count = TblblogcategoryentryPeer::doCount($criteria, $con);
				} else {
					$count = count($this->collTblblogcategoryentrys);
				}
			} else {
				$count = count($this->collTblblogcategoryentrys);
			}
		}
		$this->lastTblblogcategoryentryCriteria = $criteria;
		return $count;
	}

	
	public function addTblblogcategoryentry(Tblblogcategoryentry $l)
	{
		if ($this->collTblblogcategoryentrys === null) {
			$this->initTblblogcategoryentrys();
		}
		if (!in_array($l, $this->collTblblogcategoryentrys, true)) { 			array_push($this->collTblblogcategoryentrys, $l);
			$l->setTbldocument($this);
		}
	}


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

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

				$criteria->add(TblblogcategoryentryPeer::CE_LINK, $this->doc_id);

				$this->collTblblogcategoryentrys = TblblogcategoryentryPeer::doSelectJoinTblblogentry($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TblblogcategoryentryPeer::CE_LINK, $this->doc_id);

			if (!isset($this->lastTblblogcategoryentryCriteria) || !$this->lastTblblogcategoryentryCriteria->equals($criteria)) {
				$this->collTblblogcategoryentrys = TblblogcategoryentryPeer::doSelectJoinTblblogentry($criteria, $con, $join_behavior);
			}
		}
		$this->lastTblblogcategoryentryCriteria = $criteria;

		return $this->collTblblogcategoryentrys;
	}


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

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

				$criteria->add(TblblogcategoryentryPeer::CE_LINK, $this->doc_id);

				$this->collTblblogcategoryentrys = TblblogcategoryentryPeer::doSelectJoinTbluser($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TblblogcategoryentryPeer::CE_LINK, $this->doc_id);

			if (!isset($this->lastTblblogcategoryentryCriteria) || !$this->lastTblblogcategoryentryCriteria->equals($criteria)) {
				$this->collTblblogcategoryentrys = TblblogcategoryentryPeer::doSelectJoinTbluser($criteria, $con, $join_behavior);
			}
		}
		$this->lastTblblogcategoryentryCriteria = $criteria;

		return $this->collTblblogcategoryentrys;
	}


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

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

				$criteria->add(TblblogcategoryentryPeer::CE_LINK, $this->doc_id);

				$this->collTblblogcategoryentrys = TblblogcategoryentryPeer::doSelectJoinTblpresentation($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TblblogcategoryentryPeer::CE_LINK, $this->doc_id);

			if (!isset($this->lastTblblogcategoryentryCriteria) || !$this->lastTblblogcategoryentryCriteria->equals($criteria)) {
				$this->collTblblogcategoryentrys = TblblogcategoryentryPeer::doSelectJoinTblpresentation($criteria, $con, $join_behavior);
			}
		}
		$this->lastTblblogcategoryentryCriteria = $criteria;

		return $this->collTblblogcategoryentrys;
	}

	
	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(TbldocumentPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

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

				$criteria->add(TblblogentryPeer::ENTRY_LINK, $this->doc_id);

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

				$criteria->add(TblblogentryPeer::ENTRY_LINK, $this->doc_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(TbldocumentPeer::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_LINK, $this->doc_id);

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

				$criteria->add(TblblogentryPeer::ENTRY_LINK, $this->doc_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->setTbldocument($this);
		}
	}


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

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

				$criteria->add(TblblogentryPeer::ENTRY_LINK, $this->doc_id);

				$this->collTblblogentrys = TblblogentryPeer::doSelectJoinTblpresentation($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TblblogentryPeer::ENTRY_LINK, $this->doc_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 getTblblogentrysJoinTblblogcategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TbldocumentPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

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

				$criteria->add(TblblogentryPeer::ENTRY_LINK, $this->doc_id);

				$this->collTblblogentrys = TblblogentryPeer::doSelectJoinTblblogcategory($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TblblogentryPeer::ENTRY_LINK, $this->doc_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 getTblblogentrysJoinTblblog($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TbldocumentPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

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

				$criteria->add(TblblogentryPeer::ENTRY_LINK, $this->doc_id);

				$this->collTblblogentrys = TblblogentryPeer::doSelectJoinTblblog($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TblblogentryPeer::ENTRY_LINK, $this->doc_id);

			if (!isset($this->lastTblblogentryCriteria) || !$this->lastTblblogentryCriteria->equals($criteria)) {
				$this->collTblblogentrys = TblblogentryPeer::doSelectJoinTblblog($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(TbldocumentPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

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

				$criteria->add(TblblogentryPeer::ENTRY_LINK, $this->doc_id);

				$this->collTblblogentrys = TblblogentryPeer::doSelectJoinTbluser($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TblblogentryPeer::ENTRY_LINK, $this->doc_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 clearTbluserdocuments()
	{
		$this->collTbluserdocuments = null; 	}

	
	public function initTbluserdocuments()
	{
		$this->collTbluserdocuments = array();
	}

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

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

				$criteria->add(TbluserdocumentPeer::USDOC_DOCUMENT, $this->doc_id);

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

				$criteria->add(TbluserdocumentPeer::USDOC_DOCUMENT, $this->doc_id);

				TbluserdocumentPeer::addSelectColumns($criteria);
				if (!isset($this->lastTbluserdocumentCriteria) || !$this->lastTbluserdocumentCriteria->equals($criteria)) {
					$this->collTbluserdocuments = TbluserdocumentPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastTbluserdocumentCriteria = $criteria;
		return $this->collTbluserdocuments;
	}

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

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

		$count = null;

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

				$criteria->add(TbluserdocumentPeer::USDOC_DOCUMENT, $this->doc_id);

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

				$criteria->add(TbluserdocumentPeer::USDOC_DOCUMENT, $this->doc_id);

				if (!isset($this->lastTbluserdocumentCriteria) || !$this->lastTbluserdocumentCriteria->equals($criteria)) {
					$count = TbluserdocumentPeer::doCount($criteria, $con);
				} else {
					$count = count($this->collTbluserdocuments);
				}
			} else {
				$count = count($this->collTbluserdocuments);
			}
		}
		$this->lastTbluserdocumentCriteria = $criteria;
		return $count;
	}

	
	public function addTbluserdocument(Tbluserdocument $l)
	{
		if ($this->collTbluserdocuments === null) {
			$this->initTbluserdocuments();
		}
		if (!in_array($l, $this->collTbluserdocuments, true)) { 			array_push($this->collTbluserdocuments, $l);
			$l->setTbldocument($this);
		}
	}

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

} 