<?php

/**
 * Base class that represents a row from the 'katao_user' table.
 *
 * 
 *
 * @package    lib.model.om
 */
abstract class BaseKataoUser extends BaseObject  implements Persistent {


	/**
	 * The Peer class.
	 * Instance provides a convenient way of calling static methods on a class
	 * that calling code may not be able to identify.
	 * @var        KataoUserPeer
	 */
	protected static $peer;


	/**
	 * The value for the id field.
	 * @var        int
	 */
	protected $id;


	/**
	 * The value for the katao_member_id field.
	 * @var        int
	 */
	protected $katao_member_id;


	/**
	 * The value for the katao_supplier_id field.
	 * @var        int
	 */
	protected $katao_supplier_id;


	/**
	 * The value for the status field.
	 * @var        int
	 */
	protected $status = 2;


	/**
	 * The value for the email field.
	 * @var        string
	 */
	protected $email;


	/**
	 * The value for the address1 field.
	 * @var        string
	 */
	protected $address1;


	/**
	 * The value for the address2 field.
	 * @var        string
	 */
	protected $address2;


	/**
	 * The value for the zip field.
	 * @var        string
	 */
	protected $zip;


	/**
	 * The value for the city field.
	 * @var        string
	 */
	protected $city;


	/**
	 * The value for the phone field.
	 * @var        string
	 */
	protected $phone;


	/**
	 * The value for the fax field.
	 * @var        string
	 */
	protected $fax;


	/**
	 * The value for the gmap_lng field.
	 * @var        double
	 */
	protected $gmap_lng;


	/**
	 * The value for the gmap_lat field.
	 * @var        double
	 */
	protected $gmap_lat;


	/**
	 * The value for the login field.
	 * @var        string
	 */
	protected $login;


	/**
	 * The value for the password field.
	 * @var        string
	 */
	protected $password;


	/**
	 * The value for the is_seo field.
	 * @var        int
	 */
	protected $is_seo = 0;


	/**
	 * The value for the is_admin field.
	 * @var        int
	 */
	protected $is_admin = 0;


	/**
	 * The value for the created_at field.
	 * @var        int
	 */
	protected $created_at;


	/**
	 * The value for the updated_at field.
	 * @var        int
	 */
	protected $updated_at;

	/**
	 * @var        KataoMember
	 */
	protected $aKataoMember;

	/**
	 * @var        KataoSupplier
	 */
	protected $aKataoSupplier;

	/**
	 * Collection to store aggregation of collKataoNodes.
	 * @var        array
	 */
	protected $collKataoNodes;

	/**
	 * The criteria used to select the current contents of collKataoNodes.
	 * @var        Criteria
	 */
	protected $lastKataoNodeCriteria = null;

	/**
	 * Collection to store aggregation of collKataoCarts.
	 * @var        array
	 */
	protected $collKataoCarts;

	/**
	 * The criteria used to select the current contents of collKataoCarts.
	 * @var        Criteria
	 */
	protected $lastKataoCartCriteria = null;

	/**
	 * Collection to store aggregation of collKataoMemberAdhesions.
	 * @var        array
	 */
	protected $collKataoMemberAdhesions;

	/**
	 * The criteria used to select the current contents of collKataoMemberAdhesions.
	 * @var        Criteria
	 */
	protected $lastKataoMemberAdhesionCriteria = null;

	/**
	 * Flag to prevent endless save loop, if this object is referenced
	 * by another object which falls in this transaction.
	 * @var        boolean
	 */
	protected $alreadyInSave = false;

	/**
	 * Flag to prevent endless validation loop, if this object is referenced
	 * by another object which falls in this transaction.
	 * @var        boolean
	 */
	protected $alreadyInValidation = false;

	/**
	 * Get the [id] column value.
	 * 
	 * @return     int
	 */
	public function getId()
	{

		return $this->id;
	}

	/**
	 * Get the [katao_member_id] column value.
	 * 
	 * @return     int
	 */
	public function getKataoMemberId()
	{

		return $this->katao_member_id;
	}

	/**
	 * Get the [katao_supplier_id] column value.
	 * 
	 * @return     int
	 */
	public function getKataoSupplierId()
	{

		return $this->katao_supplier_id;
	}

	/**
	 * Get the [status] column value.
	 * 
	 * @return     int
	 */
	public function getStatus()
	{

		return $this->status;
	}

	/**
	 * Get the [email] column value.
	 * 
	 * @return     string
	 */
	public function getEmail()
	{

		return $this->email;
	}

	/**
	 * Get the [address1] column value.
	 * 
	 * @return     string
	 */
	public function getAddress1()
	{

		return $this->address1;
	}

	/**
	 * Get the [address2] column value.
	 * 
	 * @return     string
	 */
	public function getAddress2()
	{

		return $this->address2;
	}

	/**
	 * Get the [zip] column value.
	 * 
	 * @return     string
	 */
	public function getZip()
	{

		return $this->zip;
	}

	/**
	 * Get the [city] column value.
	 * 
	 * @return     string
	 */
	public function getCity()
	{

		return $this->city;
	}

	/**
	 * Get the [phone] column value.
	 * 
	 * @return     string
	 */
	public function getPhone()
	{

		return $this->phone;
	}

	/**
	 * Get the [fax] column value.
	 * 
	 * @return     string
	 */
	public function getFax()
	{

		return $this->fax;
	}

	/**
	 * Get the [gmap_lng] column value.
	 * 
	 * @return     double
	 */
	public function getGmapLng()
	{

		return $this->gmap_lng;
	}

	/**
	 * Get the [gmap_lat] column value.
	 * 
	 * @return     double
	 */
	public function getGmapLat()
	{

		return $this->gmap_lat;
	}

	/**
	 * Get the [login] column value.
	 * 
	 * @return     string
	 */
	public function getLogin()
	{

		return $this->login;
	}

	/**
	 * Get the [password] column value.
	 * 
	 * @return     string
	 */
	public function getPassword()
	{

		return $this->password;
	}

	/**
	 * Get the [is_seo] column value.
	 * 
	 * @return     int
	 */
	public function getIsSeo()
	{

		return $this->is_seo;
	}

	/**
	 * Get the [is_admin] column value.
	 * 
	 * @return     int
	 */
	public function getIsAdmin()
	{

		return $this->is_admin;
	}

	/**
	 * Get the [optionally formatted] [created_at] column value.
	 * 
	 * @param      string $format The date/time format string (either date()-style or strftime()-style).
	 *							If format is NULL, then the integer unix timestamp will be returned.
	 * @return     mixed Formatted date/time value as string or integer unix timestamp (if format is NULL).
	 * @throws     PropelException - if unable to convert the date/time to timestamp.
	 */
	public function getCreatedAt($format = 'Y-m-d H:i:s')
	{

		if ($this->created_at === null || $this->created_at === '') {
			return null;
		} elseif (!is_int($this->created_at)) {
			// a non-timestamp value was set externally, so we convert it
			$ts = strtotime($this->created_at);
			if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
				throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
			}
		} else {
			$ts = $this->created_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	/**
	 * Get the [optionally formatted] [updated_at] column value.
	 * 
	 * @param      string $format The date/time format string (either date()-style or strftime()-style).
	 *							If format is NULL, then the integer unix timestamp will be returned.
	 * @return     mixed Formatted date/time value as string or integer unix timestamp (if format is NULL).
	 * @throws     PropelException - if unable to convert the date/time to timestamp.
	 */
	public function getUpdatedAt($format = 'Y-m-d H:i:s')
	{

		if ($this->updated_at === null || $this->updated_at === '') {
			return null;
		} elseif (!is_int($this->updated_at)) {
			// a non-timestamp value was set externally, so we convert it
			$ts = strtotime($this->updated_at);
			if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
				throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
			}
		} else {
			$ts = $this->updated_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	/**
	 * Set the value of [id] column.
	 * 
	 * @param      int $v new value
	 * @return     void
	 */
	public function setId($v)
	{

		// Since the native PHP type for this column is integer,
		// we will cast the input value to an int (if it is not).
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = KataoUserPeer::ID;
		}

	} // setId()

	/**
	 * Set the value of [katao_member_id] column.
	 * 
	 * @param      int $v new value
	 * @return     void
	 */
	public function setKataoMemberId($v)
	{

		// Since the native PHP type for this column is integer,
		// we will cast the input value to an int (if it is not).
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->katao_member_id !== $v) {
			$this->katao_member_id = $v;
			$this->modifiedColumns[] = KataoUserPeer::KATAO_MEMBER_ID;
		}

		if ($this->aKataoMember !== null && $this->aKataoMember->getId() !== $v) {
			$this->aKataoMember = null;
		}

	} // setKataoMemberId()

	/**
	 * Set the value of [katao_supplier_id] column.
	 * 
	 * @param      int $v new value
	 * @return     void
	 */
	public function setKataoSupplierId($v)
	{

		// Since the native PHP type for this column is integer,
		// we will cast the input value to an int (if it is not).
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->katao_supplier_id !== $v) {
			$this->katao_supplier_id = $v;
			$this->modifiedColumns[] = KataoUserPeer::KATAO_SUPPLIER_ID;
		}

		if ($this->aKataoSupplier !== null && $this->aKataoSupplier->getId() !== $v) {
			$this->aKataoSupplier = null;
		}

	} // setKataoSupplierId()

	/**
	 * Set the value of [status] column.
	 * 
	 * @param      int $v new value
	 * @return     void
	 */
	public function setStatus($v)
	{

		// Since the native PHP type for this column is integer,
		// we will cast the input value to an int (if it is not).
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->status !== $v || $v === 2) {
			$this->status = $v;
			$this->modifiedColumns[] = KataoUserPeer::STATUS;
		}

	} // setStatus()

	/**
	 * Set the value of [email] column.
	 * 
	 * @param      string $v new value
	 * @return     void
	 */
	public function setEmail($v)
	{

		// Since the native PHP type for this column is string,
		// we will cast the input to a string (if it is not).
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->email !== $v) {
			$this->email = $v;
			$this->modifiedColumns[] = KataoUserPeer::EMAIL;
		}

	} // setEmail()

	/**
	 * Set the value of [address1] column.
	 * 
	 * @param      string $v new value
	 * @return     void
	 */
	public function setAddress1($v)
	{

		// Since the native PHP type for this column is string,
		// we will cast the input to a string (if it is not).
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->address1 !== $v) {
			$this->address1 = $v;
			$this->modifiedColumns[] = KataoUserPeer::ADDRESS1;
		}

	} // setAddress1()

	/**
	 * Set the value of [address2] column.
	 * 
	 * @param      string $v new value
	 * @return     void
	 */
	public function setAddress2($v)
	{

		// Since the native PHP type for this column is string,
		// we will cast the input to a string (if it is not).
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->address2 !== $v) {
			$this->address2 = $v;
			$this->modifiedColumns[] = KataoUserPeer::ADDRESS2;
		}

	} // setAddress2()

	/**
	 * Set the value of [zip] column.
	 * 
	 * @param      string $v new value
	 * @return     void
	 */
	public function setZip($v)
	{

		// Since the native PHP type for this column is string,
		// we will cast the input to a string (if it is not).
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->zip !== $v) {
			$this->zip = $v;
			$this->modifiedColumns[] = KataoUserPeer::ZIP;
		}

	} // setZip()

	/**
	 * Set the value of [city] column.
	 * 
	 * @param      string $v new value
	 * @return     void
	 */
	public function setCity($v)
	{

		// Since the native PHP type for this column is string,
		// we will cast the input to a string (if it is not).
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->city !== $v) {
			$this->city = $v;
			$this->modifiedColumns[] = KataoUserPeer::CITY;
		}

	} // setCity()

	/**
	 * Set the value of [phone] column.
	 * 
	 * @param      string $v new value
	 * @return     void
	 */
	public function setPhone($v)
	{

		// Since the native PHP type for this column is string,
		// we will cast the input to a string (if it is not).
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->phone !== $v) {
			$this->phone = $v;
			$this->modifiedColumns[] = KataoUserPeer::PHONE;
		}

	} // setPhone()

	/**
	 * Set the value of [fax] column.
	 * 
	 * @param      string $v new value
	 * @return     void
	 */
	public function setFax($v)
	{

		// Since the native PHP type for this column is string,
		// we will cast the input to a string (if it is not).
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->fax !== $v) {
			$this->fax = $v;
			$this->modifiedColumns[] = KataoUserPeer::FAX;
		}

	} // setFax()

	/**
	 * Set the value of [gmap_lng] column.
	 * 
	 * @param      double $v new value
	 * @return     void
	 */
	public function setGmapLng($v)
	{

		if ($this->gmap_lng !== $v) {
			$this->gmap_lng = $v;
			$this->modifiedColumns[] = KataoUserPeer::GMAP_LNG;
		}

	} // setGmapLng()

	/**
	 * Set the value of [gmap_lat] column.
	 * 
	 * @param      double $v new value
	 * @return     void
	 */
	public function setGmapLat($v)
	{

		if ($this->gmap_lat !== $v) {
			$this->gmap_lat = $v;
			$this->modifiedColumns[] = KataoUserPeer::GMAP_LAT;
		}

	} // setGmapLat()

	/**
	 * Set the value of [login] column.
	 * 
	 * @param      string $v new value
	 * @return     void
	 */
	public function setLogin($v)
	{

		// Since the native PHP type for this column is string,
		// we will cast the input to a string (if it is not).
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->login !== $v) {
			$this->login = $v;
			$this->modifiedColumns[] = KataoUserPeer::LOGIN;
		}

	} // setLogin()

	/**
	 * Set the value of [password] column.
	 * 
	 * @param      string $v new value
	 * @return     void
	 */
	public function setPassword($v)
	{

		// Since the native PHP type for this column is string,
		// we will cast the input to a string (if it is not).
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->password !== $v) {
			$this->password = $v;
			$this->modifiedColumns[] = KataoUserPeer::PASSWORD;
		}

	} // setPassword()

	/**
	 * Set the value of [is_seo] column.
	 * 
	 * @param      int $v new value
	 * @return     void
	 */
	public function setIsSeo($v)
	{

		// Since the native PHP type for this column is integer,
		// we will cast the input value to an int (if it is not).
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->is_seo !== $v || $v === 0) {
			$this->is_seo = $v;
			$this->modifiedColumns[] = KataoUserPeer::IS_SEO;
		}

	} // setIsSeo()

	/**
	 * Set the value of [is_admin] column.
	 * 
	 * @param      int $v new value
	 * @return     void
	 */
	public function setIsAdmin($v)
	{

		// Since the native PHP type for this column is integer,
		// we will cast the input value to an int (if it is not).
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->is_admin !== $v || $v === 0) {
			$this->is_admin = $v;
			$this->modifiedColumns[] = KataoUserPeer::IS_ADMIN;
		}

	} // setIsAdmin()

	/**
	 * Set the value of [created_at] column.
	 * 
	 * @param      int $v new value
	 * @return     void
	 */
	public function setCreatedAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
				throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->created_at !== $ts) {
			$this->created_at = $ts;
			$this->modifiedColumns[] = KataoUserPeer::CREATED_AT;
		}

	} // setCreatedAt()

	/**
	 * Set the value of [updated_at] column.
	 * 
	 * @param      int $v new value
	 * @return     void
	 */
	public function setUpdatedAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
				throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->updated_at !== $ts) {
			$this->updated_at = $ts;
			$this->modifiedColumns[] = KataoUserPeer::UPDATED_AT;
		}

	} // setUpdatedAt()

	/**
	 * Hydrates (populates) the object variables with values from the database resultset.
	 *
	 * An offset (1-based "start column") is specified so that objects can be hydrated
	 * with a subset of the columns in the resultset rows.  This is needed, for example,
	 * for results of JOIN queries where the resultset row includes columns from two or
	 * more tables.
	 *
	 * @param      ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
	 * @param      int $startcol 1-based offset column which indicates which restultset column to start with.
	 * @return     int next starting column
	 * @throws     PropelException  - Any caught Exception will be rewrapped as a PropelException.
	 */
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->katao_member_id = $rs->getInt($startcol + 1);

			$this->katao_supplier_id = $rs->getInt($startcol + 2);

			$this->status = $rs->getInt($startcol + 3);

			$this->email = $rs->getString($startcol + 4);

			$this->address1 = $rs->getString($startcol + 5);

			$this->address2 = $rs->getString($startcol + 6);

			$this->zip = $rs->getString($startcol + 7);

			$this->city = $rs->getString($startcol + 8);

			$this->phone = $rs->getString($startcol + 9);

			$this->fax = $rs->getString($startcol + 10);

			$this->gmap_lng = $rs->getFloat($startcol + 11);

			$this->gmap_lat = $rs->getFloat($startcol + 12);

			$this->login = $rs->getString($startcol + 13);

			$this->password = $rs->getString($startcol + 14);

			$this->is_seo = $rs->getInt($startcol + 15);

			$this->is_admin = $rs->getInt($startcol + 16);

			$this->created_at = $rs->getTimestamp($startcol + 17, null);

			$this->updated_at = $rs->getTimestamp($startcol + 18, null);

			$this->resetModified();

			$this->setNew(false);

			// FIXME - using NUM_COLUMNS may be clearer.
			return $startcol + 19; // 19 = KataoUserPeer::NUM_COLUMNS - KataoUserPeer::NUM_LAZY_LOAD_COLUMNS).

		} catch (Exception $e) {
			throw new PropelException("Error populating KataoUser object", $e);
		}
	}

	/**
	 * Removes this object from datastore and sets delete attribute.
	 *
	 * @param      Connection $con
	 * @return     void
	 * @throws     PropelException
	 * @see        BaseObject::setDeleted()
	 * @see        BaseObject::isDeleted()
	 */
	public function delete($con = null)
	{

    foreach (sfMixer::getCallables('BaseKataoUser:delete:pre') as $callable)
    {
      $ret = call_user_func($callable, $this, $con);
      if ($ret)
      {
        return;
      }
    }


		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

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

		try {
			$con->begin();
			KataoUserPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	

    foreach (sfMixer::getCallables('BaseKataoUser:delete:post') as $callable)
    {
      call_user_func($callable, $this, $con);
    }

  }
	/**
	 * Stores the object in the database.  If the object is new,
	 * it inserts it; otherwise an update is performed.  This method
	 * wraps the doSave() worker method in a transaction.
	 *
	 * @param      Connection $con
	 * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
	 * @throws     PropelException
	 * @see        doSave()
	 */
	public function save($con = null)
	{

    foreach (sfMixer::getCallables('BaseKataoUser:save:pre') as $callable)
    {
      $affectedRows = call_user_func($callable, $this, $con);
      if (is_int($affectedRows))
      {
        return $affectedRows;
      }
    }


    if ($this->isNew() && !$this->isColumnModified(KataoUserPeer::CREATED_AT))
    {
      $this->setCreatedAt(time());
    }

    if ($this->isModified() && !$this->isColumnModified(KataoUserPeer::UPDATED_AT))
    {
      $this->setUpdatedAt(time());
    }

		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

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

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
    foreach (sfMixer::getCallables('BaseKataoUser:save:post') as $callable)
    {
      call_user_func($callable, $this, $con, $affectedRows);
    }

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

	/**
	 * Stores the object in the database.
	 *
	 * If the object is new, it inserts it; otherwise an update is performed.
	 * All related objects are also updated in this method.
	 *
	 * @param      Connection $con
	 * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
	 * @throws     PropelException
	 * @see        save()
	 */
	protected function doSave($con)
	{
		$affectedRows = 0; // initialize var to track total num of affected rows
		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


			// We call the save method on the following object(s) if they
			// were passed to this object by their coresponding set
			// method.  This object relates to these object(s) by a
			// foreign key reference.

			if ($this->aKataoMember !== null) {
				if ($this->aKataoMember->isModified()) {
					$affectedRows += $this->aKataoMember->save($con);
				}
				$this->setKataoMember($this->aKataoMember);
			}

			if ($this->aKataoSupplier !== null) {
				if ($this->aKataoSupplier->isModified()) {
					$affectedRows += $this->aKataoSupplier->save($con);
				}
				$this->setKataoSupplier($this->aKataoSupplier);
			}


			// If this object has been modified, then save it to the database.
			if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = KataoUserPeer::doInsert($this, $con);
					$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
										 // should always be true here (even though technically
										 // BasePeer::doInsert() can insert multiple rows).

					$this->setId($pk);  //[IMV] update autoincrement primary key

					$this->setNew(false);
				} else {
					$affectedRows += KataoUserPeer::doUpdate($this, $con);
				}
				$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
			}

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

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

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

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} // doSave()

	/**
	 * Array of ValidationFailed objects.
	 * @var        array ValidationFailed[]
	 */
	protected $validationFailures = array();

	/**
	 * Gets any ValidationFailed objects that resulted from last call to validate().
	 *
	 *
	 * @return     array ValidationFailed[]
	 * @see        validate()
	 */
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	/**
	 * Validates the objects modified field values and all objects related to this table.
	 *
	 * If $columns is either a column name or an array of column names
	 * only those columns are validated.
	 *
	 * @param      mixed $columns Column name or an array of column names.
	 * @return     boolean Whether all columns pass validation.
	 * @see        doValidate()
	 * @see        getValidationFailures()
	 */
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	/**
	 * This function performs the validation work for complex object models.
	 *
	 * In addition to checking the current object, all related objects will
	 * also be validated.  If all pass then <code>true</code> is returned; otherwise
	 * an aggreagated array of ValidationFailed objects will be returned.
	 *
	 * @param      array $columns Array of column names to validate.
	 * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
	 */
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			// We call the validate method on the following object(s) if they
			// were passed to this object by their coresponding set
			// method.  This object relates to these object(s) by a
			// foreign key reference.

			if ($this->aKataoMember !== null) {
				if (!$this->aKataoMember->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aKataoMember->getValidationFailures());
				}
			}

			if ($this->aKataoSupplier !== null) {
				if (!$this->aKataoSupplier->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aKataoSupplier->getValidationFailures());
				}
			}


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


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

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

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


			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	/**
	 * Retrieves a field from the object by name passed in as a string.
	 *
	 * @param      string $name name
	 * @param      string $type The type of fieldname the $name is of:
	 *                     one of the class type constants TYPE_PHPNAME,
	 *                     TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
	 * @return     mixed Value of field.
	 */
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = KataoUserPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	/**
	 * Retrieves a field from the object by Position as specified in the xml schema.
	 * Zero-based.
	 *
	 * @param      int $pos position in xml schema
	 * @return     mixed Value of field at $pos
	 */
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getKataoMemberId();
				break;
			case 2:
				return $this->getKataoSupplierId();
				break;
			case 3:
				return $this->getStatus();
				break;
			case 4:
				return $this->getEmail();
				break;
			case 5:
				return $this->getAddress1();
				break;
			case 6:
				return $this->getAddress2();
				break;
			case 7:
				return $this->getZip();
				break;
			case 8:
				return $this->getCity();
				break;
			case 9:
				return $this->getPhone();
				break;
			case 10:
				return $this->getFax();
				break;
			case 11:
				return $this->getGmapLng();
				break;
			case 12:
				return $this->getGmapLat();
				break;
			case 13:
				return $this->getLogin();
				break;
			case 14:
				return $this->getPassword();
				break;
			case 15:
				return $this->getIsSeo();
				break;
			case 16:
				return $this->getIsAdmin();
				break;
			case 17:
				return $this->getCreatedAt();
				break;
			case 18:
				return $this->getUpdatedAt();
				break;
			default:
				return null;
				break;
		} // switch()
	}

	/**
	 * Exports the object as an array.
	 *
	 * You can specify the key type of the array by passing one of the class
	 * type constants.
	 *
	 * @param      string $keyType One of the class type constants TYPE_PHPNAME,
	 *                        TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
	 * @return     an associative array containing the field names (as keys) and field values
	 */
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = KataoUserPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getKataoMemberId(),
			$keys[2] => $this->getKataoSupplierId(),
			$keys[3] => $this->getStatus(),
			$keys[4] => $this->getEmail(),
			$keys[5] => $this->getAddress1(),
			$keys[6] => $this->getAddress2(),
			$keys[7] => $this->getZip(),
			$keys[8] => $this->getCity(),
			$keys[9] => $this->getPhone(),
			$keys[10] => $this->getFax(),
			$keys[11] => $this->getGmapLng(),
			$keys[12] => $this->getGmapLat(),
			$keys[13] => $this->getLogin(),
			$keys[14] => $this->getPassword(),
			$keys[15] => $this->getIsSeo(),
			$keys[16] => $this->getIsAdmin(),
			$keys[17] => $this->getCreatedAt(),
			$keys[18] => $this->getUpdatedAt(),
		);
		return $result;
	}

	/**
	 * Sets a field from the object by name passed in as a string.
	 *
	 * @param      string $name peer name
	 * @param      mixed $value field value
	 * @param      string $type The type of fieldname the $name is of:
	 *                     one of the class type constants TYPE_PHPNAME,
	 *                     TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
	 * @return     void
	 */
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = KataoUserPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	/**
	 * Sets a field from the object by Position as specified in the xml schema.
	 * Zero-based.
	 *
	 * @param      int $pos position in xml schema
	 * @param      mixed $value field value
	 * @return     void
	 */
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setKataoMemberId($value);
				break;
			case 2:
				$this->setKataoSupplierId($value);
				break;
			case 3:
				$this->setStatus($value);
				break;
			case 4:
				$this->setEmail($value);
				break;
			case 5:
				$this->setAddress1($value);
				break;
			case 6:
				$this->setAddress2($value);
				break;
			case 7:
				$this->setZip($value);
				break;
			case 8:
				$this->setCity($value);
				break;
			case 9:
				$this->setPhone($value);
				break;
			case 10:
				$this->setFax($value);
				break;
			case 11:
				$this->setGmapLng($value);
				break;
			case 12:
				$this->setGmapLat($value);
				break;
			case 13:
				$this->setLogin($value);
				break;
			case 14:
				$this->setPassword($value);
				break;
			case 15:
				$this->setIsSeo($value);
				break;
			case 16:
				$this->setIsAdmin($value);
				break;
			case 17:
				$this->setCreatedAt($value);
				break;
			case 18:
				$this->setUpdatedAt($value);
				break;
		} // switch()
	}

	/**
	 * Populates the object using an array.
	 *
	 * This is particularly useful when populating an object from one of the
	 * request arrays (e.g. $_POST).  This method goes through the column
	 * names, checking to see whether a matching key exists in populated
	 * array. If so the setByName() method is called for that column.
	 *
	 * You can specify the key type of the array by additionally passing one
	 * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
	 * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
	 *
	 * @param      array  $arr     An array to populate the object from.
	 * @param      string $keyType The type of keys the array uses.
	 * @return     void
	 */
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = KataoUserPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setKataoMemberId($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setKataoSupplierId($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setStatus($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setEmail($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setAddress1($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setAddress2($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setZip($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setCity($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setPhone($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setFax($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setGmapLng($arr[$keys[11]]);
		if (array_key_exists($keys[12], $arr)) $this->setGmapLat($arr[$keys[12]]);
		if (array_key_exists($keys[13], $arr)) $this->setLogin($arr[$keys[13]]);
		if (array_key_exists($keys[14], $arr)) $this->setPassword($arr[$keys[14]]);
		if (array_key_exists($keys[15], $arr)) $this->setIsSeo($arr[$keys[15]]);
		if (array_key_exists($keys[16], $arr)) $this->setIsAdmin($arr[$keys[16]]);
		if (array_key_exists($keys[17], $arr)) $this->setCreatedAt($arr[$keys[17]]);
		if (array_key_exists($keys[18], $arr)) $this->setUpdatedAt($arr[$keys[18]]);
	}

	/**
	 * Build a Criteria object containing the values of all modified columns in this object.
	 *
	 * @return     Criteria The Criteria object containing all modified values.
	 */
	public function buildCriteria()
	{
		$criteria = new Criteria(KataoUserPeer::DATABASE_NAME);

		if ($this->isColumnModified(KataoUserPeer::ID)) $criteria->add(KataoUserPeer::ID, $this->id);
		if ($this->isColumnModified(KataoUserPeer::KATAO_MEMBER_ID)) $criteria->add(KataoUserPeer::KATAO_MEMBER_ID, $this->katao_member_id);
		if ($this->isColumnModified(KataoUserPeer::KATAO_SUPPLIER_ID)) $criteria->add(KataoUserPeer::KATAO_SUPPLIER_ID, $this->katao_supplier_id);
		if ($this->isColumnModified(KataoUserPeer::STATUS)) $criteria->add(KataoUserPeer::STATUS, $this->status);
		if ($this->isColumnModified(KataoUserPeer::EMAIL)) $criteria->add(KataoUserPeer::EMAIL, $this->email);
		if ($this->isColumnModified(KataoUserPeer::ADDRESS1)) $criteria->add(KataoUserPeer::ADDRESS1, $this->address1);
		if ($this->isColumnModified(KataoUserPeer::ADDRESS2)) $criteria->add(KataoUserPeer::ADDRESS2, $this->address2);
		if ($this->isColumnModified(KataoUserPeer::ZIP)) $criteria->add(KataoUserPeer::ZIP, $this->zip);
		if ($this->isColumnModified(KataoUserPeer::CITY)) $criteria->add(KataoUserPeer::CITY, $this->city);
		if ($this->isColumnModified(KataoUserPeer::PHONE)) $criteria->add(KataoUserPeer::PHONE, $this->phone);
		if ($this->isColumnModified(KataoUserPeer::FAX)) $criteria->add(KataoUserPeer::FAX, $this->fax);
		if ($this->isColumnModified(KataoUserPeer::GMAP_LNG)) $criteria->add(KataoUserPeer::GMAP_LNG, $this->gmap_lng);
		if ($this->isColumnModified(KataoUserPeer::GMAP_LAT)) $criteria->add(KataoUserPeer::GMAP_LAT, $this->gmap_lat);
		if ($this->isColumnModified(KataoUserPeer::LOGIN)) $criteria->add(KataoUserPeer::LOGIN, $this->login);
		if ($this->isColumnModified(KataoUserPeer::PASSWORD)) $criteria->add(KataoUserPeer::PASSWORD, $this->password);
		if ($this->isColumnModified(KataoUserPeer::IS_SEO)) $criteria->add(KataoUserPeer::IS_SEO, $this->is_seo);
		if ($this->isColumnModified(KataoUserPeer::IS_ADMIN)) $criteria->add(KataoUserPeer::IS_ADMIN, $this->is_admin);
		if ($this->isColumnModified(KataoUserPeer::CREATED_AT)) $criteria->add(KataoUserPeer::CREATED_AT, $this->created_at);
		if ($this->isColumnModified(KataoUserPeer::UPDATED_AT)) $criteria->add(KataoUserPeer::UPDATED_AT, $this->updated_at);

		return $criteria;
	}

	/**
	 * Builds a Criteria object containing the primary key for this object.
	 *
	 * Unlike buildCriteria() this method includes the primary key values regardless
	 * of whether or not they have been modified.
	 *
	 * @return     Criteria The Criteria object containing value(s) for primary key(s).
	 */
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(KataoUserPeer::DATABASE_NAME);

		$criteria->add(KataoUserPeer::ID, $this->id);

		return $criteria;
	}

	/**
	 * Returns the primary key for this object (row).
	 * @return     int
	 */
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	/**
	 * Generic method to set the primary key (id column).
	 *
	 * @param      int $key Primary key.
	 * @return     void
	 */
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	/**
	 * Sets contents of passed object to values from current object.
	 *
	 * If desired, this method can also make copies of all associated (fkey referrers)
	 * objects.
	 *
	 * @param      object $copyObj An object of KataoUser (or compatible) type.
	 * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
	 * @throws     PropelException
	 */
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setKataoMemberId($this->katao_member_id);

		$copyObj->setKataoSupplierId($this->katao_supplier_id);

		$copyObj->setStatus($this->status);

		$copyObj->setEmail($this->email);

		$copyObj->setAddress1($this->address1);

		$copyObj->setAddress2($this->address2);

		$copyObj->setZip($this->zip);

		$copyObj->setCity($this->city);

		$copyObj->setPhone($this->phone);

		$copyObj->setFax($this->fax);

		$copyObj->setGmapLng($this->gmap_lng);

		$copyObj->setGmapLat($this->gmap_lat);

		$copyObj->setLogin($this->login);

		$copyObj->setPassword($this->password);

		$copyObj->setIsSeo($this->is_seo);

		$copyObj->setIsAdmin($this->is_admin);

		$copyObj->setCreatedAt($this->created_at);

		$copyObj->setUpdatedAt($this->updated_at);


		if ($deepCopy) {
			// important: temporarily setNew(false) because this affects the behavior of
			// the getter/setter methods for fkey referrer objects.
			$copyObj->setNew(false);

			foreach($this->getKataoNodes() as $relObj) {
				$copyObj->addKataoNode($relObj->copy($deepCopy));
			}

			foreach($this->getKataoCarts() as $relObj) {
				$copyObj->addKataoCart($relObj->copy($deepCopy));
			}

			foreach($this->getKataoMemberAdhesions() as $relObj) {
				$copyObj->addKataoMemberAdhesion($relObj->copy($deepCopy));
			}

		} // if ($deepCopy)


		$copyObj->setNew(true);

		$copyObj->setId(NULL); // this is a pkey column, so set to default value

	}

	/**
	 * Makes a copy of this object that will be inserted as a new row in table when saved.
	 * It creates a new object filling in the simple attributes, but skipping any primary
	 * keys that are defined for the table.
	 *
	 * If desired, this method can also make copies of all associated (fkey referrers)
	 * objects.
	 *
	 * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
	 * @return     KataoUser Clone of current object.
	 * @throws     PropelException
	 */
	public function copy($deepCopy = false)
	{
		// we use get_class(), because this might be a subclass
		$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	/**
	 * Returns a peer instance associated with this om.
	 *
	 * Since Peer classes are not to have any instance attributes, this method returns the
	 * same instance for all member of this class. The method could therefore
	 * be static, but this would prevent one from overriding the behavior.
	 *
	 * @return     KataoUserPeer
	 */
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new KataoUserPeer();
		}
		return self::$peer;
	}

	/**
	 * Declares an association between this object and a KataoMember object.
	 *
	 * @param      KataoMember $v
	 * @return     void
	 * @throws     PropelException
	 */
	public function setKataoMember($v)
	{


		if ($v === null) {
			$this->setKataoMemberId(NULL);
		} else {
			$this->setKataoMemberId($v->getId());
		}


		$this->aKataoMember = $v;
	}


	/**
	 * Get the associated KataoMember object
	 *
	 * @param      Connection Optional Connection object.
	 * @return     KataoMember The associated KataoMember object.
	 * @throws     PropelException
	 */
	public function getKataoMember($con = null)
	{
		if ($this->aKataoMember === null && ($this->katao_member_id !== null)) {
			// include the related Peer class
			$this->aKataoMember = KataoMemberPeer::retrieveByPK($this->katao_member_id, $con);

			/* The following can be used instead of the line above to
			   guarantee the related object contains a reference
			   to this object, but this level of coupling
			   may be undesirable in many circumstances.
			   As it can lead to a db query with many results that may
			   never be used.
			   $obj = KataoMemberPeer::retrieveByPK($this->katao_member_id, $con);
			   $obj->addKataoMembers($this);
			 */
		}
		return $this->aKataoMember;
	}

	/**
	 * Declares an association between this object and a KataoSupplier object.
	 *
	 * @param      KataoSupplier $v
	 * @return     void
	 * @throws     PropelException
	 */
	public function setKataoSupplier($v)
	{


		if ($v === null) {
			$this->setKataoSupplierId(NULL);
		} else {
			$this->setKataoSupplierId($v->getId());
		}


		$this->aKataoSupplier = $v;
	}


	/**
	 * Get the associated KataoSupplier object
	 *
	 * @param      Connection Optional Connection object.
	 * @return     KataoSupplier The associated KataoSupplier object.
	 * @throws     PropelException
	 */
	public function getKataoSupplier($con = null)
	{
		if ($this->aKataoSupplier === null && ($this->katao_supplier_id !== null)) {
			// include the related Peer class
			$this->aKataoSupplier = KataoSupplierPeer::retrieveByPK($this->katao_supplier_id, $con);

			/* The following can be used instead of the line above to
			   guarantee the related object contains a reference
			   to this object, but this level of coupling
			   may be undesirable in many circumstances.
			   As it can lead to a db query with many results that may
			   never be used.
			   $obj = KataoSupplierPeer::retrieveByPK($this->katao_supplier_id, $con);
			   $obj->addKataoSuppliers($this);
			 */
		}
		return $this->aKataoSupplier;
	}

	/**
	 * Temporary storage of collKataoNodes to save a possible db hit in
	 * the event objects are add to the collection, but the
	 * complete collection is never requested.
	 * @return     void
	 */
	public function initKataoNodes()
	{
		if ($this->collKataoNodes === null) {
			$this->collKataoNodes = array();
		}
	}

	/**
	 * If this collection has already been initialized with
	 * an identical criteria, it returns the collection.
	 * Otherwise if this KataoUser has previously
	 * been saved, it will retrieve related KataoNodes from storage.
	 * If this KataoUser is new, it will return
	 * an empty collection or the current collection, the criteria
	 * is ignored on a new object.
	 *
	 * @param      Connection $con
	 * @param      Criteria $criteria
	 * @throws     PropelException
	 */
	public function getKataoNodes($criteria = null, $con = null)
	{
		// include the Peer class
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

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

				$criteria->add(KataoNodePeer::RESPONSIBLE, $this->getId());

				KataoNodePeer::addSelectColumns($criteria);
				$this->collKataoNodes = KataoNodePeer::doSelect($criteria, $con);
			}
		} else {
			// criteria has no effect for a new object
			if (!$this->isNew()) {
				// the following code is to determine if a new query is
				// called for.  If the criteria is the same as the last
				// one, just return the collection.


				$criteria->add(KataoNodePeer::RESPONSIBLE, $this->getId());

				KataoNodePeer::addSelectColumns($criteria);
				if (!isset($this->lastKataoNodeCriteria) || !$this->lastKataoNodeCriteria->equals($criteria)) {
					$this->collKataoNodes = KataoNodePeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastKataoNodeCriteria = $criteria;
		return $this->collKataoNodes;
	}

	/**
	 * Returns the number of related KataoNodes.
	 *
	 * @param      Criteria $criteria
	 * @param      boolean $distinct
	 * @param      Connection $con
	 * @throws     PropelException
	 */
	public function countKataoNodes($criteria = null, $distinct = false, $con = null)
	{
		// include the Peer class
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(KataoNodePeer::RESPONSIBLE, $this->getId());

		return KataoNodePeer::doCount($criteria, $distinct, $con);
	}

	/**
	 * Method called to associate a KataoNode object to this object
	 * through the KataoNode foreign key attribute
	 *
	 * @param      KataoNode $l KataoNode
	 * @return     void
	 * @throws     PropelException
	 */
	public function addKataoNode(KataoNode $l)
	{
		$this->collKataoNodes[] = $l;
		$l->setKataoUser($this);
	}

	/**
	 * Temporary storage of collKataoCarts to save a possible db hit in
	 * the event objects are add to the collection, but the
	 * complete collection is never requested.
	 * @return     void
	 */
	public function initKataoCarts()
	{
		if ($this->collKataoCarts === null) {
			$this->collKataoCarts = array();
		}
	}

	/**
	 * If this collection has already been initialized with
	 * an identical criteria, it returns the collection.
	 * Otherwise if this KataoUser has previously
	 * been saved, it will retrieve related KataoCarts from storage.
	 * If this KataoUser is new, it will return
	 * an empty collection or the current collection, the criteria
	 * is ignored on a new object.
	 *
	 * @param      Connection $con
	 * @param      Criteria $criteria
	 * @throws     PropelException
	 */
	public function getKataoCarts($criteria = null, $con = null)
	{
		// include the Peer class
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

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

				$criteria->add(KataoCartPeer::KATAO_USER_ID, $this->getId());

				KataoCartPeer::addSelectColumns($criteria);
				$this->collKataoCarts = KataoCartPeer::doSelect($criteria, $con);
			}
		} else {
			// criteria has no effect for a new object
			if (!$this->isNew()) {
				// the following code is to determine if a new query is
				// called for.  If the criteria is the same as the last
				// one, just return the collection.


				$criteria->add(KataoCartPeer::KATAO_USER_ID, $this->getId());

				KataoCartPeer::addSelectColumns($criteria);
				if (!isset($this->lastKataoCartCriteria) || !$this->lastKataoCartCriteria->equals($criteria)) {
					$this->collKataoCarts = KataoCartPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastKataoCartCriteria = $criteria;
		return $this->collKataoCarts;
	}

	/**
	 * Returns the number of related KataoCarts.
	 *
	 * @param      Criteria $criteria
	 * @param      boolean $distinct
	 * @param      Connection $con
	 * @throws     PropelException
	 */
	public function countKataoCarts($criteria = null, $distinct = false, $con = null)
	{
		// include the Peer class
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(KataoCartPeer::KATAO_USER_ID, $this->getId());

		return KataoCartPeer::doCount($criteria, $distinct, $con);
	}

	/**
	 * Method called to associate a KataoCart object to this object
	 * through the KataoCart foreign key attribute
	 *
	 * @param      KataoCart $l KataoCart
	 * @return     void
	 * @throws     PropelException
	 */
	public function addKataoCart(KataoCart $l)
	{
		$this->collKataoCarts[] = $l;
		$l->setKataoUser($this);
	}


	/**
	 * If this collection has already been initialized with
	 * an identical criteria, it returns the collection.
	 * Otherwise if this KataoUser is new, it will return
	 * an empty collection; or if this KataoUser has previously
	 * been saved, it will retrieve related KataoCarts from storage.
	 *
	 * This method is protected by default in order to keep the public
	 * api reasonable.  You can provide public methods for those you
	 * actually need in KataoUser.
	 */
	public function getKataoCartsJoinKataoPeriod($criteria = null, $con = null)
	{
		// include the Peer class
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

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

				$criteria->add(KataoCartPeer::KATAO_USER_ID, $this->getId());

				$this->collKataoCarts = KataoCartPeer::doSelectJoinKataoPeriod($criteria, $con);
			}
		} else {
			// the following code is to determine if a new query is
			// called for.  If the criteria is the same as the last
			// one, just return the collection.

			$criteria->add(KataoCartPeer::KATAO_USER_ID, $this->getId());

			if (!isset($this->lastKataoCartCriteria) || !$this->lastKataoCartCriteria->equals($criteria)) {
				$this->collKataoCarts = KataoCartPeer::doSelectJoinKataoPeriod($criteria, $con);
			}
		}
		$this->lastKataoCartCriteria = $criteria;

		return $this->collKataoCarts;
	}


	/**
	 * If this collection has already been initialized with
	 * an identical criteria, it returns the collection.
	 * Otherwise if this KataoUser is new, it will return
	 * an empty collection; or if this KataoUser has previously
	 * been saved, it will retrieve related KataoCarts from storage.
	 *
	 * This method is protected by default in order to keep the public
	 * api reasonable.  You can provide public methods for those you
	 * actually need in KataoUser.
	 */
	public function getKataoCartsJoinKataoNode($criteria = null, $con = null)
	{
		// include the Peer class
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

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

				$criteria->add(KataoCartPeer::KATAO_USER_ID, $this->getId());

				$this->collKataoCarts = KataoCartPeer::doSelectJoinKataoNode($criteria, $con);
			}
		} else {
			// the following code is to determine if a new query is
			// called for.  If the criteria is the same as the last
			// one, just return the collection.

			$criteria->add(KataoCartPeer::KATAO_USER_ID, $this->getId());

			if (!isset($this->lastKataoCartCriteria) || !$this->lastKataoCartCriteria->equals($criteria)) {
				$this->collKataoCarts = KataoCartPeer::doSelectJoinKataoNode($criteria, $con);
			}
		}
		$this->lastKataoCartCriteria = $criteria;

		return $this->collKataoCarts;
	}

	/**
	 * Temporary storage of collKataoMemberAdhesions to save a possible db hit in
	 * the event objects are add to the collection, but the
	 * complete collection is never requested.
	 * @return     void
	 */
	public function initKataoMemberAdhesions()
	{
		if ($this->collKataoMemberAdhesions === null) {
			$this->collKataoMemberAdhesions = array();
		}
	}

	/**
	 * If this collection has already been initialized with
	 * an identical criteria, it returns the collection.
	 * Otherwise if this KataoUser has previously
	 * been saved, it will retrieve related KataoMemberAdhesions from storage.
	 * If this KataoUser is new, it will return
	 * an empty collection or the current collection, the criteria
	 * is ignored on a new object.
	 *
	 * @param      Connection $con
	 * @param      Criteria $criteria
	 * @throws     PropelException
	 */
	public function getKataoMemberAdhesions($criteria = null, $con = null)
	{
		// include the Peer class
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

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

				$criteria->add(KataoMemberAdhesionPeer::KATAO_USER_ID, $this->getId());

				KataoMemberAdhesionPeer::addSelectColumns($criteria);
				$this->collKataoMemberAdhesions = KataoMemberAdhesionPeer::doSelect($criteria, $con);
			}
		} else {
			// criteria has no effect for a new object
			if (!$this->isNew()) {
				// the following code is to determine if a new query is
				// called for.  If the criteria is the same as the last
				// one, just return the collection.


				$criteria->add(KataoMemberAdhesionPeer::KATAO_USER_ID, $this->getId());

				KataoMemberAdhesionPeer::addSelectColumns($criteria);
				if (!isset($this->lastKataoMemberAdhesionCriteria) || !$this->lastKataoMemberAdhesionCriteria->equals($criteria)) {
					$this->collKataoMemberAdhesions = KataoMemberAdhesionPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastKataoMemberAdhesionCriteria = $criteria;
		return $this->collKataoMemberAdhesions;
	}

	/**
	 * Returns the number of related KataoMemberAdhesions.
	 *
	 * @param      Criteria $criteria
	 * @param      boolean $distinct
	 * @param      Connection $con
	 * @throws     PropelException
	 */
	public function countKataoMemberAdhesions($criteria = null, $distinct = false, $con = null)
	{
		// include the Peer class
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(KataoMemberAdhesionPeer::KATAO_USER_ID, $this->getId());

		return KataoMemberAdhesionPeer::doCount($criteria, $distinct, $con);
	}

	/**
	 * Method called to associate a KataoMemberAdhesion object to this object
	 * through the KataoMemberAdhesion foreign key attribute
	 *
	 * @param      KataoMemberAdhesion $l KataoMemberAdhesion
	 * @return     void
	 * @throws     PropelException
	 */
	public function addKataoMemberAdhesion(KataoMemberAdhesion $l)
	{
		$this->collKataoMemberAdhesions[] = $l;
		$l->setKataoUser($this);
	}


  public function __call($method, $arguments)
  {
    if (!$callable = sfMixer::getCallable('BaseKataoUser:'.$method))
    {
      throw new sfException(sprintf('Call to undefined method BaseKataoUser::%s', $method));
    }

    array_unshift($arguments, $this);

    return call_user_func_array($callable, $arguments);
  }


} // BaseKataoUser
