<?php

/**
 * Base static class for performing query and update operations on the 'katao_config' table.
 *
 * 
 *
 * @package    lib.model.om
 */
abstract class BaseKataoConfigPeer {

	/** the default database name for this class */
	const DATABASE_NAME = 'propel';

	/** the table name for this class */
	const TABLE_NAME = 'katao_config';

	/** A class that can be returned by this peer. */
	const CLASS_DEFAULT = 'lib.model.KataoConfig';

	/** The total number of columns. */
	const NUM_COLUMNS = 33;

	/** The number of lazy-loaded columns. */
	const NUM_LAZY_LOAD_COLUMNS = 0;


	/** the column name for the ID field */
	const ID = 'katao_config.ID';

	/** the column name for the KATAO_MEMBER_ID field */
	const KATAO_MEMBER_ID = 'katao_config.KATAO_MEMBER_ID';

	/** the column name for the NAME field */
	const NAME = 'katao_config.NAME';

	/** the column name for the ADDRESS field */
	const ADDRESS = 'katao_config.ADDRESS';

	/** the column name for the PHONE field */
	const PHONE = 'katao_config.PHONE';

	/** the column name for the EMAIL field */
	const EMAIL = 'katao_config.EMAIL';

	/** the column name for the SIRET_NUMBER field */
	const SIRET_NUMBER = 'katao_config.SIRET_NUMBER';

	/** the column name for the TVA_NUMBER field */
	const TVA_NUMBER = 'katao_config.TVA_NUMBER';

	/** the column name for the RCS_NUMBER field */
	const RCS_NUMBER = 'katao_config.RCS_NUMBER';

	/** the column name for the CAPITAL field */
	const CAPITAL = 'katao_config.CAPITAL';

	/** the column name for the INITIAL_TRANSACTIONS_COUNT field */
	const INITIAL_TRANSACTIONS_COUNT = 'katao_config.INITIAL_TRANSACTIONS_COUNT';

	/** the column name for the INITIAL_TRANSACTIONS_SUM field */
	const INITIAL_TRANSACTIONS_SUM = 'katao_config.INITIAL_TRANSACTIONS_SUM';

	/** the column name for the DEFAULT_PRODUCT_PICTURE field */
	const DEFAULT_PRODUCT_PICTURE = 'katao_config.DEFAULT_PRODUCT_PICTURE';

	/** the column name for the DEFAULT_PRODUCT_MARGIN field */
	const DEFAULT_PRODUCT_MARGIN = 'katao_config.DEFAULT_PRODUCT_MARGIN';

	/** the column name for the DEFAULT_PRODUCT_SOL_PERCENT field */
	const DEFAULT_PRODUCT_SOL_PERCENT = 'katao_config.DEFAULT_PRODUCT_SOL_PERCENT';

	/** the column name for the MAILING_LIST_EMAIL field */
	const MAILING_LIST_EMAIL = 'katao_config.MAILING_LIST_EMAIL';

	/** the column name for the CART_VALIDATION_DAYS_NUMBER field */
	const CART_VALIDATION_DAYS_NUMBER = 'katao_config.CART_VALIDATION_DAYS_NUMBER';

	/** the column name for the ACCOUNTING_CODE_PREFIX_PURCHASE field */
	const ACCOUNTING_CODE_PREFIX_PURCHASE = 'katao_config.ACCOUNTING_CODE_PREFIX_PURCHASE';

	/** the column name for the ACCOUNTING_CODE_PREFIX_SELL field */
	const ACCOUNTING_CODE_PREFIX_SELL = 'katao_config.ACCOUNTING_CODE_PREFIX_SELL';

	/** the column name for the ACCOUNTING_CODE_BANK field */
	const ACCOUNTING_CODE_BANK = 'katao_config.ACCOUNTING_CODE_BANK';

	/** the column name for the ACCOUNTING_CODE_BANK_SOL field */
	const ACCOUNTING_CODE_BANK_SOL = 'katao_config.ACCOUNTING_CODE_BANK_SOL';

	/** the column name for the ACCOUNTING_CODE_CREDIT field */
	const ACCOUNTING_CODE_CREDIT = 'katao_config.ACCOUNTING_CODE_CREDIT';

	/** the column name for the ACCOUNTING_CODE_ERROR_ADJUSTMENT_POSITIVE field */
	const ACCOUNTING_CODE_ERROR_ADJUSTMENT_POSITIVE = 'katao_config.ACCOUNTING_CODE_ERROR_ADJUSTMENT_POSITIVE';

	/** the column name for the ACCOUNTING_CODE_ERROR_ADJUSTMENT_NEGATIVE field */
	const ACCOUNTING_CODE_ERROR_ADJUSTMENT_NEGATIVE = 'katao_config.ACCOUNTING_CODE_ERROR_ADJUSTMENT_NEGATIVE';

	/** the column name for the ACCOUNTING_CODE_SOL_DISCOUNT field */
	const ACCOUNTING_CODE_SOL_DISCOUNT = 'katao_config.ACCOUNTING_CODE_SOL_DISCOUNT';

	/** the column name for the ACCOUNTING_CODE_FEES_SHIPPING field */
	const ACCOUNTING_CODE_FEES_SHIPPING = 'katao_config.ACCOUNTING_CODE_FEES_SHIPPING';

	/** the column name for the ACCOUNTING_CODE_FEES_BILLING field */
	const ACCOUNTING_CODE_FEES_BILLING = 'katao_config.ACCOUNTING_CODE_FEES_BILLING';

	/** the column name for the ACCOUNTING_CODE_DISCOUNT field */
	const ACCOUNTING_CODE_DISCOUNT = 'katao_config.ACCOUNTING_CODE_DISCOUNT';

	/** the column name for the MEMBER_FEE field */
	const MEMBER_FEE = 'katao_config.MEMBER_FEE';

	/** the column name for the ADDITIONAL_CURRENCY_NAME field */
	const ADDITIONAL_CURRENCY_NAME = 'katao_config.ADDITIONAL_CURRENCY_NAME';

	/** the column name for the DEBUG_EMAIL field */
	const DEBUG_EMAIL = 'katao_config.DEBUG_EMAIL';

	/** the column name for the BANK_NAME field */
	const BANK_NAME = 'katao_config.BANK_NAME';

	/** the column name for the BANK_ACCOUNT field */
	const BANK_ACCOUNT = 'katao_config.BANK_ACCOUNT';

	/** The PHP to DB Name Mapping */
	private static $phpNameMap = null;


	/**
	 * holds an array of fieldnames
	 *
	 * first dimension keys are the type constants
	 * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
	 */
	private static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('Id', 'KataoMemberId', 'Name', 'Address', 'Phone', 'Email', 'SiretNumber', 'TvaNumber', 'RcsNumber', 'Capital', 'InitialTransactionsCount', 'InitialTransactionsSum', 'DefaultProductPicture', 'DefaultProductMargin', 'DefaultProductSolPercent', 'MailingListEmail', 'CartValidationDaysNumber', 'AccountingCodePrefixPurchase', 'AccountingCodePrefixSell', 'AccountingCodeBank', 'AccountingCodeBankSol', 'AccountingCodeCredit', 'AccountingCodeErrorAdjustmentPositive', 'AccountingCodeErrorAdjustmentNegative', 'AccountingCodeSolDiscount', 'AccountingCodeFeesShipping', 'AccountingCodeFeesBilling', 'AccountingCodeDiscount', 'MemberFee', 'AdditionalCurrencyName', 'DebugEmail', 'BankName', 'BankAccount', ),
		BasePeer::TYPE_COLNAME => array (KataoConfigPeer::ID, KataoConfigPeer::KATAO_MEMBER_ID, KataoConfigPeer::NAME, KataoConfigPeer::ADDRESS, KataoConfigPeer::PHONE, KataoConfigPeer::EMAIL, KataoConfigPeer::SIRET_NUMBER, KataoConfigPeer::TVA_NUMBER, KataoConfigPeer::RCS_NUMBER, KataoConfigPeer::CAPITAL, KataoConfigPeer::INITIAL_TRANSACTIONS_COUNT, KataoConfigPeer::INITIAL_TRANSACTIONS_SUM, KataoConfigPeer::DEFAULT_PRODUCT_PICTURE, KataoConfigPeer::DEFAULT_PRODUCT_MARGIN, KataoConfigPeer::DEFAULT_PRODUCT_SOL_PERCENT, KataoConfigPeer::MAILING_LIST_EMAIL, KataoConfigPeer::CART_VALIDATION_DAYS_NUMBER, KataoConfigPeer::ACCOUNTING_CODE_PREFIX_PURCHASE, KataoConfigPeer::ACCOUNTING_CODE_PREFIX_SELL, KataoConfigPeer::ACCOUNTING_CODE_BANK, KataoConfigPeer::ACCOUNTING_CODE_BANK_SOL, KataoConfigPeer::ACCOUNTING_CODE_CREDIT, KataoConfigPeer::ACCOUNTING_CODE_ERROR_ADJUSTMENT_POSITIVE, KataoConfigPeer::ACCOUNTING_CODE_ERROR_ADJUSTMENT_NEGATIVE, KataoConfigPeer::ACCOUNTING_CODE_SOL_DISCOUNT, KataoConfigPeer::ACCOUNTING_CODE_FEES_SHIPPING, KataoConfigPeer::ACCOUNTING_CODE_FEES_BILLING, KataoConfigPeer::ACCOUNTING_CODE_DISCOUNT, KataoConfigPeer::MEMBER_FEE, KataoConfigPeer::ADDITIONAL_CURRENCY_NAME, KataoConfigPeer::DEBUG_EMAIL, KataoConfigPeer::BANK_NAME, KataoConfigPeer::BANK_ACCOUNT, ),
		BasePeer::TYPE_FIELDNAME => array ('id', 'katao_member_id', 'name', 'address', 'phone', 'email', 'siret_number', 'tva_number', 'rcs_number', 'capital', 'initial_transactions_count', 'initial_transactions_sum', 'default_product_picture', 'default_product_margin', 'default_product_sol_percent', 'mailing_list_email', 'cart_validation_days_number', 'accounting_code_prefix_purchase', 'accounting_code_prefix_sell', 'accounting_code_bank', 'accounting_code_bank_sol', 'accounting_code_credit', 'accounting_code_error_adjustment_positive', 'accounting_code_error_adjustment_negative', 'accounting_code_sol_discount', 'accounting_code_fees_shipping', 'accounting_code_fees_billing', 'accounting_code_discount', 'member_fee', 'additional_currency_name', 'debug_email', 'bank_name', 'bank_account', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, )
	);

	/**
	 * holds an array of keys for quick access to the fieldnames array
	 *
	 * first dimension keys are the type constants
	 * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
	 */
	private static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'KataoMemberId' => 1, 'Name' => 2, 'Address' => 3, 'Phone' => 4, 'Email' => 5, 'SiretNumber' => 6, 'TvaNumber' => 7, 'RcsNumber' => 8, 'Capital' => 9, 'InitialTransactionsCount' => 10, 'InitialTransactionsSum' => 11, 'DefaultProductPicture' => 12, 'DefaultProductMargin' => 13, 'DefaultProductSolPercent' => 14, 'MailingListEmail' => 15, 'CartValidationDaysNumber' => 16, 'AccountingCodePrefixPurchase' => 17, 'AccountingCodePrefixSell' => 18, 'AccountingCodeBank' => 19, 'AccountingCodeBankSol' => 20, 'AccountingCodeCredit' => 21, 'AccountingCodeErrorAdjustmentPositive' => 22, 'AccountingCodeErrorAdjustmentNegative' => 23, 'AccountingCodeSolDiscount' => 24, 'AccountingCodeFeesShipping' => 25, 'AccountingCodeFeesBilling' => 26, 'AccountingCodeDiscount' => 27, 'MemberFee' => 28, 'AdditionalCurrencyName' => 29, 'DebugEmail' => 30, 'BankName' => 31, 'BankAccount' => 32, ),
		BasePeer::TYPE_COLNAME => array (KataoConfigPeer::ID => 0, KataoConfigPeer::KATAO_MEMBER_ID => 1, KataoConfigPeer::NAME => 2, KataoConfigPeer::ADDRESS => 3, KataoConfigPeer::PHONE => 4, KataoConfigPeer::EMAIL => 5, KataoConfigPeer::SIRET_NUMBER => 6, KataoConfigPeer::TVA_NUMBER => 7, KataoConfigPeer::RCS_NUMBER => 8, KataoConfigPeer::CAPITAL => 9, KataoConfigPeer::INITIAL_TRANSACTIONS_COUNT => 10, KataoConfigPeer::INITIAL_TRANSACTIONS_SUM => 11, KataoConfigPeer::DEFAULT_PRODUCT_PICTURE => 12, KataoConfigPeer::DEFAULT_PRODUCT_MARGIN => 13, KataoConfigPeer::DEFAULT_PRODUCT_SOL_PERCENT => 14, KataoConfigPeer::MAILING_LIST_EMAIL => 15, KataoConfigPeer::CART_VALIDATION_DAYS_NUMBER => 16, KataoConfigPeer::ACCOUNTING_CODE_PREFIX_PURCHASE => 17, KataoConfigPeer::ACCOUNTING_CODE_PREFIX_SELL => 18, KataoConfigPeer::ACCOUNTING_CODE_BANK => 19, KataoConfigPeer::ACCOUNTING_CODE_BANK_SOL => 20, KataoConfigPeer::ACCOUNTING_CODE_CREDIT => 21, KataoConfigPeer::ACCOUNTING_CODE_ERROR_ADJUSTMENT_POSITIVE => 22, KataoConfigPeer::ACCOUNTING_CODE_ERROR_ADJUSTMENT_NEGATIVE => 23, KataoConfigPeer::ACCOUNTING_CODE_SOL_DISCOUNT => 24, KataoConfigPeer::ACCOUNTING_CODE_FEES_SHIPPING => 25, KataoConfigPeer::ACCOUNTING_CODE_FEES_BILLING => 26, KataoConfigPeer::ACCOUNTING_CODE_DISCOUNT => 27, KataoConfigPeer::MEMBER_FEE => 28, KataoConfigPeer::ADDITIONAL_CURRENCY_NAME => 29, KataoConfigPeer::DEBUG_EMAIL => 30, KataoConfigPeer::BANK_NAME => 31, KataoConfigPeer::BANK_ACCOUNT => 32, ),
		BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'katao_member_id' => 1, 'name' => 2, 'address' => 3, 'phone' => 4, 'email' => 5, 'siret_number' => 6, 'tva_number' => 7, 'rcs_number' => 8, 'capital' => 9, 'initial_transactions_count' => 10, 'initial_transactions_sum' => 11, 'default_product_picture' => 12, 'default_product_margin' => 13, 'default_product_sol_percent' => 14, 'mailing_list_email' => 15, 'cart_validation_days_number' => 16, 'accounting_code_prefix_purchase' => 17, 'accounting_code_prefix_sell' => 18, 'accounting_code_bank' => 19, 'accounting_code_bank_sol' => 20, 'accounting_code_credit' => 21, 'accounting_code_error_adjustment_positive' => 22, 'accounting_code_error_adjustment_negative' => 23, 'accounting_code_sol_discount' => 24, 'accounting_code_fees_shipping' => 25, 'accounting_code_fees_billing' => 26, 'accounting_code_discount' => 27, 'member_fee' => 28, 'additional_currency_name' => 29, 'debug_email' => 30, 'bank_name' => 31, 'bank_account' => 32, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, )
	);

	/**
	 * @return     MapBuilder the map builder for this peer
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function getMapBuilder()
	{
		return BasePeer::getMapBuilder('lib.model.map.KataoConfigMapBuilder');
	}
	/**
	 * Gets a map (hash) of PHP names to DB column names.
	 *
	 * @return     array The PHP to DB name map for this peer
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
	 */
	public static function getPhpNameMap()
	{
		if (self::$phpNameMap === null) {
			$map = KataoConfigPeer::getTableMap();
			$columns = $map->getColumns();
			$nameMap = array();
			foreach ($columns as $column) {
				$nameMap[$column->getPhpName()] = $column->getColumnName();
			}
			self::$phpNameMap = $nameMap;
		}
		return self::$phpNameMap;
	}
	/**
	 * Translates a fieldname to another type
	 *
	 * @param      string $name field name
	 * @param      string $fromType One of the class type constants TYPE_PHPNAME,
	 *                         TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
	 * @param      string $toType   One of the class type constants
	 * @return     string translated name of the field.
	 */
	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];
	}

	/**
	 * Returns an array of of field names.
	 *
	 * @param      string $type The type of fieldnames to return:
	 *                      One of the class type constants TYPE_PHPNAME,
	 *                      TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
	 * @return     array A list of field names
	 */

	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 TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	/**
	 * Convenience method which changes table.column to alias.column.
	 *
	 * Using this method you can maintain SQL abstraction while using column aliases.
	 * <code>
	 *		$c->addAlias("alias1", TablePeer::TABLE_NAME);
	 *		$c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
	 * </code>
	 * @param      string $alias The alias for the current table.
	 * @param      string $column The column name for current table. (i.e. KataoConfigPeer::COLUMN_NAME).
	 * @return     string
	 */
	public static function alias($alias, $column)
	{
		return str_replace(KataoConfigPeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	/**
	 * Add all the columns needed to create a new object.
	 *
	 * Note: any columns that were marked with lazyLoad="true" in the
	 * XML schema will not be added to the select list and only loaded
	 * on demand.
	 *
	 * @param      criteria object containing the columns to add.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function addSelectColumns(Criteria $criteria)
	{

		$criteria->addSelectColumn(KataoConfigPeer::ID);

		$criteria->addSelectColumn(KataoConfigPeer::KATAO_MEMBER_ID);

		$criteria->addSelectColumn(KataoConfigPeer::NAME);

		$criteria->addSelectColumn(KataoConfigPeer::ADDRESS);

		$criteria->addSelectColumn(KataoConfigPeer::PHONE);

		$criteria->addSelectColumn(KataoConfigPeer::EMAIL);

		$criteria->addSelectColumn(KataoConfigPeer::SIRET_NUMBER);

		$criteria->addSelectColumn(KataoConfigPeer::TVA_NUMBER);

		$criteria->addSelectColumn(KataoConfigPeer::RCS_NUMBER);

		$criteria->addSelectColumn(KataoConfigPeer::CAPITAL);

		$criteria->addSelectColumn(KataoConfigPeer::INITIAL_TRANSACTIONS_COUNT);

		$criteria->addSelectColumn(KataoConfigPeer::INITIAL_TRANSACTIONS_SUM);

		$criteria->addSelectColumn(KataoConfigPeer::DEFAULT_PRODUCT_PICTURE);

		$criteria->addSelectColumn(KataoConfigPeer::DEFAULT_PRODUCT_MARGIN);

		$criteria->addSelectColumn(KataoConfigPeer::DEFAULT_PRODUCT_SOL_PERCENT);

		$criteria->addSelectColumn(KataoConfigPeer::MAILING_LIST_EMAIL);

		$criteria->addSelectColumn(KataoConfigPeer::CART_VALIDATION_DAYS_NUMBER);

		$criteria->addSelectColumn(KataoConfigPeer::ACCOUNTING_CODE_PREFIX_PURCHASE);

		$criteria->addSelectColumn(KataoConfigPeer::ACCOUNTING_CODE_PREFIX_SELL);

		$criteria->addSelectColumn(KataoConfigPeer::ACCOUNTING_CODE_BANK);

		$criteria->addSelectColumn(KataoConfigPeer::ACCOUNTING_CODE_BANK_SOL);

		$criteria->addSelectColumn(KataoConfigPeer::ACCOUNTING_CODE_CREDIT);

		$criteria->addSelectColumn(KataoConfigPeer::ACCOUNTING_CODE_ERROR_ADJUSTMENT_POSITIVE);

		$criteria->addSelectColumn(KataoConfigPeer::ACCOUNTING_CODE_ERROR_ADJUSTMENT_NEGATIVE);

		$criteria->addSelectColumn(KataoConfigPeer::ACCOUNTING_CODE_SOL_DISCOUNT);

		$criteria->addSelectColumn(KataoConfigPeer::ACCOUNTING_CODE_FEES_SHIPPING);

		$criteria->addSelectColumn(KataoConfigPeer::ACCOUNTING_CODE_FEES_BILLING);

		$criteria->addSelectColumn(KataoConfigPeer::ACCOUNTING_CODE_DISCOUNT);

		$criteria->addSelectColumn(KataoConfigPeer::MEMBER_FEE);

		$criteria->addSelectColumn(KataoConfigPeer::ADDITIONAL_CURRENCY_NAME);

		$criteria->addSelectColumn(KataoConfigPeer::DEBUG_EMAIL);

		$criteria->addSelectColumn(KataoConfigPeer::BANK_NAME);

		$criteria->addSelectColumn(KataoConfigPeer::BANK_ACCOUNT);

	}

	const COUNT = 'COUNT(katao_config.ID)';
	const COUNT_DISTINCT = 'COUNT(DISTINCT katao_config.ID)';

	/**
	 * Returns the number of rows matching criteria.
	 *
	 * @param      Criteria $criteria
	 * @param      boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
	 * @param      Connection $con
	 * @return     int Number of matching rows.
	 */
	public static function doCount(Criteria $criteria, $distinct = false, $con = null)
	{
		// we're going to modify criteria, so copy it first
		$criteria = clone $criteria;

		// clear out anything that might confuse the ORDER BY clause
		$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(KataoConfigPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(KataoConfigPeer::COUNT);
		}

		// just in case we're grouping: add those columns to the select statement
		foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$rs = KataoConfigPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
			// no rows returned; we infer that means 0 matches.
			return 0;
		}
	}
	/**
	 * Method to select one object from the DB.
	 *
	 * @param      Criteria $criteria object used to create the SELECT statement.
	 * @param      Connection $con
	 * @return     KataoConfig
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doSelectOne(Criteria $criteria, $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = KataoConfigPeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	/**
	 * Method to do selects.
	 *
	 * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
	 * @param      Connection $con
	 * @return     array Array of selected Objects
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doSelect(Criteria $criteria, $con = null)
	{
		return KataoConfigPeer::populateObjects(KataoConfigPeer::doSelectRS($criteria, $con));
	}
	/**
	 * Prepares the Criteria object and uses the parent doSelect()
	 * method to get a ResultSet.
	 *
	 * Use this method directly if you want to just get the resultset
	 * (instead of an array of objects).
	 *
	 * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
	 * @param      Connection $con the connection to use
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 * @return     ResultSet The resultset object with numerically-indexed fields.
	 * @see        BasePeer::doSelect()
	 */
	public static function doSelectRS(Criteria $criteria, $con = null)
	{

    foreach (sfMixer::getCallables('BaseKataoConfigPeer:doSelectRS:doSelectRS') as $callable)
    {
      call_user_func($callable, 'BaseKataoConfigPeer', $criteria, $con);
    }


		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if (!$criteria->getSelectColumns()) {
			$criteria = clone $criteria;
			KataoConfigPeer::addSelectColumns($criteria);
		}

		// Set the correct dbName
		$criteria->setDbName(self::DATABASE_NAME);

		// BasePeer returns a Creole ResultSet, set to return
		// rows indexed numerically.
		return BasePeer::doSelect($criteria, $con);
	}
	/**
	 * The returned array will contain objects of the default type or
	 * objects that inherit from the default.
	 *
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function populateObjects(ResultSet $rs)
	{
		$results = array();
	
		// set the class once to avoid overhead in the loop
		$cls = KataoConfigPeer::getOMClass();
		$cls = sfPropel::import($cls);
		// populate the object(s)
		while($rs->next()) {
		
			$obj = new $cls();
			$obj->hydrate($rs);
			$results[] = $obj;
			
		}
		return $results;
	}

	/**
	 * Returns the number of rows matching criteria, joining the related KataoMember table
	 *
	 * @param      Criteria $c
	 * @param      boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
	 * @param      Connection $con
	 * @return     int Number of matching rows.
	 */
	public static function doCountJoinKataoMember(Criteria $criteria, $distinct = false, $con = null)
	{
		// we're going to modify criteria, so copy it first
		$criteria = clone $criteria;

		// clear out anything that might confuse the ORDER BY clause
		$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(KataoConfigPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(KataoConfigPeer::COUNT);
		}

		// just in case we're grouping: add those columns to the select statement
		foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(KataoConfigPeer::KATAO_MEMBER_ID, KataoMemberPeer::ID);

		$rs = KataoConfigPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
			// no rows returned; we infer that means 0 matches.
			return 0;
		}
	}


	/**
	 * Selects a collection of KataoConfig objects pre-filled with their KataoMember objects.
	 *
	 * @return     array Array of KataoConfig objects.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doSelectJoinKataoMember(Criteria $c, $con = null)
	{

    foreach (sfMixer::getCallables('BaseKataoConfigPeer:doSelectJoin:doSelectJoin') as $callable)
    {
      call_user_func($callable, 'BaseKataoConfigPeer', $c, $con);
    }


		$c = clone $c;

		// Set the correct dbName if it has not been overridden
		if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		KataoConfigPeer::addSelectColumns($c);
		$startcol = (KataoConfigPeer::NUM_COLUMNS - KataoConfigPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
		KataoMemberPeer::addSelectColumns($c);

		$c->addJoin(KataoConfigPeer::KATAO_MEMBER_ID, KataoMemberPeer::ID);
		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = KataoConfigPeer::getOMClass();

			$cls = sfPropel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = KataoMemberPeer::getOMClass();

			$cls = sfPropel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol);

			$newObject = true;
			foreach($results as $temp_obj1) {
				$temp_obj2 = $temp_obj1->getKataoMember(); //CHECKME
				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					// e.g. $author->addBookRelatedByBookId()
					$temp_obj2->addKataoConfig($obj1); //CHECKME
					break;
				}
			}
			if ($newObject) {
				$obj2->initKataoConfigs();
				$obj2->addKataoConfig($obj1); //CHECKME
			}
			$results[] = $obj1;
		}
		return $results;
	}


	/**
	 * Returns the number of rows matching criteria, joining all related tables
	 *
	 * @param      Criteria $c
	 * @param      boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
	 * @param      Connection $con
	 * @return     int Number of matching rows.
	 */
	public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
	{
		$criteria = clone $criteria;

		// clear out anything that might confuse the ORDER BY clause
		$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(KataoConfigPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(KataoConfigPeer::COUNT);
		}

		// just in case we're grouping: add those columns to the select statement
		foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(KataoConfigPeer::KATAO_MEMBER_ID, KataoMemberPeer::ID);

		$rs = KataoConfigPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
			// no rows returned; we infer that means 0 matches.
			return 0;
		}
	}


	/**
	 * Selects a collection of KataoConfig objects pre-filled with all related objects.
	 *
	 * @return     array Array of KataoConfig objects.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doSelectJoinAll(Criteria $c, $con = null)
	{

    foreach (sfMixer::getCallables('BaseKataoConfigPeer:doSelectJoinAll:doSelectJoinAll') as $callable)
    {
      call_user_func($callable, 'BaseKataoConfigPeer', $c, $con);
    }


		$c = clone $c;

		// Set the correct dbName if it has not been overridden
		if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		KataoConfigPeer::addSelectColumns($c);
		$startcol2 = (KataoConfigPeer::NUM_COLUMNS - KataoConfigPeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		KataoMemberPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + KataoMemberPeer::NUM_COLUMNS;

		$c->addJoin(KataoConfigPeer::KATAO_MEMBER_ID, KataoMemberPeer::ID);

		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = KataoConfigPeer::getOMClass();


			$cls = sfPropel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);


				// Add objects for joined KataoMember rows
	
			$omClass = KataoMemberPeer::getOMClass();


			$cls = sfPropel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getKataoMember(); // CHECKME
				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addKataoConfig($obj1); // CHECKME
					break;
				}
			}

			if ($newObject) {
				$obj2->initKataoConfigs();
				$obj2->addKataoConfig($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}


  static public function getUniqueColumnNames()
  {
    return array();
  }
	/**
	 * Returns the TableMap related to this peer.
	 * This method is not needed for general use but a specific application could have a need.
	 * @return     TableMap
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	/**
	 * The class that the Peer will make instances of.
	 *
	 * This uses a dot-path notation which is tranalted into a path
	 * relative to a location on the PHP include_path.
	 * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
	 *
	 * @return     string path.to.ClassName
	 */
	public static function getOMClass()
	{
		return KataoConfigPeer::CLASS_DEFAULT;
	}

	/**
	 * Method perform an INSERT on the database, given a KataoConfig or Criteria object.
	 *
	 * @param      mixed $values Criteria or KataoConfig object containing data that is used to create the INSERT statement.
	 * @param      Connection $con the connection to use
	 * @return     mixed The new primary key.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doInsert($values, $con = null)
	{

    foreach (sfMixer::getCallables('BaseKataoConfigPeer:doInsert:pre') as $callable)
    {
      $ret = call_user_func($callable, 'BaseKataoConfigPeer', $values, $con);
      if (false !== $ret)
      {
        return $ret;
      }
    }


		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; // rename for clarity
		} else {
			$criteria = $values->buildCriteria(); // build Criteria from KataoConfig object
		}

		$criteria->remove(KataoConfigPeer::ID); // remove pkey col since this table uses auto-increment


		// Set the correct dbName
		$criteria->setDbName(self::DATABASE_NAME);

		try {
			// use transaction because $criteria could contain info
			// for more than one table (I guess, conceivably)
			$con->begin();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollback();
			throw $e;
		}

		
    foreach (sfMixer::getCallables('BaseKataoConfigPeer:doInsert:post') as $callable)
    {
      call_user_func($callable, 'BaseKataoConfigPeer', $values, $con, $pk);
    }

    return $pk;
	}

	/**
	 * Method perform an UPDATE on the database, given a KataoConfig or Criteria object.
	 *
	 * @param      mixed $values Criteria or KataoConfig object containing data that is used to create the UPDATE statement.
	 * @param      Connection $con The connection to use (specify Connection object to exert more control over transactions).
	 * @return     int The number of affected rows (if supported by underlying database driver).
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doUpdate($values, $con = null)
	{

    foreach (sfMixer::getCallables('BaseKataoConfigPeer:doUpdate:pre') as $callable)
    {
      $ret = call_user_func($callable, 'BaseKataoConfigPeer', $values, $con);
      if (false !== $ret)
      {
        return $ret;
      }
    }


		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

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

		if ($values instanceof Criteria) {
			$criteria = clone $values; // rename for clarity

			$comparison = $criteria->getComparison(KataoConfigPeer::ID);
			$selectCriteria->add(KataoConfigPeer::ID, $criteria->remove(KataoConfigPeer::ID), $comparison);

		} else { // $values is KataoConfig object
			$criteria = $values->buildCriteria(); // gets full criteria
			$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
		}

		// set the correct dbName
		$criteria->setDbName(self::DATABASE_NAME);

		$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
	

    foreach (sfMixer::getCallables('BaseKataoConfigPeer:doUpdate:post') as $callable)
    {
      call_user_func($callable, 'BaseKataoConfigPeer', $values, $con, $ret);
    }

    return $ret;
  }

	/**
	 * Method to DELETE all rows from the katao_config table.
	 *
	 * @return     int The number of affected rows (if supported by underlying database driver).
	 */
	public static function doDeleteAll($con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}
		$affectedRows = 0; // initialize var to track total num of affected rows
		try {
			// use transaction because $criteria could contain info
			// for more than one table or we could emulating ON DELETE CASCADE, etc.
			$con->begin();
			$affectedRows += BasePeer::doDeleteAll(KataoConfigPeer::TABLE_NAME, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	/**
	 * Method perform a DELETE on the database, given a KataoConfig or Criteria object OR a primary key value.
	 *
	 * @param      mixed $values Criteria or KataoConfig object or primary key or array of primary keys
	 *              which is used to create the DELETE statement
	 * @param      Connection $con the connection to use
	 * @return     int 	The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
	 *				if supported by native driver or if emulated using Propel.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	 public static function doDelete($values, $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(KataoConfigPeer::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; // rename for clarity
		} elseif ($values instanceof KataoConfig) {

			$criteria = $values->buildPkeyCriteria();
		} else {
			// it must be the primary key
			$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(KataoConfigPeer::ID, (array) $values, Criteria::IN);
		}

		// Set the correct dbName
		$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; // initialize var to track total num of affected rows

		try {
			// use transaction because $criteria could contain info
			// for more than one table or we could emulating ON DELETE CASCADE, etc.
			$con->begin();
			
			$affectedRows += BasePeer::doDelete($criteria, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	/**
	 * Validates all modified columns of given KataoConfig object.
	 * If parameter $columns is either a single column name or an array of column names
	 * than only those columns are validated.
	 *
	 * NOTICE: This does not apply to primary or foreign keys for now.
	 *
	 * @param      KataoConfig $obj The object to validate.
	 * @param      mixed $cols Column name or array of column names.
	 *
	 * @return     mixed TRUE if all columns are valid or the error message of the first invalid column.
	 */
	public static function doValidate(KataoConfig $obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(KataoConfigPeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(KataoConfigPeer::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(KataoConfigPeer::DATABASE_NAME, KataoConfigPeer::TABLE_NAME, $columns);
    if ($res !== true) {
        $request = sfContext::getInstance()->getRequest();
        foreach ($res as $failed) {
            $col = KataoConfigPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
            $request->setError($col, $failed->getMessage());
        }
    }

    return $res;
	}

	/**
	 * Retrieve a single object by pkey.
	 *
	 * @param      mixed $pk the primary key.
	 * @param      Connection $con the connection to use
	 * @return     KataoConfig
	 */
	public static function retrieveByPK($pk, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$criteria = new Criteria(KataoConfigPeer::DATABASE_NAME);

		$criteria->add(KataoConfigPeer::ID, $pk);


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

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

	/**
	 * Retrieve multiple objects by pkey.
	 *
	 * @param      array $pks List of primary keys
	 * @param      Connection $con the connection to use
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function retrieveByPKs($pks, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

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

} // BaseKataoConfigPeer

// static code to register the map builder for this Peer with the main Propel class
if (Propel::isInit()) {
	// the MapBuilder classes register themselves with Propel during initialization
	// so we need to load them here.
	try {
		BaseKataoConfigPeer::getMapBuilder();
	} catch (Exception $e) {
		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
	}
} else {
	// even if Propel is not yet initialized, the map builder class can be registered
	// now and then it will be loaded when Propel initializes.
	Propel::registerMapBuilder('lib.model.map.KataoConfigMapBuilder');
}
