<?php


abstract class BaseTblblogentryinvalidPeer {

	
	const DATABASE_NAME = 'propel';

	
	const TABLE_NAME = 'tblblogentryinvalid';

	
	const CLASS_DEFAULT = 'lib.model.Tblblogentryinvalid';

	
	const NUM_COLUMNS = 6;

	
	const NUM_LAZY_LOAD_COLUMNS = 0;

	
	const EI_FROM = 'tblblogentryinvalid.EI_FROM';

	
	const EI_TO = 'tblblogentryinvalid.EI_TO';

	
	const EI_ENTRY = 'tblblogentryinvalid.EI_ENTRY';

	
	const EI_CONTENT = 'tblblogentryinvalid.EI_CONTENT';

	
	const EI_BLOG = 'tblblogentryinvalid.EI_BLOG';

	
	const EI_DATESENT = 'tblblogentryinvalid.EI_DATESENT';

	
	public static $instances = array();

	
	private static $mapBuilder = null;

	
	private static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('EiFrom', 'EiTo', 'EiEntry', 'EiContent', 'EiBlog', 'EiDatesent', ),
		BasePeer::TYPE_STUDLYPHPNAME => array ('eiFrom', 'eiTo', 'eiEntry', 'eiContent', 'eiBlog', 'eiDatesent', ),
		BasePeer::TYPE_COLNAME => array (self::EI_FROM, self::EI_TO, self::EI_ENTRY, self::EI_CONTENT, self::EI_BLOG, self::EI_DATESENT, ),
		BasePeer::TYPE_FIELDNAME => array ('ei_from', 'ei_to', 'ei_entry', 'ei_content', 'ei_blog', 'ei_datesent', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
	);

	
	private static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('EiFrom' => 0, 'EiTo' => 1, 'EiEntry' => 2, 'EiContent' => 3, 'EiBlog' => 4, 'EiDatesent' => 5, ),
		BasePeer::TYPE_STUDLYPHPNAME => array ('eiFrom' => 0, 'eiTo' => 1, 'eiEntry' => 2, 'eiContent' => 3, 'eiBlog' => 4, 'eiDatesent' => 5, ),
		BasePeer::TYPE_COLNAME => array (self::EI_FROM => 0, self::EI_TO => 1, self::EI_ENTRY => 2, self::EI_CONTENT => 3, self::EI_BLOG => 4, self::EI_DATESENT => 5, ),
		BasePeer::TYPE_FIELDNAME => array ('ei_from' => 0, 'ei_to' => 1, 'ei_entry' => 2, 'ei_content' => 3, 'ei_blog' => 4, 'ei_datesent' => 5, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
	);

	
	public static function getMapBuilder()
	{
		if (self::$mapBuilder === null) {
			self::$mapBuilder = new TblblogentryinvalidMapBuilder();
		}
		return self::$mapBuilder;
	}
	
	static public function translateFieldName($name, $fromType, $toType)
	{
		$toNames = self::getFieldNames($toType);
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
		if ($key === null) {
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
		}
		return $toNames[$key];
	}

	

	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
	{
		if (!array_key_exists($type, self::$fieldNames)) {
			throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	
	public static function alias($alias, $column)
	{
		return str_replace(TblblogentryinvalidPeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	
	public static function addSelectColumns(Criteria $criteria)
	{

		$criteria->addSelectColumn(TblblogentryinvalidPeer::EI_FROM);

		$criteria->addSelectColumn(TblblogentryinvalidPeer::EI_TO);

		$criteria->addSelectColumn(TblblogentryinvalidPeer::EI_ENTRY);

		$criteria->addSelectColumn(TblblogentryinvalidPeer::EI_CONTENT);

		$criteria->addSelectColumn(TblblogentryinvalidPeer::EI_BLOG);

		$criteria->addSelectColumn(TblblogentryinvalidPeer::EI_DATESENT);

	}

	
	public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
	{
				$criteria = clone $criteria;

								$criteria->setPrimaryTableName(TblblogentryinvalidPeer::TABLE_NAME);

		if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->setDistinct();
		}

		if (!$criteria->hasSelectClause()) {
			TblblogentryinvalidPeer::addSelectColumns($criteria);
		}

		$criteria->clearOrderByColumns(); 		$criteria->setDbName(self::DATABASE_NAME); 
		if ($con === null) {
			$con = Propel::getConnection(TblblogentryinvalidPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}
				$stmt = BasePeer::doCount($criteria, $con);

		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$count = (int) $row[0];
		} else {
			$count = 0; 		}
		$stmt->closeCursor();
		return $count;
	}
	
	public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = TblblogentryinvalidPeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	
	public static function doSelect(Criteria $criteria, PropelPDO $con = null)
	{
		return TblblogentryinvalidPeer::populateObjects(TblblogentryinvalidPeer::doSelectStmt($criteria, $con));
	}
	
	public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(TblblogentryinvalidPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

		if (!$criteria->hasSelectClause()) {
			$criteria = clone $criteria;
			TblblogentryinvalidPeer::addSelectColumns($criteria);
		}

				$criteria->setDbName(self::DATABASE_NAME);

				return BasePeer::doSelect($criteria, $con);
	}
	
	public static function addInstanceToPool(Tblblogentryinvalid $obj, $key = null)
	{
		if (Propel::isInstancePoolingEnabled()) {
			if ($key === null) {
				$key = (string) $obj->getEiEntry();
			} 			self::$instances[$key] = $obj;
		}
	}

	
	public static function removeInstanceFromPool($value)
	{
		if (Propel::isInstancePoolingEnabled() && $value !== null) {
			if (is_object($value) && $value instanceof Tblblogentryinvalid) {
				$key = (string) $value->getEiEntry();
			} elseif (is_scalar($value)) {
								$key = (string) $value;
			} else {
				$e = new PropelException("Invalid value passed to removeInstanceFromPool().  Expected primary key or Tblblogentryinvalid object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
				throw $e;
			}

			unset(self::$instances[$key]);
		}
	} 
	
	public static function getInstanceFromPool($key)
	{
		if (Propel::isInstancePoolingEnabled()) {
			if (isset(self::$instances[$key])) {
				return self::$instances[$key];
			}
		}
		return null; 	}
	
	
	public static function clearInstancePool()
	{
		self::$instances = array();
	}
	
	
	public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
	{
				if ($row[$startcol + 2] === null) {
			return null;
		}
		return (string) $row[$startcol + 2];
	}

	
	public static function populateObjects(PDOStatement $stmt)
	{
		$results = array();
	
				$cls = TblblogentryinvalidPeer::getOMClass();
		$cls = substr('.'.$cls, strrpos('.'.$cls, '.') + 1);
				while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$key = TblblogentryinvalidPeer::getPrimaryKeyHashFromRow($row, 0);
			if (null !== ($obj = TblblogentryinvalidPeer::getInstanceFromPool($key))) {
																$results[] = $obj;
			} else {
		
				$obj = new $cls();
				$obj->hydrate($row);
				$results[] = $obj;
				TblblogentryinvalidPeer::addInstanceToPool($obj, $key);
			} 		}
		$stmt->closeCursor();
		return $results;
	}
	
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	
	public static function getOMClass()
	{
		return TblblogentryinvalidPeer::CLASS_DEFAULT;
	}

	
	public static function doInsert($values, PropelPDO $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(TblblogentryinvalidPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} else {
			$criteria = $values->buildCriteria(); 		}


				$criteria->setDbName(self::DATABASE_NAME);

		try {
									$con->beginTransaction();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollBack();
			throw $e;
		}

		return $pk;
	}

	
	public static function doUpdate($values, PropelPDO $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(TblblogentryinvalidPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}

		$selectCriteria = new Criteria(self::DATABASE_NAME);

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
			$comparison = $criteria->getComparison(TblblogentryinvalidPeer::EI_ENTRY);
			$selectCriteria->add(TblblogentryinvalidPeer::EI_ENTRY, $criteria->remove(TblblogentryinvalidPeer::EI_ENTRY), $comparison);

		} else { 			$criteria = $values->buildCriteria(); 			$selectCriteria = $values->buildPkeyCriteria(); 		}

				$criteria->setDbName(self::DATABASE_NAME);

		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
	}

	
	public static function doDeleteAll($con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(TblblogentryinvalidPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		$affectedRows = 0; 		try {
									$con->beginTransaction();
			$affectedRows += BasePeer::doDeleteAll(TblblogentryinvalidPeer::TABLE_NAME, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollBack();
			throw $e;
		}
	}

	
	 public static function doDelete($values, PropelPDO $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(TblblogentryinvalidPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}

		if ($values instanceof Criteria) {
												TblblogentryinvalidPeer::clearInstancePool();

						$criteria = clone $values;
		} elseif ($values instanceof Tblblogentryinvalid) {
						TblblogentryinvalidPeer::removeInstanceFromPool($values);
						$criteria = $values->buildPkeyCriteria();
		} else {
			


			$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(TblblogentryinvalidPeer::EI_ENTRY, (array) $values, Criteria::IN);

			foreach ((array) $values as $singleval) {
								TblblogentryinvalidPeer::removeInstanceFromPool($singleval);
			}
		}

				$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; 
		try {
									$con->beginTransaction();
			
			$affectedRows += BasePeer::doDelete($criteria, $con);

			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollBack();
			throw $e;
		}
	}

	
	public static function doValidate(Tblblogentryinvalid $obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(TblblogentryinvalidPeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(TblblogentryinvalidPeer::TABLE_NAME);

			if (! is_array($cols)) {
				$cols = array($cols);
			}

			foreach ($cols as $colName) {
				if ($tableMap->containsColumn($colName)) {
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
					$columns[$colName] = $obj->$get();
				}
			}
		} else {

		}

		$res =  BasePeer::doValidate(TblblogentryinvalidPeer::DATABASE_NAME, TblblogentryinvalidPeer::TABLE_NAME, $columns);
    if ($res !== true) {
        $request = sfContext::getInstance()->getRequest();
        foreach ($res as $failed) {
            $col = TblblogentryinvalidPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
            $request->setError($col, $failed->getMessage());
        }
    }

    return $res;
	}

	
	public static function retrieveByPK($pk, PropelPDO $con = null)
	{

		if (null !== ($obj = TblblogentryinvalidPeer::getInstanceFromPool((string) $pk))) {
			return $obj;
		}

		if ($con === null) {
			$con = Propel::getConnection(TblblogentryinvalidPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

		$criteria = new Criteria(TblblogentryinvalidPeer::DATABASE_NAME);
		$criteria->add(TblblogentryinvalidPeer::EI_ENTRY, $pk);

		$v = TblblogentryinvalidPeer::doSelect($criteria, $con);

		return !empty($v) > 0 ? $v[0] : null;
	}

	
	public static function retrieveByPKs($pks, PropelPDO $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(TblblogentryinvalidPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria(TblblogentryinvalidPeer::DATABASE_NAME);
			$criteria->add(TblblogentryinvalidPeer::EI_ENTRY, $pks, Criteria::IN);
			$objs = TblblogentryinvalidPeer::doSelect($criteria, $con);
		}
		return $objs;
	}

} 

Propel::getDatabaseMap(BaseTblblogentryinvalidPeer::DATABASE_NAME)->addTableBuilder(BaseTblblogentryinvalidPeer::TABLE_NAME, BaseTblblogentryinvalidPeer::getMapBuilder());

