Accessory instance. If
+ * obj is an instance of Accessory, delegates to
+ * equals(Accessory). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Accessory The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Accessory The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [accessory] column value.
+ *
+ * @return int
+ */
+ public function getAccessory()
+ {
+
+ return $this->accessory;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Accessory The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AccessoryTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Accessory The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = AccessoryTableMap::PRODUCT_ID;
+ }
+
+ if ($this->aProductRelatedByProductId !== null && $this->aProductRelatedByProductId->getId() !== $v) {
+ $this->aProductRelatedByProductId = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [accessory] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Accessory The current object (for fluent API support)
+ */
+ public function setAccessory($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->accessory !== $v) {
+ $this->accessory = $v;
+ $this->modifiedColumns[] = AccessoryTableMap::ACCESSORY;
+ }
+
+ if ($this->aProductRelatedByAccessory !== null && $this->aProductRelatedByAccessory->getId() !== $v) {
+ $this->aProductRelatedByAccessory = null;
+ }
+
+
+ return $this;
+ } // setAccessory()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Accessory The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = AccessoryTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Accessory The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = AccessoryTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Accessory The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = AccessoryTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AccessoryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AccessoryTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->product_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AccessoryTableMap::translateFieldName('Accessory', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->accessory = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AccessoryTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AccessoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AccessoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = AccessoryTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Accessory object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aProductRelatedByProductId !== null && $this->product_id !== $this->aProductRelatedByProductId->getId()) {
+ $this->aProductRelatedByProductId = null;
+ }
+ if ($this->aProductRelatedByAccessory !== null && $this->accessory !== $this->aProductRelatedByAccessory->getId()) {
+ $this->aProductRelatedByAccessory = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AccessoryTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildAccessoryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aProductRelatedByProductId = null;
+ $this->aProductRelatedByAccessory = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Accessory::setDeleted()
+ * @see Accessory::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AccessoryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildAccessoryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AccessoryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(AccessoryTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(AccessoryTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(AccessoryTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AccessoryTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProductRelatedByProductId !== null) {
+ if ($this->aProductRelatedByProductId->isModified() || $this->aProductRelatedByProductId->isNew()) {
+ $affectedRows += $this->aProductRelatedByProductId->save($con);
+ }
+ $this->setProductRelatedByProductId($this->aProductRelatedByProductId);
+ }
+
+ if ($this->aProductRelatedByAccessory !== null) {
+ if ($this->aProductRelatedByAccessory->isModified() || $this->aProductRelatedByAccessory->isNew()) {
+ $affectedRows += $this->aProductRelatedByAccessory->save($con);
+ }
+ $this->setProductRelatedByAccessory($this->aProductRelatedByAccessory);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AccessoryTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(AccessoryTableMap::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'PRODUCT_ID';
+ }
+ if ($this->isColumnModified(AccessoryTableMap::ACCESSORY)) {
+ $modifiedColumns[':p' . $index++] = 'ACCESSORY';
+ }
+ if ($this->isColumnModified(AccessoryTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(AccessoryTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(AccessoryTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO accessory (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'PRODUCT_ID':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case 'ACCESSORY':
+ $stmt->bindValue($identifier, $this->accessory, PDO::PARAM_INT);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AccessoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getProductId();
+ break;
+ case 2:
+ return $this->getAccessory();
+ break;
+ case 3:
+ return $this->getPosition();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Accessory'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Accessory'][$this->getPrimaryKey()] = true;
+ $keys = AccessoryTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getProductId(),
+ $keys[2] => $this->getAccessory(),
+ $keys[3] => $this->getPosition(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aProductRelatedByProductId) {
+ $result['ProductRelatedByProductId'] = $this->aProductRelatedByProductId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aProductRelatedByAccessory) {
+ $result['ProductRelatedByAccessory'] = $this->aProductRelatedByAccessory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AccessoryTableMap::translateFieldName($name, $type, TableMap::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->setProductId($value);
+ break;
+ case 2:
+ $this->setAccessory($value);
+ break;
+ case 3:
+ $this->setPosition($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = AccessoryTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setAccessory($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(AccessoryTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(AccessoryTableMap::ID)) $criteria->add(AccessoryTableMap::ID, $this->id);
+ if ($this->isColumnModified(AccessoryTableMap::PRODUCT_ID)) $criteria->add(AccessoryTableMap::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(AccessoryTableMap::ACCESSORY)) $criteria->add(AccessoryTableMap::ACCESSORY, $this->accessory);
+ if ($this->isColumnModified(AccessoryTableMap::POSITION)) $criteria->add(AccessoryTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(AccessoryTableMap::CREATED_AT)) $criteria->add(AccessoryTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AccessoryTableMap::UPDATED_AT)) $criteria->add(AccessoryTableMap::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(AccessoryTableMap::DATABASE_NAME);
+ $criteria->add(AccessoryTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Accessory (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setAccessory($this->getAccessory());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\Accessory 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildProduct object.
+ *
+ * @param ChildProduct $v
+ * @return \Thelia\Model\Accessory The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProductRelatedByProductId(ChildProduct $v = null)
+ {
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
+ }
+
+ $this->aProductRelatedByProductId = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildProduct object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAccessoryRelatedByProductId($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildProduct object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildProduct The associated ChildProduct object.
+ * @throws PropelException
+ */
+ public function getProductRelatedByProductId(ConnectionInterface $con = null)
+ {
+ if ($this->aProductRelatedByProductId === null && ($this->product_id !== null)) {
+ $this->aProductRelatedByProductId = ChildProductQuery::create()->findPk($this->product_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aProductRelatedByProductId->addAccessoriesRelatedByProductId($this);
+ */
+ }
+
+ return $this->aProductRelatedByProductId;
+ }
+
+ /**
+ * Declares an association between this object and a ChildProduct object.
+ *
+ * @param ChildProduct $v
+ * @return \Thelia\Model\Accessory The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProductRelatedByAccessory(ChildProduct $v = null)
+ {
+ if ($v === null) {
+ $this->setAccessory(NULL);
+ } else {
+ $this->setAccessory($v->getId());
+ }
+
+ $this->aProductRelatedByAccessory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildProduct object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAccessoryRelatedByAccessory($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildProduct object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildProduct The associated ChildProduct object.
+ * @throws PropelException
+ */
+ public function getProductRelatedByAccessory(ConnectionInterface $con = null)
+ {
+ if ($this->aProductRelatedByAccessory === null && ($this->accessory !== null)) {
+ $this->aProductRelatedByAccessory = ChildProductQuery::create()->findPk($this->accessory, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aProductRelatedByAccessory->addAccessoriesRelatedByAccessory($this);
+ */
+ }
+
+ return $this->aProductRelatedByAccessory;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->product_id = null;
+ $this->accessory = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aProductRelatedByProductId = null;
+ $this->aProductRelatedByAccessory = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AccessoryTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildAccessory The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = AccessoryTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/AccessoryQuery.php b/core/lib/Thelia/Model/Base/AccessoryQuery.php
new file mode 100644
index 000000000..82bb03a70
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AccessoryQuery.php
@@ -0,0 +1,804 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAccessory|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AccessoryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AccessoryTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAccessory A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, PRODUCT_ID, ACCESSORY, POSITION, CREATED_AT, UPDATED_AT FROM accessory WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildAccessory();
+ $obj->hydrate($row);
+ AccessoryTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAccessory|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AccessoryTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AccessoryTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(AccessoryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(AccessoryTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AccessoryTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProductRelatedByProductId()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(AccessoryTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(AccessoryTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AccessoryTableMap::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the accessory column
+ *
+ * Example usage:
+ *
+ * $query->filterByAccessory(1234); // WHERE accessory = 1234
+ * $query->filterByAccessory(array(12, 34)); // WHERE accessory IN (12, 34)
+ * $query->filterByAccessory(array('min' => 12)); // WHERE accessory > 12
+ *
+ *
+ * @see filterByProductRelatedByAccessory()
+ *
+ * @param mixed $accessory The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function filterByAccessory($accessory = null, $comparison = null)
+ {
+ if (is_array($accessory)) {
+ $useMinMax = false;
+ if (isset($accessory['min'])) {
+ $this->addUsingAlias(AccessoryTableMap::ACCESSORY, $accessory['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($accessory['max'])) {
+ $this->addUsingAlias(AccessoryTableMap::ACCESSORY, $accessory['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AccessoryTableMap::ACCESSORY, $accessory, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(AccessoryTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(AccessoryTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AccessoryTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AccessoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AccessoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AccessoryTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AccessoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AccessoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AccessoryTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Product object
+ *
+ * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function filterByProductRelatedByProductId($product, $comparison = null)
+ {
+ if ($product instanceof \Thelia\Model\Product) {
+ return $this
+ ->addUsingAlias(AccessoryTableMap::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AccessoryTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByProductRelatedByProductId() only accepts arguments of type \Thelia\Model\Product or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ProductRelatedByProductId relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function joinProductRelatedByProductId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ProductRelatedByProductId');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ProductRelatedByProductId');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ProductRelatedByProductId relation Product object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
+ */
+ public function useProductRelatedByProductIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinProductRelatedByProductId($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ProductRelatedByProductId', '\Thelia\Model\ProductQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Product object
+ *
+ * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function filterByProductRelatedByAccessory($product, $comparison = null)
+ {
+ if ($product instanceof \Thelia\Model\Product) {
+ return $this
+ ->addUsingAlias(AccessoryTableMap::ACCESSORY, $product->getId(), $comparison);
+ } elseif ($product instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AccessoryTableMap::ACCESSORY, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByProductRelatedByAccessory() only accepts arguments of type \Thelia\Model\Product or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ProductRelatedByAccessory relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function joinProductRelatedByAccessory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ProductRelatedByAccessory');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ProductRelatedByAccessory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ProductRelatedByAccessory relation Product object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
+ */
+ public function useProductRelatedByAccessoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinProductRelatedByAccessory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ProductRelatedByAccessory', '\Thelia\Model\ProductQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildAccessory $accessory Object to remove from the list of results
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function prune($accessory = null)
+ {
+ if ($accessory) {
+ $this->addUsingAlias(AccessoryTableMap::ID, $accessory->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the accessory table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AccessoryTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ AccessoryTableMap::clearInstancePool();
+ AccessoryTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildAccessory or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildAccessory object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AccessoryTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(AccessoryTableMap::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->beginTransaction();
+
+
+ AccessoryTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ AccessoryTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AccessoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AccessoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AccessoryTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AccessoryTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AccessoryTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildAccessoryQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AccessoryTableMap::CREATED_AT);
+ }
+
+} // AccessoryQuery
diff --git a/core/lib/Thelia/Model/Base/Address.php b/core/lib/Thelia/Model/Base/Address.php
new file mode 100644
index 000000000..fe734960b
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Address.php
@@ -0,0 +1,2133 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Address instance. If
+ * obj is an instance of Address, delegates to
+ * equals(Address). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Address The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Address The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [customer_id] column value.
+ *
+ * @return int
+ */
+ public function getCustomerId()
+ {
+
+ return $this->customer_id;
+ }
+
+ /**
+ * Get the [customer_title_id] column value.
+ *
+ * @return int
+ */
+ public function getCustomerTitleId()
+ {
+
+ return $this->customer_title_id;
+ }
+
+ /**
+ * Get the [company] column value.
+ *
+ * @return string
+ */
+ public function getCompany()
+ {
+
+ return $this->company;
+ }
+
+ /**
+ * Get the [firstname] column value.
+ *
+ * @return string
+ */
+ public function getFirstname()
+ {
+
+ return $this->firstname;
+ }
+
+ /**
+ * Get the [lastname] column value.
+ *
+ * @return string
+ */
+ public function getLastname()
+ {
+
+ return $this->lastname;
+ }
+
+ /**
+ * 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 [address3] column value.
+ *
+ * @return string
+ */
+ public function getAddress3()
+ {
+
+ return $this->address3;
+ }
+
+ /**
+ * Get the [zipcode] column value.
+ *
+ * @return string
+ */
+ public function getZipcode()
+ {
+
+ return $this->zipcode;
+ }
+
+ /**
+ * Get the [city] column value.
+ *
+ * @return string
+ */
+ public function getCity()
+ {
+
+ return $this->city;
+ }
+
+ /**
+ * Get the [country_id] column value.
+ *
+ * @return int
+ */
+ public function getCountryId()
+ {
+
+ return $this->country_id;
+ }
+
+ /**
+ * Get the [phone] column value.
+ *
+ * @return string
+ */
+ public function getPhone()
+ {
+
+ return $this->phone;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AddressTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = AddressTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [customer_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setCustomerId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_id !== $v) {
+ $this->customer_id = $v;
+ $this->modifiedColumns[] = AddressTableMap::CUSTOMER_ID;
+ }
+
+ if ($this->aCustomer !== null && $this->aCustomer->getId() !== $v) {
+ $this->aCustomer = null;
+ }
+
+
+ return $this;
+ } // setCustomerId()
+
+ /**
+ * Set the value of [customer_title_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setCustomerTitleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_title_id !== $v) {
+ $this->customer_title_id = $v;
+ $this->modifiedColumns[] = AddressTableMap::CUSTOMER_TITLE_ID;
+ }
+
+ if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) {
+ $this->aCustomerTitle = null;
+ }
+
+
+ return $this;
+ } // setCustomerTitleId()
+
+ /**
+ * Set the value of [company] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setCompany($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->company !== $v) {
+ $this->company = $v;
+ $this->modifiedColumns[] = AddressTableMap::COMPANY;
+ }
+
+
+ return $this;
+ } // setCompany()
+
+ /**
+ * Set the value of [firstname] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setFirstname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->firstname !== $v) {
+ $this->firstname = $v;
+ $this->modifiedColumns[] = AddressTableMap::FIRSTNAME;
+ }
+
+
+ return $this;
+ } // setFirstname()
+
+ /**
+ * Set the value of [lastname] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setLastname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lastname !== $v) {
+ $this->lastname = $v;
+ $this->modifiedColumns[] = AddressTableMap::LASTNAME;
+ }
+
+
+ return $this;
+ } // setLastname()
+
+ /**
+ * Set the value of [address1] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setAddress1($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address1 !== $v) {
+ $this->address1 = $v;
+ $this->modifiedColumns[] = AddressTableMap::ADDRESS1;
+ }
+
+
+ return $this;
+ } // setAddress1()
+
+ /**
+ * Set the value of [address2] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setAddress2($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address2 !== $v) {
+ $this->address2 = $v;
+ $this->modifiedColumns[] = AddressTableMap::ADDRESS2;
+ }
+
+
+ return $this;
+ } // setAddress2()
+
+ /**
+ * Set the value of [address3] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setAddress3($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address3 !== $v) {
+ $this->address3 = $v;
+ $this->modifiedColumns[] = AddressTableMap::ADDRESS3;
+ }
+
+
+ return $this;
+ } // setAddress3()
+
+ /**
+ * Set the value of [zipcode] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setZipcode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->zipcode !== $v) {
+ $this->zipcode = $v;
+ $this->modifiedColumns[] = AddressTableMap::ZIPCODE;
+ }
+
+
+ return $this;
+ } // setZipcode()
+
+ /**
+ * Set the value of [city] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setCity($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->city !== $v) {
+ $this->city = $v;
+ $this->modifiedColumns[] = AddressTableMap::CITY;
+ }
+
+
+ return $this;
+ } // setCity()
+
+ /**
+ * Set the value of [country_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setCountryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->country_id !== $v) {
+ $this->country_id = $v;
+ $this->modifiedColumns[] = AddressTableMap::COUNTRY_ID;
+ }
+
+
+ return $this;
+ } // setCountryId()
+
+ /**
+ * Set the value of [phone] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setPhone($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->phone !== $v) {
+ $this->phone = $v;
+ $this->modifiedColumns[] = AddressTableMap::PHONE;
+ }
+
+
+ return $this;
+ } // setPhone()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = AddressTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = AddressTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AddressTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AddressTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AddressTableMap::translateFieldName('CustomerId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->customer_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AddressTableMap::translateFieldName('CustomerTitleId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->customer_title_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AddressTableMap::translateFieldName('Company', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->company = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AddressTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->firstname = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : AddressTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->lastname = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : AddressTableMap::translateFieldName('Address1', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->address1 = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : AddressTableMap::translateFieldName('Address2', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->address2 = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : AddressTableMap::translateFieldName('Address3', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->address3 = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : AddressTableMap::translateFieldName('Zipcode', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->zipcode = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : AddressTableMap::translateFieldName('City', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->city = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : AddressTableMap::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->country_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : AddressTableMap::translateFieldName('Phone', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->phone = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : AddressTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : AddressTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 16; // 16 = AddressTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Address object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) {
+ $this->aCustomer = null;
+ }
+ if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) {
+ $this->aCustomerTitle = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AddressTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildAddressQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCustomer = null;
+ $this->aCustomerTitle = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Address::setDeleted()
+ * @see Address::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AddressTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildAddressQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AddressTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(AddressTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(AddressTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(AddressTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AddressTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCustomer !== null) {
+ if ($this->aCustomer->isModified() || $this->aCustomer->isNew()) {
+ $affectedRows += $this->aCustomer->save($con);
+ }
+ $this->setCustomer($this->aCustomer);
+ }
+
+ if ($this->aCustomerTitle !== null) {
+ if ($this->aCustomerTitle->isModified() || $this->aCustomerTitle->isNew()) {
+ $affectedRows += $this->aCustomerTitle->save($con);
+ }
+ $this->setCustomerTitle($this->aCustomerTitle);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AddressTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AddressTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AddressTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(AddressTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(AddressTableMap::CUSTOMER_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID';
+ }
+ if ($this->isColumnModified(AddressTableMap::CUSTOMER_TITLE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CUSTOMER_TITLE_ID';
+ }
+ if ($this->isColumnModified(AddressTableMap::COMPANY)) {
+ $modifiedColumns[':p' . $index++] = 'COMPANY';
+ }
+ if ($this->isColumnModified(AddressTableMap::FIRSTNAME)) {
+ $modifiedColumns[':p' . $index++] = 'FIRSTNAME';
+ }
+ if ($this->isColumnModified(AddressTableMap::LASTNAME)) {
+ $modifiedColumns[':p' . $index++] = 'LASTNAME';
+ }
+ if ($this->isColumnModified(AddressTableMap::ADDRESS1)) {
+ $modifiedColumns[':p' . $index++] = 'ADDRESS1';
+ }
+ if ($this->isColumnModified(AddressTableMap::ADDRESS2)) {
+ $modifiedColumns[':p' . $index++] = 'ADDRESS2';
+ }
+ if ($this->isColumnModified(AddressTableMap::ADDRESS3)) {
+ $modifiedColumns[':p' . $index++] = 'ADDRESS3';
+ }
+ if ($this->isColumnModified(AddressTableMap::ZIPCODE)) {
+ $modifiedColumns[':p' . $index++] = 'ZIPCODE';
+ }
+ if ($this->isColumnModified(AddressTableMap::CITY)) {
+ $modifiedColumns[':p' . $index++] = 'CITY';
+ }
+ if ($this->isColumnModified(AddressTableMap::COUNTRY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'COUNTRY_ID';
+ }
+ if ($this->isColumnModified(AddressTableMap::PHONE)) {
+ $modifiedColumns[':p' . $index++] = 'PHONE';
+ }
+ if ($this->isColumnModified(AddressTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(AddressTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO address (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'CUSTOMER_ID':
+ $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
+ break;
+ case 'CUSTOMER_TITLE_ID':
+ $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT);
+ break;
+ case 'COMPANY':
+ $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR);
+ break;
+ case 'FIRSTNAME':
+ $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR);
+ break;
+ case 'LASTNAME':
+ $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR);
+ break;
+ case 'ADDRESS1':
+ $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR);
+ break;
+ case 'ADDRESS2':
+ $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR);
+ break;
+ case 'ADDRESS3':
+ $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR);
+ break;
+ case 'ZIPCODE':
+ $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR);
+ break;
+ case 'CITY':
+ $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR);
+ break;
+ case 'COUNTRY_ID':
+ $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT);
+ break;
+ case 'PHONE':
+ $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AddressTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getTitle();
+ break;
+ case 2:
+ return $this->getCustomerId();
+ break;
+ case 3:
+ return $this->getCustomerTitleId();
+ break;
+ case 4:
+ return $this->getCompany();
+ break;
+ case 5:
+ return $this->getFirstname();
+ break;
+ case 6:
+ return $this->getLastname();
+ break;
+ case 7:
+ return $this->getAddress1();
+ break;
+ case 8:
+ return $this->getAddress2();
+ break;
+ case 9:
+ return $this->getAddress3();
+ break;
+ case 10:
+ return $this->getZipcode();
+ break;
+ case 11:
+ return $this->getCity();
+ break;
+ case 12:
+ return $this->getCountryId();
+ break;
+ case 13:
+ return $this->getPhone();
+ break;
+ case 14:
+ return $this->getCreatedAt();
+ break;
+ case 15:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Address'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Address'][$this->getPrimaryKey()] = true;
+ $keys = AddressTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getTitle(),
+ $keys[2] => $this->getCustomerId(),
+ $keys[3] => $this->getCustomerTitleId(),
+ $keys[4] => $this->getCompany(),
+ $keys[5] => $this->getFirstname(),
+ $keys[6] => $this->getLastname(),
+ $keys[7] => $this->getAddress1(),
+ $keys[8] => $this->getAddress2(),
+ $keys[9] => $this->getAddress3(),
+ $keys[10] => $this->getZipcode(),
+ $keys[11] => $this->getCity(),
+ $keys[12] => $this->getCountryId(),
+ $keys[13] => $this->getPhone(),
+ $keys[14] => $this->getCreatedAt(),
+ $keys[15] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCustomer) {
+ $result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCustomerTitle) {
+ $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AddressTableMap::translateFieldName($name, $type, TableMap::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->setTitle($value);
+ break;
+ case 2:
+ $this->setCustomerId($value);
+ break;
+ case 3:
+ $this->setCustomerTitleId($value);
+ break;
+ case 4:
+ $this->setCompany($value);
+ break;
+ case 5:
+ $this->setFirstname($value);
+ break;
+ case 6:
+ $this->setLastname($value);
+ break;
+ case 7:
+ $this->setAddress1($value);
+ break;
+ case 8:
+ $this->setAddress2($value);
+ break;
+ case 9:
+ $this->setAddress3($value);
+ break;
+ case 10:
+ $this->setZipcode($value);
+ break;
+ case 11:
+ $this->setCity($value);
+ break;
+ case 12:
+ $this->setCountryId($value);
+ break;
+ case 13:
+ $this->setPhone($value);
+ break;
+ case 14:
+ $this->setCreatedAt($value);
+ break;
+ case 15:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = AddressTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setTitle($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCustomerId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCustomerTitleId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCompany($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setFirstname($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setLastname($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setAddress1($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setAddress2($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setAddress3($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setZipcode($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setCity($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setCountryId($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setPhone($arr[$keys[13]]);
+ if (array_key_exists($keys[14], $arr)) $this->setCreatedAt($arr[$keys[14]]);
+ if (array_key_exists($keys[15], $arr)) $this->setUpdatedAt($arr[$keys[15]]);
+ }
+
+ /**
+ * 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(AddressTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(AddressTableMap::ID)) $criteria->add(AddressTableMap::ID, $this->id);
+ if ($this->isColumnModified(AddressTableMap::TITLE)) $criteria->add(AddressTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(AddressTableMap::CUSTOMER_ID)) $criteria->add(AddressTableMap::CUSTOMER_ID, $this->customer_id);
+ if ($this->isColumnModified(AddressTableMap::CUSTOMER_TITLE_ID)) $criteria->add(AddressTableMap::CUSTOMER_TITLE_ID, $this->customer_title_id);
+ if ($this->isColumnModified(AddressTableMap::COMPANY)) $criteria->add(AddressTableMap::COMPANY, $this->company);
+ if ($this->isColumnModified(AddressTableMap::FIRSTNAME)) $criteria->add(AddressTableMap::FIRSTNAME, $this->firstname);
+ if ($this->isColumnModified(AddressTableMap::LASTNAME)) $criteria->add(AddressTableMap::LASTNAME, $this->lastname);
+ if ($this->isColumnModified(AddressTableMap::ADDRESS1)) $criteria->add(AddressTableMap::ADDRESS1, $this->address1);
+ if ($this->isColumnModified(AddressTableMap::ADDRESS2)) $criteria->add(AddressTableMap::ADDRESS2, $this->address2);
+ if ($this->isColumnModified(AddressTableMap::ADDRESS3)) $criteria->add(AddressTableMap::ADDRESS3, $this->address3);
+ if ($this->isColumnModified(AddressTableMap::ZIPCODE)) $criteria->add(AddressTableMap::ZIPCODE, $this->zipcode);
+ if ($this->isColumnModified(AddressTableMap::CITY)) $criteria->add(AddressTableMap::CITY, $this->city);
+ if ($this->isColumnModified(AddressTableMap::COUNTRY_ID)) $criteria->add(AddressTableMap::COUNTRY_ID, $this->country_id);
+ if ($this->isColumnModified(AddressTableMap::PHONE)) $criteria->add(AddressTableMap::PHONE, $this->phone);
+ if ($this->isColumnModified(AddressTableMap::CREATED_AT)) $criteria->add(AddressTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AddressTableMap::UPDATED_AT)) $criteria->add(AddressTableMap::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(AddressTableMap::DATABASE_NAME);
+ $criteria->add(AddressTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Address (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setCustomerId($this->getCustomerId());
+ $copyObj->setCustomerTitleId($this->getCustomerTitleId());
+ $copyObj->setCompany($this->getCompany());
+ $copyObj->setFirstname($this->getFirstname());
+ $copyObj->setLastname($this->getLastname());
+ $copyObj->setAddress1($this->getAddress1());
+ $copyObj->setAddress2($this->getAddress2());
+ $copyObj->setAddress3($this->getAddress3());
+ $copyObj->setZipcode($this->getZipcode());
+ $copyObj->setCity($this->getCity());
+ $copyObj->setCountryId($this->getCountryId());
+ $copyObj->setPhone($this->getPhone());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Address 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCustomer object.
+ *
+ * @param ChildCustomer $v
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCustomer(ChildCustomer $v = null)
+ {
+ if ($v === null) {
+ $this->setCustomerId(NULL);
+ } else {
+ $this->setCustomerId($v->getId());
+ }
+
+ $this->aCustomer = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCustomer object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAddress($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCustomer object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCustomer The associated ChildCustomer object.
+ * @throws PropelException
+ */
+ public function getCustomer(ConnectionInterface $con = null)
+ {
+ if ($this->aCustomer === null && ($this->customer_id !== null)) {
+ $this->aCustomer = ChildCustomerQuery::create()->findPk($this->customer_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCustomer->addAddresses($this);
+ */
+ }
+
+ return $this->aCustomer;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCustomerTitle object.
+ *
+ * @param ChildCustomerTitle $v
+ * @return \Thelia\Model\Address The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCustomerTitle(ChildCustomerTitle $v = null)
+ {
+ if ($v === null) {
+ $this->setCustomerTitleId(NULL);
+ } else {
+ $this->setCustomerTitleId($v->getId());
+ }
+
+ $this->aCustomerTitle = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCustomerTitle object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAddress($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCustomerTitle object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCustomerTitle The associated ChildCustomerTitle object.
+ * @throws PropelException
+ */
+ public function getCustomerTitle(ConnectionInterface $con = null)
+ {
+ if ($this->aCustomerTitle === null && ($this->customer_title_id !== null)) {
+ $this->aCustomerTitle = ChildCustomerTitleQuery::create()->findPk($this->customer_title_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCustomerTitle->addAddresses($this);
+ */
+ }
+
+ return $this->aCustomerTitle;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->title = null;
+ $this->customer_id = null;
+ $this->customer_title_id = null;
+ $this->company = null;
+ $this->firstname = null;
+ $this->lastname = null;
+ $this->address1 = null;
+ $this->address2 = null;
+ $this->address3 = null;
+ $this->zipcode = null;
+ $this->city = null;
+ $this->country_id = null;
+ $this->phone = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCustomer = null;
+ $this->aCustomerTitle = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AddressTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildAddress The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = AddressTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/AddressQuery.php b/core/lib/Thelia/Model/Base/AddressQuery.php
new file mode 100644
index 000000000..8611f14a8
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AddressQuery.php
@@ -0,0 +1,1134 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAddress|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AddressTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AddressTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAddress A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, TITLE, CUSTOMER_ID, CUSTOMER_TITLE_ID, COMPANY, FIRSTNAME, LASTNAME, ADDRESS1, ADDRESS2, ADDRESS3, ZIPCODE, CITY, COUNTRY_ID, PHONE, CREATED_AT, UPDATED_AT FROM address WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildAddress();
+ $obj->hydrate($row);
+ AddressTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAddress|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AddressTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AddressTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(AddressTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(AddressTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerId(1234); // WHERE customer_id = 1234
+ * $query->filterByCustomerId(array(12, 34)); // WHERE customer_id IN (12, 34)
+ * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id > 12
+ *
+ *
+ * @see filterByCustomer()
+ *
+ * @param mixed $customerId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByCustomerId($customerId = null, $comparison = null)
+ {
+ if (is_array($customerId)) {
+ $useMinMax = false;
+ if (isset($customerId['min'])) {
+ $this->addUsingAlias(AddressTableMap::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerId['max'])) {
+ $this->addUsingAlias(AddressTableMap::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::CUSTOMER_ID, $customerId, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_title_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234
+ * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34)
+ * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12
+ *
+ *
+ * @see filterByCustomerTitle()
+ *
+ * @param mixed $customerTitleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByCustomerTitleId($customerTitleId = null, $comparison = null)
+ {
+ if (is_array($customerTitleId)) {
+ $useMinMax = false;
+ if (isset($customerTitleId['min'])) {
+ $this->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerTitleId['max'])) {
+ $this->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the company column
+ *
+ * Example usage:
+ *
+ * $query->filterByCompany('fooValue'); // WHERE company = 'fooValue'
+ * $query->filterByCompany('%fooValue%'); // WHERE company LIKE '%fooValue%'
+ *
+ *
+ * @param string $company The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByCompany($company = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($company)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $company)) {
+ $company = str_replace('*', '%', $company);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::COMPANY, $company, $comparison);
+ }
+
+ /**
+ * Filter the query on the firstname column
+ *
+ * Example usage:
+ *
+ * $query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue'
+ * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%'
+ *
+ *
+ * @param string $firstname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByFirstname($firstname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($firstname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $firstname)) {
+ $firstname = str_replace('*', '%', $firstname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::FIRSTNAME, $firstname, $comparison);
+ }
+
+ /**
+ * Filter the query on the lastname column
+ *
+ * Example usage:
+ *
+ * $query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue'
+ * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%'
+ *
+ *
+ * @param string $lastname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByLastname($lastname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lastname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lastname)) {
+ $lastname = str_replace('*', '%', $lastname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::LASTNAME, $lastname, $comparison);
+ }
+
+ /**
+ * Filter the query on the address1 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress1('fooValue'); // WHERE address1 = 'fooValue'
+ * $query->filterByAddress1('%fooValue%'); // WHERE address1 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address1 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress1($address1 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address1)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address1)) {
+ $address1 = str_replace('*', '%', $address1);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::ADDRESS1, $address1, $comparison);
+ }
+
+ /**
+ * Filter the query on the address2 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress2('fooValue'); // WHERE address2 = 'fooValue'
+ * $query->filterByAddress2('%fooValue%'); // WHERE address2 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address2 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress2($address2 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address2)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address2)) {
+ $address2 = str_replace('*', '%', $address2);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::ADDRESS2, $address2, $comparison);
+ }
+
+ /**
+ * Filter the query on the address3 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress3('fooValue'); // WHERE address3 = 'fooValue'
+ * $query->filterByAddress3('%fooValue%'); // WHERE address3 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address3 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress3($address3 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address3)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address3)) {
+ $address3 = str_replace('*', '%', $address3);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::ADDRESS3, $address3, $comparison);
+ }
+
+ /**
+ * Filter the query on the zipcode column
+ *
+ * Example usage:
+ *
+ * $query->filterByZipcode('fooValue'); // WHERE zipcode = 'fooValue'
+ * $query->filterByZipcode('%fooValue%'); // WHERE zipcode LIKE '%fooValue%'
+ *
+ *
+ * @param string $zipcode The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByZipcode($zipcode = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($zipcode)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $zipcode)) {
+ $zipcode = str_replace('*', '%', $zipcode);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::ZIPCODE, $zipcode, $comparison);
+ }
+
+ /**
+ * Filter the query on the city column
+ *
+ * Example usage:
+ *
+ * $query->filterByCity('fooValue'); // WHERE city = 'fooValue'
+ * $query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%'
+ *
+ *
+ * @param string $city The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByCity($city = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($city)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $city)) {
+ $city = str_replace('*', '%', $city);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::CITY, $city, $comparison);
+ }
+
+ /**
+ * Filter the query on the country_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCountryId(1234); // WHERE country_id = 1234
+ * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
+ * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
+ *
+ *
+ * @param mixed $countryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByCountryId($countryId = null, $comparison = null)
+ {
+ if (is_array($countryId)) {
+ $useMinMax = false;
+ if (isset($countryId['min'])) {
+ $this->addUsingAlias(AddressTableMap::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($countryId['max'])) {
+ $this->addUsingAlias(AddressTableMap::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::COUNTRY_ID, $countryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the phone column
+ *
+ * Example usage:
+ *
+ * $query->filterByPhone('fooValue'); // WHERE phone = 'fooValue'
+ * $query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%'
+ *
+ *
+ * @param string $phone The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByPhone($phone = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($phone)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $phone)) {
+ $phone = str_replace('*', '%', $phone);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::PHONE, $phone, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AddressTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AddressTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AddressTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AddressTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AddressTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Customer object
+ *
+ * @param \Thelia\Model\Customer|ObjectCollection $customer The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByCustomer($customer, $comparison = null)
+ {
+ if ($customer instanceof \Thelia\Model\Customer) {
+ return $this
+ ->addUsingAlias(AddressTableMap::CUSTOMER_ID, $customer->getId(), $comparison);
+ } elseif ($customer instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AddressTableMap::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCustomer() only accepts arguments of type \Thelia\Model\Customer or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Customer relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Customer');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Customer');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Customer relation Customer object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CustomerQuery A secondary query class using the current class as primary query
+ */
+ public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCustomer($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\CustomerTitle object
+ *
+ * @param \Thelia\Model\CustomerTitle|ObjectCollection $customerTitle The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function filterByCustomerTitle($customerTitle, $comparison = null)
+ {
+ if ($customerTitle instanceof \Thelia\Model\CustomerTitle) {
+ return $this
+ ->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison);
+ } elseif ($customerTitle instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCustomerTitle() only accepts arguments of type \Thelia\Model\CustomerTitle or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CustomerTitle relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CustomerTitle');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'CustomerTitle');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CustomerTitle relation CustomerTitle object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query
+ */
+ public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCustomerTitle($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildAddress $address Object to remove from the list of results
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function prune($address = null)
+ {
+ if ($address) {
+ $this->addUsingAlias(AddressTableMap::ID, $address->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the address table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AddressTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ AddressTableMap::clearInstancePool();
+ AddressTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildAddress or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildAddress object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AddressTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(AddressTableMap::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->beginTransaction();
+
+
+ AddressTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ AddressTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AddressTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AddressTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AddressTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AddressTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AddressTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildAddressQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AddressTableMap::CREATED_AT);
+ }
+
+} // AddressQuery
diff --git a/core/lib/Thelia/Model/Base/Admin.php b/core/lib/Thelia/Model/Base/Admin.php
new file mode 100644
index 000000000..b1241473e
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Admin.php
@@ -0,0 +1,2123 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Admin instance. If
+ * obj is an instance of Admin, delegates to
+ * equals(Admin). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Admin The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Admin The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [firstname] column value.
+ *
+ * @return string
+ */
+ public function getFirstname()
+ {
+
+ return $this->firstname;
+ }
+
+ /**
+ * Get the [lastname] column value.
+ *
+ * @return string
+ */
+ public function getLastname()
+ {
+
+ return $this->lastname;
+ }
+
+ /**
+ * 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 [algo] column value.
+ *
+ * @return string
+ */
+ public function getAlgo()
+ {
+
+ return $this->algo;
+ }
+
+ /**
+ * Get the [salt] column value.
+ *
+ * @return string
+ */
+ public function getSalt()
+ {
+
+ return $this->salt;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Admin The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AdminTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [firstname] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Admin The current object (for fluent API support)
+ */
+ public function setFirstname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->firstname !== $v) {
+ $this->firstname = $v;
+ $this->modifiedColumns[] = AdminTableMap::FIRSTNAME;
+ }
+
+
+ return $this;
+ } // setFirstname()
+
+ /**
+ * Set the value of [lastname] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Admin The current object (for fluent API support)
+ */
+ public function setLastname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lastname !== $v) {
+ $this->lastname = $v;
+ $this->modifiedColumns[] = AdminTableMap::LASTNAME;
+ }
+
+
+ return $this;
+ } // setLastname()
+
+ /**
+ * Set the value of [login] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Admin The current object (for fluent API support)
+ */
+ public function setLogin($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->login !== $v) {
+ $this->login = $v;
+ $this->modifiedColumns[] = AdminTableMap::LOGIN;
+ }
+
+
+ return $this;
+ } // setLogin()
+
+ /**
+ * Set the value of [password] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Admin The current object (for fluent API support)
+ */
+ public function setPassword($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->password !== $v) {
+ $this->password = $v;
+ $this->modifiedColumns[] = AdminTableMap::PASSWORD;
+ }
+
+
+ return $this;
+ } // setPassword()
+
+ /**
+ * Set the value of [algo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Admin The current object (for fluent API support)
+ */
+ public function setAlgo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->algo !== $v) {
+ $this->algo = $v;
+ $this->modifiedColumns[] = AdminTableMap::ALGO;
+ }
+
+
+ return $this;
+ } // setAlgo()
+
+ /**
+ * Set the value of [salt] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Admin The current object (for fluent API support)
+ */
+ public function setSalt($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->salt !== $v) {
+ $this->salt = $v;
+ $this->modifiedColumns[] = AdminTableMap::SALT;
+ }
+
+
+ return $this;
+ } // setSalt()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Admin The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = AdminTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Admin The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = AdminTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AdminTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AdminTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->firstname = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AdminTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->lastname = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AdminTableMap::translateFieldName('Login', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->login = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AdminTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->password = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AdminTableMap::translateFieldName('Algo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->algo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : AdminTableMap::translateFieldName('Salt', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->salt = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : AdminTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : AdminTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 9; // 9 = AdminTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Admin object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AdminTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildAdminQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collAdminGroups = null;
+
+ $this->collGroups = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Admin::setDeleted()
+ * @see Admin::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildAdminQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(AdminTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(AdminTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(AdminTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AdminTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->groupsScheduledForDeletion !== null) {
+ if (!$this->groupsScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->groupsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($remotePk, $pk);
+ }
+
+ AdminGroupQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->groupsScheduledForDeletion = null;
+ }
+
+ foreach ($this->getGroups() as $group) {
+ if ($group->isModified()) {
+ $group->save($con);
+ }
+ }
+ } elseif ($this->collGroups) {
+ foreach ($this->collGroups as $group) {
+ if ($group->isModified()) {
+ $group->save($con);
+ }
+ }
+ }
+
+ if ($this->adminGroupsScheduledForDeletion !== null) {
+ if (!$this->adminGroupsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\AdminGroupQuery::create()
+ ->filterByPrimaryKeys($this->adminGroupsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->adminGroupsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAdminGroups !== null) {
+ foreach ($this->collAdminGroups as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AdminTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AdminTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(AdminTableMap::FIRSTNAME)) {
+ $modifiedColumns[':p' . $index++] = 'FIRSTNAME';
+ }
+ if ($this->isColumnModified(AdminTableMap::LASTNAME)) {
+ $modifiedColumns[':p' . $index++] = 'LASTNAME';
+ }
+ if ($this->isColumnModified(AdminTableMap::LOGIN)) {
+ $modifiedColumns[':p' . $index++] = 'LOGIN';
+ }
+ if ($this->isColumnModified(AdminTableMap::PASSWORD)) {
+ $modifiedColumns[':p' . $index++] = 'PASSWORD';
+ }
+ if ($this->isColumnModified(AdminTableMap::ALGO)) {
+ $modifiedColumns[':p' . $index++] = 'ALGO';
+ }
+ if ($this->isColumnModified(AdminTableMap::SALT)) {
+ $modifiedColumns[':p' . $index++] = 'SALT';
+ }
+ if ($this->isColumnModified(AdminTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(AdminTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO admin (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'FIRSTNAME':
+ $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR);
+ break;
+ case 'LASTNAME':
+ $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR);
+ break;
+ case 'LOGIN':
+ $stmt->bindValue($identifier, $this->login, PDO::PARAM_STR);
+ break;
+ case 'PASSWORD':
+ $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR);
+ break;
+ case 'ALGO':
+ $stmt->bindValue($identifier, $this->algo, PDO::PARAM_STR);
+ break;
+ case 'SALT':
+ $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AdminTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getFirstname();
+ break;
+ case 2:
+ return $this->getLastname();
+ break;
+ case 3:
+ return $this->getLogin();
+ break;
+ case 4:
+ return $this->getPassword();
+ break;
+ case 5:
+ return $this->getAlgo();
+ break;
+ case 6:
+ return $this->getSalt();
+ break;
+ case 7:
+ return $this->getCreatedAt();
+ break;
+ case 8:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Admin'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Admin'][$this->getPrimaryKey()] = true;
+ $keys = AdminTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getFirstname(),
+ $keys[2] => $this->getLastname(),
+ $keys[3] => $this->getLogin(),
+ $keys[4] => $this->getPassword(),
+ $keys[5] => $this->getAlgo(),
+ $keys[6] => $this->getSalt(),
+ $keys[7] => $this->getCreatedAt(),
+ $keys[8] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collAdminGroups) {
+ $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AdminTableMap::translateFieldName($name, $type, TableMap::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->setFirstname($value);
+ break;
+ case 2:
+ $this->setLastname($value);
+ break;
+ case 3:
+ $this->setLogin($value);
+ break;
+ case 4:
+ $this->setPassword($value);
+ break;
+ case 5:
+ $this->setAlgo($value);
+ break;
+ case 6:
+ $this->setSalt($value);
+ break;
+ case 7:
+ $this->setCreatedAt($value);
+ break;
+ case 8:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = AdminTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setFirstname($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLastname($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setLogin($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPassword($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setAlgo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setSalt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
+ }
+
+ /**
+ * 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(AdminTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(AdminTableMap::ID)) $criteria->add(AdminTableMap::ID, $this->id);
+ if ($this->isColumnModified(AdminTableMap::FIRSTNAME)) $criteria->add(AdminTableMap::FIRSTNAME, $this->firstname);
+ if ($this->isColumnModified(AdminTableMap::LASTNAME)) $criteria->add(AdminTableMap::LASTNAME, $this->lastname);
+ if ($this->isColumnModified(AdminTableMap::LOGIN)) $criteria->add(AdminTableMap::LOGIN, $this->login);
+ if ($this->isColumnModified(AdminTableMap::PASSWORD)) $criteria->add(AdminTableMap::PASSWORD, $this->password);
+ if ($this->isColumnModified(AdminTableMap::ALGO)) $criteria->add(AdminTableMap::ALGO, $this->algo);
+ if ($this->isColumnModified(AdminTableMap::SALT)) $criteria->add(AdminTableMap::SALT, $this->salt);
+ if ($this->isColumnModified(AdminTableMap::CREATED_AT)) $criteria->add(AdminTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AdminTableMap::UPDATED_AT)) $criteria->add(AdminTableMap::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(AdminTableMap::DATABASE_NAME);
+ $criteria->add(AdminTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Admin (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setFirstname($this->getFirstname());
+ $copyObj->setLastname($this->getLastname());
+ $copyObj->setLogin($this->getLogin());
+ $copyObj->setPassword($this->getPassword());
+ $copyObj->setAlgo($this->getAlgo());
+ $copyObj->setSalt($this->getSalt());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getAdminGroups() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAdminGroup($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Admin 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('AdminGroup' == $relationName) {
+ return $this->initAdminGroups();
+ }
+ }
+
+ /**
+ * Clears out the collAdminGroups collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAdminGroups()
+ */
+ public function clearAdminGroups()
+ {
+ $this->collAdminGroups = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collAdminGroups collection loaded partially.
+ */
+ public function resetPartialAdminGroups($v = true)
+ {
+ $this->collAdminGroupsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAdminGroups collection.
+ *
+ * By default this just sets the collAdminGroups collection to an empty array (like clearcollAdminGroups());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAdminGroups($overrideExisting = true)
+ {
+ if (null !== $this->collAdminGroups && !$overrideExisting) {
+ return;
+ }
+ $this->collAdminGroups = new ObjectCollection();
+ $this->collAdminGroups->setModel('\Thelia\Model\AdminGroup');
+ }
+
+ /**
+ * Gets an array of ChildAdminGroup objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildAdmin is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildAdminGroup[] List of ChildAdminGroup objects
+ * @throws PropelException
+ */
+ public function getAdminGroups($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAdminGroupsPartial && !$this->isNew();
+ if (null === $this->collAdminGroups || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAdminGroups) {
+ // return empty collection
+ $this->initAdminGroups();
+ } else {
+ $collAdminGroups = ChildAdminGroupQuery::create(null, $criteria)
+ ->filterByAdmin($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collAdminGroupsPartial && count($collAdminGroups)) {
+ $this->initAdminGroups(false);
+
+ foreach ($collAdminGroups as $obj) {
+ if (false == $this->collAdminGroups->contains($obj)) {
+ $this->collAdminGroups->append($obj);
+ }
+ }
+
+ $this->collAdminGroupsPartial = true;
+ }
+
+ $collAdminGroups->getInternalIterator()->rewind();
+
+ return $collAdminGroups;
+ }
+
+ if ($partial && $this->collAdminGroups) {
+ foreach ($this->collAdminGroups as $obj) {
+ if ($obj->isNew()) {
+ $collAdminGroups[] = $obj;
+ }
+ }
+ }
+
+ $this->collAdminGroups = $collAdminGroups;
+ $this->collAdminGroupsPartial = false;
+ }
+ }
+
+ return $this->collAdminGroups;
+ }
+
+ /**
+ * Sets a collection of AdminGroup objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $adminGroups A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildAdmin The current object (for fluent API support)
+ */
+ public function setAdminGroups(Collection $adminGroups, ConnectionInterface $con = null)
+ {
+ $adminGroupsToDelete = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->adminGroupsScheduledForDeletion = clone $adminGroupsToDelete;
+
+ foreach ($adminGroupsToDelete as $adminGroupRemoved) {
+ $adminGroupRemoved->setAdmin(null);
+ }
+
+ $this->collAdminGroups = null;
+ foreach ($adminGroups as $adminGroup) {
+ $this->addAdminGroup($adminGroup);
+ }
+
+ $this->collAdminGroups = $adminGroups;
+ $this->collAdminGroupsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related AdminGroup objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related AdminGroup objects.
+ * @throws PropelException
+ */
+ public function countAdminGroups(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAdminGroupsPartial && !$this->isNew();
+ if (null === $this->collAdminGroups || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAdminGroups) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getAdminGroups());
+ }
+
+ $query = ChildAdminGroupQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAdmin($this)
+ ->count($con);
+ }
+
+ return count($this->collAdminGroups);
+ }
+
+ /**
+ * Method called to associate a ChildAdminGroup object to this object
+ * through the ChildAdminGroup foreign key attribute.
+ *
+ * @param ChildAdminGroup $l ChildAdminGroup
+ * @return \Thelia\Model\Admin The current object (for fluent API support)
+ */
+ public function addAdminGroup(ChildAdminGroup $l)
+ {
+ if ($this->collAdminGroups === null) {
+ $this->initAdminGroups();
+ $this->collAdminGroupsPartial = true;
+ }
+
+ if (!in_array($l, $this->collAdminGroups->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddAdminGroup($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AdminGroup $adminGroup The adminGroup object to add.
+ */
+ protected function doAddAdminGroup($adminGroup)
+ {
+ $this->collAdminGroups[]= $adminGroup;
+ $adminGroup->setAdmin($this);
+ }
+
+ /**
+ * @param AdminGroup $adminGroup The adminGroup object to remove.
+ * @return ChildAdmin The current object (for fluent API support)
+ */
+ public function removeAdminGroup($adminGroup)
+ {
+ if ($this->getAdminGroups()->contains($adminGroup)) {
+ $this->collAdminGroups->remove($this->collAdminGroups->search($adminGroup));
+ if (null === $this->adminGroupsScheduledForDeletion) {
+ $this->adminGroupsScheduledForDeletion = clone $this->collAdminGroups;
+ $this->adminGroupsScheduledForDeletion->clear();
+ }
+ $this->adminGroupsScheduledForDeletion[]= clone $adminGroup;
+ $adminGroup->setAdmin(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Admin is new, it will return
+ * an empty collection; or if this Admin has previously
+ * been saved, it will retrieve related AdminGroups 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 Admin.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildAdminGroup[] List of ChildAdminGroup objects
+ */
+ public function getAdminGroupsJoinGroup($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildAdminGroupQuery::create(null, $criteria);
+ $query->joinWith('Group', $joinBehavior);
+
+ return $this->getAdminGroups($query, $con);
+ }
+
+ /**
+ * Clears out the collGroups collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addGroups()
+ */
+ public function clearGroups()
+ {
+ $this->collGroups = null; // important to set this to NULL since that means it is uninitialized
+ $this->collGroupsPartial = null;
+ }
+
+ /**
+ * Initializes the collGroups collection.
+ *
+ * By default this just sets the collGroups collection to an empty collection (like clearGroups());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initGroups()
+ {
+ $this->collGroups = new ObjectCollection();
+ $this->collGroups->setModel('\Thelia\Model\Group');
+ }
+
+ /**
+ * Gets a collection of ChildGroup objects related by a many-to-many relationship
+ * to the current object by way of the admin_group cross-reference table.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildAdmin is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return ObjectCollection|ChildGroup[] List of ChildGroup objects
+ */
+ public function getGroups($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collGroups || null !== $criteria) {
+ if ($this->isNew() && null === $this->collGroups) {
+ // return empty collection
+ $this->initGroups();
+ } else {
+ $collGroups = ChildGroupQuery::create(null, $criteria)
+ ->filterByAdmin($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collGroups;
+ }
+ $this->collGroups = $collGroups;
+ }
+ }
+
+ return $this->collGroups;
+ }
+
+ /**
+ * Sets a collection of Group objects related by a many-to-many relationship
+ * to the current object by way of the admin_group cross-reference table.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $groups A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildAdmin The current object (for fluent API support)
+ */
+ public function setGroups(Collection $groups, ConnectionInterface $con = null)
+ {
+ $this->clearGroups();
+ $currentGroups = $this->getGroups();
+
+ $this->groupsScheduledForDeletion = $currentGroups->diff($groups);
+
+ foreach ($groups as $group) {
+ if (!$currentGroups->contains($group)) {
+ $this->doAddGroup($group);
+ }
+ }
+
+ $this->collGroups = $groups;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildGroup objects related by a many-to-many relationship
+ * to the current object by way of the admin_group cross-reference table.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param boolean $distinct Set to true to force count distinct
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return int the number of related ChildGroup objects
+ */
+ public function countGroups($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collGroups || null !== $criteria) {
+ if ($this->isNew() && null === $this->collGroups) {
+ return 0;
+ } else {
+ $query = ChildGroupQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAdmin($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collGroups);
+ }
+ }
+
+ /**
+ * Associate a ChildGroup object to this object
+ * through the admin_group cross reference table.
+ *
+ * @param ChildGroup $group The ChildAdminGroup object to relate
+ * @return ChildAdmin The current object (for fluent API support)
+ */
+ public function addGroup(ChildGroup $group)
+ {
+ if ($this->collGroups === null) {
+ $this->initGroups();
+ }
+
+ if (!$this->collGroups->contains($group)) { // only add it if the **same** object is not already associated
+ $this->doAddGroup($group);
+ $this->collGroups[] = $group;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Group $group The group object to add.
+ */
+ protected function doAddGroup($group)
+ {
+ $adminGroup = new ChildAdminGroup();
+ $adminGroup->setGroup($group);
+ $this->addAdminGroup($adminGroup);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$group->getAdmins()->contains($this)) {
+ $foreignCollection = $group->getAdmins();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildGroup object to this object
+ * through the admin_group cross reference table.
+ *
+ * @param ChildGroup $group The ChildAdminGroup object to relate
+ * @return ChildAdmin The current object (for fluent API support)
+ */
+ public function removeGroup(ChildGroup $group)
+ {
+ if ($this->getGroups()->contains($group)) {
+ $this->collGroups->remove($this->collGroups->search($group));
+
+ if (null === $this->groupsScheduledForDeletion) {
+ $this->groupsScheduledForDeletion = clone $this->collGroups;
+ $this->groupsScheduledForDeletion->clear();
+ }
+
+ $this->groupsScheduledForDeletion[] = $group;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->firstname = null;
+ $this->lastname = null;
+ $this->login = null;
+ $this->password = null;
+ $this->algo = null;
+ $this->salt = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collAdminGroups) {
+ foreach ($this->collAdminGroups as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collGroups) {
+ foreach ($this->collGroups as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collAdminGroups instanceof Collection) {
+ $this->collAdminGroups->clearIterator();
+ }
+ $this->collAdminGroups = null;
+ if ($this->collGroups instanceof Collection) {
+ $this->collGroups->clearIterator();
+ }
+ $this->collGroups = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AdminTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildAdmin The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = AdminTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/AdminGroup.php b/core/lib/Thelia/Model/Base/AdminGroup.php
new file mode 100644
index 000000000..60141e3f8
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AdminGroup.php
@@ -0,0 +1,1505 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another AdminGroup instance. If
+ * obj is an instance of AdminGroup, delegates to
+ * equals(AdminGroup). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return AdminGroup The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return AdminGroup The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [group_id] column value.
+ *
+ * @return int
+ */
+ public function getGroupId()
+ {
+
+ return $this->group_id;
+ }
+
+ /**
+ * Get the [admin_id] column value.
+ *
+ * @return int
+ */
+ public function getAdminId()
+ {
+
+ return $this->admin_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AdminGroup The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AdminGroupTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [group_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AdminGroup The current object (for fluent API support)
+ */
+ public function setGroupId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->group_id !== $v) {
+ $this->group_id = $v;
+ $this->modifiedColumns[] = AdminGroupTableMap::GROUP_ID;
+ }
+
+ if ($this->aGroup !== null && $this->aGroup->getId() !== $v) {
+ $this->aGroup = null;
+ }
+
+
+ return $this;
+ } // setGroupId()
+
+ /**
+ * Set the value of [admin_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AdminGroup The current object (for fluent API support)
+ */
+ public function setAdminId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->admin_id !== $v) {
+ $this->admin_id = $v;
+ $this->modifiedColumns[] = AdminGroupTableMap::ADMIN_ID;
+ }
+
+ if ($this->aAdmin !== null && $this->aAdmin->getId() !== $v) {
+ $this->aAdmin = null;
+ }
+
+
+ return $this;
+ } // setAdminId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\AdminGroup The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = AdminGroupTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\AdminGroup The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = AdminGroupTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AdminGroupTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AdminGroupTableMap::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->group_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AdminGroupTableMap::translateFieldName('AdminId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->admin_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AdminGroupTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AdminGroupTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = AdminGroupTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\AdminGroup object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aGroup !== null && $this->group_id !== $this->aGroup->getId()) {
+ $this->aGroup = null;
+ }
+ if ($this->aAdmin !== null && $this->admin_id !== $this->aAdmin->getId()) {
+ $this->aAdmin = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AdminGroupTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildAdminGroupQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aGroup = null;
+ $this->aAdmin = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see AdminGroup::setDeleted()
+ * @see AdminGroup::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildAdminGroupQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(AdminGroupTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(AdminGroupTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(AdminGroupTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AdminGroupTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aGroup !== null) {
+ if ($this->aGroup->isModified() || $this->aGroup->isNew()) {
+ $affectedRows += $this->aGroup->save($con);
+ }
+ $this->setGroup($this->aGroup);
+ }
+
+ if ($this->aAdmin !== null) {
+ if ($this->aAdmin->isModified() || $this->aAdmin->isNew()) {
+ $affectedRows += $this->aAdmin->save($con);
+ }
+ $this->setAdmin($this->aAdmin);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AdminGroupTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminGroupTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AdminGroupTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(AdminGroupTableMap::GROUP_ID)) {
+ $modifiedColumns[':p' . $index++] = 'GROUP_ID';
+ }
+ if ($this->isColumnModified(AdminGroupTableMap::ADMIN_ID)) {
+ $modifiedColumns[':p' . $index++] = 'ADMIN_ID';
+ }
+ if ($this->isColumnModified(AdminGroupTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(AdminGroupTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO admin_group (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'GROUP_ID':
+ $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT);
+ break;
+ case 'ADMIN_ID':
+ $stmt->bindValue($identifier, $this->admin_id, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AdminGroupTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getGroupId();
+ break;
+ case 2:
+ return $this->getAdminId();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['AdminGroup'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['AdminGroup'][serialize($this->getPrimaryKey())] = true;
+ $keys = AdminGroupTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getGroupId(),
+ $keys[2] => $this->getAdminId(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aGroup) {
+ $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aAdmin) {
+ $result['Admin'] = $this->aAdmin->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AdminGroupTableMap::translateFieldName($name, $type, TableMap::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->setGroupId($value);
+ break;
+ case 2:
+ $this->setAdminId($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = AdminGroupTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setAdminId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * 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(AdminGroupTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(AdminGroupTableMap::ID)) $criteria->add(AdminGroupTableMap::ID, $this->id);
+ if ($this->isColumnModified(AdminGroupTableMap::GROUP_ID)) $criteria->add(AdminGroupTableMap::GROUP_ID, $this->group_id);
+ if ($this->isColumnModified(AdminGroupTableMap::ADMIN_ID)) $criteria->add(AdminGroupTableMap::ADMIN_ID, $this->admin_id);
+ if ($this->isColumnModified(AdminGroupTableMap::CREATED_AT)) $criteria->add(AdminGroupTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AdminGroupTableMap::UPDATED_AT)) $criteria->add(AdminGroupTableMap::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(AdminGroupTableMap::DATABASE_NAME);
+ $criteria->add(AdminGroupTableMap::ID, $this->id);
+ $criteria->add(AdminGroupTableMap::GROUP_ID, $this->group_id);
+ $criteria->add(AdminGroupTableMap::ADMIN_ID, $this->admin_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getGroupId();
+ $pks[2] = $this->getAdminId();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setGroupId($keys[1]);
+ $this->setAdminId($keys[2]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getGroupId()) && (null === $this->getAdminId());
+ }
+
+ /**
+ * 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 \Thelia\Model\AdminGroup (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setGroupId($this->getGroupId());
+ $copyObj->setAdminId($this->getAdminId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\AdminGroup 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildGroup object.
+ *
+ * @param ChildGroup $v
+ * @return \Thelia\Model\AdminGroup The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setGroup(ChildGroup $v = null)
+ {
+ if ($v === null) {
+ $this->setGroupId(NULL);
+ } else {
+ $this->setGroupId($v->getId());
+ }
+
+ $this->aGroup = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildGroup object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAdminGroup($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildGroup object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildGroup The associated ChildGroup object.
+ * @throws PropelException
+ */
+ public function getGroup(ConnectionInterface $con = null)
+ {
+ if ($this->aGroup === null && ($this->group_id !== null)) {
+ $this->aGroup = ChildGroupQuery::create()->findPk($this->group_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aGroup->addAdminGroups($this);
+ */
+ }
+
+ return $this->aGroup;
+ }
+
+ /**
+ * Declares an association between this object and a ChildAdmin object.
+ *
+ * @param ChildAdmin $v
+ * @return \Thelia\Model\AdminGroup The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setAdmin(ChildAdmin $v = null)
+ {
+ if ($v === null) {
+ $this->setAdminId(NULL);
+ } else {
+ $this->setAdminId($v->getId());
+ }
+
+ $this->aAdmin = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildAdmin object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAdminGroup($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildAdmin object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildAdmin The associated ChildAdmin object.
+ * @throws PropelException
+ */
+ public function getAdmin(ConnectionInterface $con = null)
+ {
+ if ($this->aAdmin === null && ($this->admin_id !== null)) {
+ $this->aAdmin = ChildAdminQuery::create()->findPk($this->admin_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aAdmin->addAdminGroups($this);
+ */
+ }
+
+ return $this->aAdmin;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->group_id = null;
+ $this->admin_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aGroup = null;
+ $this->aAdmin = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AdminGroupTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildAdminGroup The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = AdminGroupTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/AdminGroupQuery.php b/core/lib/Thelia/Model/Base/AdminGroupQuery.php
new file mode 100644
index 000000000..8d3353b4c
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AdminGroupQuery.php
@@ -0,0 +1,778 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34, 56), $con);
+ *
+ *
+ * @param array[$id, $group_id, $admin_id] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAdminGroup|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AdminGroupTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AdminGroupTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAdminGroup A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, GROUP_ID, ADMIN_ID, CREATED_AT, UPDATED_AT FROM admin_group WHERE ID = :p0 AND GROUP_ID = :p1 AND ADMIN_ID = :p2';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
+ $stmt->bindValue(':p2', $key[2], PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildAdminGroup();
+ $obj->hydrate($row);
+ AdminGroupTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAdminGroup|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(AdminGroupTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(AdminGroupTableMap::GROUP_ID, $key[1], Criteria::EQUAL);
+ $this->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $key[2], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(AdminGroupTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(AdminGroupTableMap::GROUP_ID, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $cton2 = $this->getNewCriterion(AdminGroupTableMap::ADMIN_ID, $key[2], Criteria::EQUAL);
+ $cton0->addAnd($cton2);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(AdminGroupTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(AdminGroupTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminGroupTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the group_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByGroupId(1234); // WHERE group_id = 1234
+ * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34)
+ * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12
+ *
+ *
+ * @see filterByGroup()
+ *
+ * @param mixed $groupId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function filterByGroupId($groupId = null, $comparison = null)
+ {
+ if (is_array($groupId)) {
+ $useMinMax = false;
+ if (isset($groupId['min'])) {
+ $this->addUsingAlias(AdminGroupTableMap::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($groupId['max'])) {
+ $this->addUsingAlias(AdminGroupTableMap::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminGroupTableMap::GROUP_ID, $groupId, $comparison);
+ }
+
+ /**
+ * Filter the query on the admin_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAdminId(1234); // WHERE admin_id = 1234
+ * $query->filterByAdminId(array(12, 34)); // WHERE admin_id IN (12, 34)
+ * $query->filterByAdminId(array('min' => 12)); // WHERE admin_id > 12
+ *
+ *
+ * @see filterByAdmin()
+ *
+ * @param mixed $adminId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function filterByAdminId($adminId = null, $comparison = null)
+ {
+ if (is_array($adminId)) {
+ $useMinMax = false;
+ if (isset($adminId['min'])) {
+ $this->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $adminId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($adminId['max'])) {
+ $this->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $adminId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $adminId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AdminGroupTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AdminGroupTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminGroupTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AdminGroupTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AdminGroupTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminGroupTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Group object
+ *
+ * @param \Thelia\Model\Group|ObjectCollection $group The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function filterByGroup($group, $comparison = null)
+ {
+ if ($group instanceof \Thelia\Model\Group) {
+ return $this
+ ->addUsingAlias(AdminGroupTableMap::GROUP_ID, $group->getId(), $comparison);
+ } elseif ($group instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AdminGroupTableMap::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByGroup() only accepts arguments of type \Thelia\Model\Group or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Group relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Group');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Group');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Group relation Group object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\GroupQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinGroup($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Admin object
+ *
+ * @param \Thelia\Model\Admin|ObjectCollection $admin The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function filterByAdmin($admin, $comparison = null)
+ {
+ if ($admin instanceof \Thelia\Model\Admin) {
+ return $this
+ ->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $admin->getId(), $comparison);
+ } elseif ($admin instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $admin->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByAdmin() only accepts arguments of type \Thelia\Model\Admin or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Admin relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function joinAdmin($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Admin');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Admin');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Admin relation Admin object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AdminQuery A secondary query class using the current class as primary query
+ */
+ public function useAdminQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAdmin($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Admin', '\Thelia\Model\AdminQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildAdminGroup $adminGroup Object to remove from the list of results
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function prune($adminGroup = null)
+ {
+ if ($adminGroup) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(AdminGroupTableMap::ID), $adminGroup->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(AdminGroupTableMap::GROUP_ID), $adminGroup->getGroupId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond2', $this->getAliasedColName(AdminGroupTableMap::ADMIN_ID), $adminGroup->getAdminId(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the admin_group table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ AdminGroupTableMap::clearInstancePool();
+ AdminGroupTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildAdminGroup or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildAdminGroup object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminGroupTableMap::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->beginTransaction();
+
+
+ AdminGroupTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ AdminGroupTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AdminGroupTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AdminGroupTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AdminGroupTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AdminGroupTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AdminGroupTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildAdminGroupQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AdminGroupTableMap::CREATED_AT);
+ }
+
+} // AdminGroupQuery
diff --git a/core/lib/Thelia/Model/Base/AdminLog.php b/core/lib/Thelia/Model/Base/AdminLog.php
new file mode 100644
index 000000000..c83be20ee
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AdminLog.php
@@ -0,0 +1,1507 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another AdminLog instance. If
+ * obj is an instance of AdminLog, delegates to
+ * equals(AdminLog). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return AdminLog The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return AdminLog The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [admin_login] column value.
+ *
+ * @return string
+ */
+ public function getAdminLogin()
+ {
+
+ return $this->admin_login;
+ }
+
+ /**
+ * Get the [admin_firstname] column value.
+ *
+ * @return string
+ */
+ public function getAdminFirstname()
+ {
+
+ return $this->admin_firstname;
+ }
+
+ /**
+ * Get the [admin_lastname] column value.
+ *
+ * @return string
+ */
+ public function getAdminLastname()
+ {
+
+ return $this->admin_lastname;
+ }
+
+ /**
+ * Get the [action] column value.
+ *
+ * @return string
+ */
+ public function getAction()
+ {
+
+ return $this->action;
+ }
+
+ /**
+ * Get the [request] column value.
+ *
+ * @return string
+ */
+ public function getRequest()
+ {
+
+ return $this->request;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AdminLog The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AdminLogTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [admin_login] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AdminLog The current object (for fluent API support)
+ */
+ public function setAdminLogin($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->admin_login !== $v) {
+ $this->admin_login = $v;
+ $this->modifiedColumns[] = AdminLogTableMap::ADMIN_LOGIN;
+ }
+
+
+ return $this;
+ } // setAdminLogin()
+
+ /**
+ * Set the value of [admin_firstname] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AdminLog The current object (for fluent API support)
+ */
+ public function setAdminFirstname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->admin_firstname !== $v) {
+ $this->admin_firstname = $v;
+ $this->modifiedColumns[] = AdminLogTableMap::ADMIN_FIRSTNAME;
+ }
+
+
+ return $this;
+ } // setAdminFirstname()
+
+ /**
+ * Set the value of [admin_lastname] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AdminLog The current object (for fluent API support)
+ */
+ public function setAdminLastname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->admin_lastname !== $v) {
+ $this->admin_lastname = $v;
+ $this->modifiedColumns[] = AdminLogTableMap::ADMIN_LASTNAME;
+ }
+
+
+ return $this;
+ } // setAdminLastname()
+
+ /**
+ * Set the value of [action] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AdminLog The current object (for fluent API support)
+ */
+ public function setAction($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->action !== $v) {
+ $this->action = $v;
+ $this->modifiedColumns[] = AdminLogTableMap::ACTION;
+ }
+
+
+ return $this;
+ } // setAction()
+
+ /**
+ * Set the value of [request] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AdminLog The current object (for fluent API support)
+ */
+ public function setRequest($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->request !== $v) {
+ $this->request = $v;
+ $this->modifiedColumns[] = AdminLogTableMap::REQUEST;
+ }
+
+
+ return $this;
+ } // setRequest()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\AdminLog The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = AdminLogTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\AdminLog The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = AdminLogTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AdminLogTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AdminLogTableMap::translateFieldName('AdminLogin', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->admin_login = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AdminLogTableMap::translateFieldName('AdminFirstname', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->admin_firstname = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AdminLogTableMap::translateFieldName('AdminLastname', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->admin_lastname = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AdminLogTableMap::translateFieldName('Action', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->action = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AdminLogTableMap::translateFieldName('Request', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->request = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : AdminLogTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : AdminLogTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = AdminLogTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\AdminLog object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AdminLogTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildAdminLogQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see AdminLog::setDeleted()
+ * @see AdminLog::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminLogTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildAdminLogQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminLogTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(AdminLogTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(AdminLogTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(AdminLogTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AdminLogTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AdminLogTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminLogTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AdminLogTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(AdminLogTableMap::ADMIN_LOGIN)) {
+ $modifiedColumns[':p' . $index++] = 'ADMIN_LOGIN';
+ }
+ if ($this->isColumnModified(AdminLogTableMap::ADMIN_FIRSTNAME)) {
+ $modifiedColumns[':p' . $index++] = 'ADMIN_FIRSTNAME';
+ }
+ if ($this->isColumnModified(AdminLogTableMap::ADMIN_LASTNAME)) {
+ $modifiedColumns[':p' . $index++] = 'ADMIN_LASTNAME';
+ }
+ if ($this->isColumnModified(AdminLogTableMap::ACTION)) {
+ $modifiedColumns[':p' . $index++] = 'ACTION';
+ }
+ if ($this->isColumnModified(AdminLogTableMap::REQUEST)) {
+ $modifiedColumns[':p' . $index++] = 'REQUEST';
+ }
+ if ($this->isColumnModified(AdminLogTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(AdminLogTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO admin_log (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'ADMIN_LOGIN':
+ $stmt->bindValue($identifier, $this->admin_login, PDO::PARAM_STR);
+ break;
+ case 'ADMIN_FIRSTNAME':
+ $stmt->bindValue($identifier, $this->admin_firstname, PDO::PARAM_STR);
+ break;
+ case 'ADMIN_LASTNAME':
+ $stmt->bindValue($identifier, $this->admin_lastname, PDO::PARAM_STR);
+ break;
+ case 'ACTION':
+ $stmt->bindValue($identifier, $this->action, PDO::PARAM_STR);
+ break;
+ case 'REQUEST':
+ $stmt->bindValue($identifier, $this->request, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AdminLogTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getAdminLogin();
+ break;
+ case 2:
+ return $this->getAdminFirstname();
+ break;
+ case 3:
+ return $this->getAdminLastname();
+ break;
+ case 4:
+ return $this->getAction();
+ break;
+ case 5:
+ return $this->getRequest();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array())
+ {
+ if (isset($alreadyDumpedObjects['AdminLog'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['AdminLog'][$this->getPrimaryKey()] = true;
+ $keys = AdminLogTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getAdminLogin(),
+ $keys[2] => $this->getAdminFirstname(),
+ $keys[3] => $this->getAdminLastname(),
+ $keys[4] => $this->getAction(),
+ $keys[5] => $this->getRequest(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AdminLogTableMap::translateFieldName($name, $type, TableMap::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->setAdminLogin($value);
+ break;
+ case 2:
+ $this->setAdminFirstname($value);
+ break;
+ case 3:
+ $this->setAdminLastname($value);
+ break;
+ case 4:
+ $this->setAction($value);
+ break;
+ case 5:
+ $this->setRequest($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = AdminLogTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setAdminLogin($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setAdminFirstname($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setAdminLastname($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setAction($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setRequest($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * 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(AdminLogTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(AdminLogTableMap::ID)) $criteria->add(AdminLogTableMap::ID, $this->id);
+ if ($this->isColumnModified(AdminLogTableMap::ADMIN_LOGIN)) $criteria->add(AdminLogTableMap::ADMIN_LOGIN, $this->admin_login);
+ if ($this->isColumnModified(AdminLogTableMap::ADMIN_FIRSTNAME)) $criteria->add(AdminLogTableMap::ADMIN_FIRSTNAME, $this->admin_firstname);
+ if ($this->isColumnModified(AdminLogTableMap::ADMIN_LASTNAME)) $criteria->add(AdminLogTableMap::ADMIN_LASTNAME, $this->admin_lastname);
+ if ($this->isColumnModified(AdminLogTableMap::ACTION)) $criteria->add(AdminLogTableMap::ACTION, $this->action);
+ if ($this->isColumnModified(AdminLogTableMap::REQUEST)) $criteria->add(AdminLogTableMap::REQUEST, $this->request);
+ if ($this->isColumnModified(AdminLogTableMap::CREATED_AT)) $criteria->add(AdminLogTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AdminLogTableMap::UPDATED_AT)) $criteria->add(AdminLogTableMap::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(AdminLogTableMap::DATABASE_NAME);
+ $criteria->add(AdminLogTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\AdminLog (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setAdminLogin($this->getAdminLogin());
+ $copyObj->setAdminFirstname($this->getAdminFirstname());
+ $copyObj->setAdminLastname($this->getAdminLastname());
+ $copyObj->setAction($this->getAction());
+ $copyObj->setRequest($this->getRequest());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\AdminLog 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;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->admin_login = null;
+ $this->admin_firstname = null;
+ $this->admin_lastname = null;
+ $this->action = null;
+ $this->request = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AdminLogTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildAdminLog The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = AdminLogTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/AdminLogQuery.php b/core/lib/Thelia/Model/Base/AdminLogQuery.php
new file mode 100644
index 000000000..53a5849b5
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AdminLogQuery.php
@@ -0,0 +1,669 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAdminLog|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AdminLogTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AdminLogTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAdminLog A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, ADMIN_LOGIN, ADMIN_FIRSTNAME, ADMIN_LASTNAME, ACTION, REQUEST, CREATED_AT, UPDATED_AT FROM admin_log WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildAdminLog();
+ $obj->hydrate($row);
+ AdminLogTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAdminLog|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AdminLogTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AdminLogTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(AdminLogTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(AdminLogTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the admin_login column
+ *
+ * Example usage:
+ *
+ * $query->filterByAdminLogin('fooValue'); // WHERE admin_login = 'fooValue'
+ * $query->filterByAdminLogin('%fooValue%'); // WHERE admin_login LIKE '%fooValue%'
+ *
+ *
+ * @param string $adminLogin The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function filterByAdminLogin($adminLogin = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($adminLogin)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $adminLogin)) {
+ $adminLogin = str_replace('*', '%', $adminLogin);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogTableMap::ADMIN_LOGIN, $adminLogin, $comparison);
+ }
+
+ /**
+ * Filter the query on the admin_firstname column
+ *
+ * Example usage:
+ *
+ * $query->filterByAdminFirstname('fooValue'); // WHERE admin_firstname = 'fooValue'
+ * $query->filterByAdminFirstname('%fooValue%'); // WHERE admin_firstname LIKE '%fooValue%'
+ *
+ *
+ * @param string $adminFirstname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function filterByAdminFirstname($adminFirstname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($adminFirstname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $adminFirstname)) {
+ $adminFirstname = str_replace('*', '%', $adminFirstname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogTableMap::ADMIN_FIRSTNAME, $adminFirstname, $comparison);
+ }
+
+ /**
+ * Filter the query on the admin_lastname column
+ *
+ * Example usage:
+ *
+ * $query->filterByAdminLastname('fooValue'); // WHERE admin_lastname = 'fooValue'
+ * $query->filterByAdminLastname('%fooValue%'); // WHERE admin_lastname LIKE '%fooValue%'
+ *
+ *
+ * @param string $adminLastname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function filterByAdminLastname($adminLastname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($adminLastname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $adminLastname)) {
+ $adminLastname = str_replace('*', '%', $adminLastname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogTableMap::ADMIN_LASTNAME, $adminLastname, $comparison);
+ }
+
+ /**
+ * Filter the query on the action column
+ *
+ * Example usage:
+ *
+ * $query->filterByAction('fooValue'); // WHERE action = 'fooValue'
+ * $query->filterByAction('%fooValue%'); // WHERE action LIKE '%fooValue%'
+ *
+ *
+ * @param string $action The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function filterByAction($action = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($action)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $action)) {
+ $action = str_replace('*', '%', $action);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogTableMap::ACTION, $action, $comparison);
+ }
+
+ /**
+ * Filter the query on the request column
+ *
+ * Example usage:
+ *
+ * $query->filterByRequest('fooValue'); // WHERE request = 'fooValue'
+ * $query->filterByRequest('%fooValue%'); // WHERE request LIKE '%fooValue%'
+ *
+ *
+ * @param string $request The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function filterByRequest($request = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($request)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $request)) {
+ $request = str_replace('*', '%', $request);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogTableMap::REQUEST, $request, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AdminLogTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AdminLogTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AdminLogTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AdminLogTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminLogTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildAdminLog $adminLog Object to remove from the list of results
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function prune($adminLog = null)
+ {
+ if ($adminLog) {
+ $this->addUsingAlias(AdminLogTableMap::ID, $adminLog->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the admin_log table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminLogTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ AdminLogTableMap::clearInstancePool();
+ AdminLogTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildAdminLog or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildAdminLog object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminLogTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminLogTableMap::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->beginTransaction();
+
+
+ AdminLogTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ AdminLogTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AdminLogTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AdminLogTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AdminLogTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AdminLogTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AdminLogTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildAdminLogQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AdminLogTableMap::CREATED_AT);
+ }
+
+} // AdminLogQuery
diff --git a/core/lib/Thelia/Model/Base/AdminQuery.php b/core/lib/Thelia/Model/Base/AdminQuery.php
new file mode 100644
index 000000000..1ac79b4fe
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AdminQuery.php
@@ -0,0 +1,799 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAdmin|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AdminTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AdminTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAdmin A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, FIRSTNAME, LASTNAME, LOGIN, PASSWORD, ALGO, SALT, CREATED_AT, UPDATED_AT FROM admin WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildAdmin();
+ $obj->hydrate($row);
+ AdminTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAdmin|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AdminTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AdminTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(AdminTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(AdminTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the firstname column
+ *
+ * Example usage:
+ *
+ * $query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue'
+ * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%'
+ *
+ *
+ * @param string $firstname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function filterByFirstname($firstname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($firstname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $firstname)) {
+ $firstname = str_replace('*', '%', $firstname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminTableMap::FIRSTNAME, $firstname, $comparison);
+ }
+
+ /**
+ * Filter the query on the lastname column
+ *
+ * Example usage:
+ *
+ * $query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue'
+ * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%'
+ *
+ *
+ * @param string $lastname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function filterByLastname($lastname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lastname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lastname)) {
+ $lastname = str_replace('*', '%', $lastname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminTableMap::LASTNAME, $lastname, $comparison);
+ }
+
+ /**
+ * Filter the query on the login column
+ *
+ * Example usage:
+ *
+ * $query->filterByLogin('fooValue'); // WHERE login = 'fooValue'
+ * $query->filterByLogin('%fooValue%'); // WHERE login LIKE '%fooValue%'
+ *
+ *
+ * @param string $login The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function filterByLogin($login = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($login)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $login)) {
+ $login = str_replace('*', '%', $login);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminTableMap::LOGIN, $login, $comparison);
+ }
+
+ /**
+ * Filter the query on the password column
+ *
+ * Example usage:
+ *
+ * $query->filterByPassword('fooValue'); // WHERE password = 'fooValue'
+ * $query->filterByPassword('%fooValue%'); // WHERE password LIKE '%fooValue%'
+ *
+ *
+ * @param string $password The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function filterByPassword($password = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($password)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $password)) {
+ $password = str_replace('*', '%', $password);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminTableMap::PASSWORD, $password, $comparison);
+ }
+
+ /**
+ * Filter the query on the algo column
+ *
+ * Example usage:
+ *
+ * $query->filterByAlgo('fooValue'); // WHERE algo = 'fooValue'
+ * $query->filterByAlgo('%fooValue%'); // WHERE algo LIKE '%fooValue%'
+ *
+ *
+ * @param string $algo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function filterByAlgo($algo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($algo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $algo)) {
+ $algo = str_replace('*', '%', $algo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminTableMap::ALGO, $algo, $comparison);
+ }
+
+ /**
+ * Filter the query on the salt column
+ *
+ * Example usage:
+ *
+ * $query->filterBySalt('fooValue'); // WHERE salt = 'fooValue'
+ * $query->filterBySalt('%fooValue%'); // WHERE salt LIKE '%fooValue%'
+ *
+ *
+ * @param string $salt The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function filterBySalt($salt = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($salt)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $salt)) {
+ $salt = str_replace('*', '%', $salt);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AdminTableMap::SALT, $salt, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AdminTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AdminTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AdminTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AdminTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AdminTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\AdminGroup object
+ *
+ * @param \Thelia\Model\AdminGroup|ObjectCollection $adminGroup the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function filterByAdminGroup($adminGroup, $comparison = null)
+ {
+ if ($adminGroup instanceof \Thelia\Model\AdminGroup) {
+ return $this
+ ->addUsingAlias(AdminTableMap::ID, $adminGroup->getAdminId(), $comparison);
+ } elseif ($adminGroup instanceof ObjectCollection) {
+ return $this
+ ->useAdminGroupQuery()
+ ->filterByPrimaryKeys($adminGroup->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAdminGroup() only accepts arguments of type \Thelia\Model\AdminGroup or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AdminGroup relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function joinAdminGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AdminGroup');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AdminGroup');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AdminGroup relation AdminGroup object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AdminGroupQuery A secondary query class using the current class as primary query
+ */
+ public function useAdminGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAdminGroup($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AdminGroup', '\Thelia\Model\AdminGroupQuery');
+ }
+
+ /**
+ * Filter the query by a related Group object
+ * using the admin_group table as cross reference
+ *
+ * @param Group $group the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function filterByGroup($group, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useAdminGroupQuery()
+ ->filterByGroup($group, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildAdmin $admin Object to remove from the list of results
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function prune($admin = null)
+ {
+ if ($admin) {
+ $this->addUsingAlias(AdminTableMap::ID, $admin->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the admin table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ AdminTableMap::clearInstancePool();
+ AdminTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildAdmin or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildAdmin object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(AdminTableMap::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->beginTransaction();
+
+
+ AdminTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ AdminTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AdminTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AdminTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AdminTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AdminTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AdminTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildAdminQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AdminTableMap::CREATED_AT);
+ }
+
+} // AdminQuery
diff --git a/core/lib/Thelia/Model/Base/Area.php b/core/lib/Thelia/Model/Base/Area.php
new file mode 100644
index 000000000..fbd3199f4
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Area.php
@@ -0,0 +1,1904 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Area instance. If
+ * obj is an instance of Area, delegates to
+ * equals(Area). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Area The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Area The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [name] column value.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+
+ return $this->name;
+ }
+
+ /**
+ * Get the [unit] column value.
+ *
+ * @return double
+ */
+ public function getUnit()
+ {
+
+ return $this->unit;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Area The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AreaTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [name] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Area The current object (for fluent API support)
+ */
+ public function setName($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->name !== $v) {
+ $this->name = $v;
+ $this->modifiedColumns[] = AreaTableMap::NAME;
+ }
+
+
+ return $this;
+ } // setName()
+
+ /**
+ * Set the value of [unit] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\Area The current object (for fluent API support)
+ */
+ public function setUnit($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->unit !== $v) {
+ $this->unit = $v;
+ $this->modifiedColumns[] = AreaTableMap::UNIT;
+ }
+
+
+ return $this;
+ } // setUnit()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Area The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = AreaTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Area The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = AreaTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AreaTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AreaTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->name = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AreaTableMap::translateFieldName('Unit', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->unit = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AreaTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AreaTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = AreaTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Area object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AreaTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildAreaQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collCountries = null;
+
+ $this->collDelivzones = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Area::setDeleted()
+ * @see Area::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AreaTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildAreaQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AreaTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(AreaTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(AreaTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(AreaTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AreaTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->countriesScheduledForDeletion !== null) {
+ if (!$this->countriesScheduledForDeletion->isEmpty()) {
+ foreach ($this->countriesScheduledForDeletion as $country) {
+ // need to save related object because we set the relation to null
+ $country->save($con);
+ }
+ $this->countriesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCountries !== null) {
+ foreach ($this->collCountries as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->delivzonesScheduledForDeletion !== null) {
+ if (!$this->delivzonesScheduledForDeletion->isEmpty()) {
+ foreach ($this->delivzonesScheduledForDeletion as $delivzone) {
+ // need to save related object because we set the relation to null
+ $delivzone->save($con);
+ }
+ $this->delivzonesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collDelivzones !== null) {
+ foreach ($this->collDelivzones as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AreaTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AreaTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AreaTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(AreaTableMap::NAME)) {
+ $modifiedColumns[':p' . $index++] = 'NAME';
+ }
+ if ($this->isColumnModified(AreaTableMap::UNIT)) {
+ $modifiedColumns[':p' . $index++] = 'UNIT';
+ }
+ if ($this->isColumnModified(AreaTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(AreaTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO area (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'NAME':
+ $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
+ break;
+ case 'UNIT':
+ $stmt->bindValue($identifier, $this->unit, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AreaTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getName();
+ break;
+ case 2:
+ return $this->getUnit();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Area'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Area'][$this->getPrimaryKey()] = true;
+ $keys = AreaTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getName(),
+ $keys[2] => $this->getUnit(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collCountries) {
+ $result['Countries'] = $this->collCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collDelivzones) {
+ $result['Delivzones'] = $this->collDelivzones->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AreaTableMap::translateFieldName($name, $type, TableMap::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->setName($value);
+ break;
+ case 2:
+ $this->setUnit($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = AreaTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setUnit($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * 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(AreaTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(AreaTableMap::ID)) $criteria->add(AreaTableMap::ID, $this->id);
+ if ($this->isColumnModified(AreaTableMap::NAME)) $criteria->add(AreaTableMap::NAME, $this->name);
+ if ($this->isColumnModified(AreaTableMap::UNIT)) $criteria->add(AreaTableMap::UNIT, $this->unit);
+ if ($this->isColumnModified(AreaTableMap::CREATED_AT)) $criteria->add(AreaTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AreaTableMap::UPDATED_AT)) $criteria->add(AreaTableMap::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(AreaTableMap::DATABASE_NAME);
+ $criteria->add(AreaTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Area (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setName($this->getName());
+ $copyObj->setUnit($this->getUnit());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getCountries() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCountry($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getDelivzones() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addDelivzone($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Area 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('Country' == $relationName) {
+ return $this->initCountries();
+ }
+ if ('Delivzone' == $relationName) {
+ return $this->initDelivzones();
+ }
+ }
+
+ /**
+ * Clears out the collCountries collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCountries()
+ */
+ public function clearCountries()
+ {
+ $this->collCountries = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCountries collection loaded partially.
+ */
+ public function resetPartialCountries($v = true)
+ {
+ $this->collCountriesPartial = $v;
+ }
+
+ /**
+ * Initializes the collCountries collection.
+ *
+ * By default this just sets the collCountries collection to an empty array (like clearcollCountries());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCountries($overrideExisting = true)
+ {
+ if (null !== $this->collCountries && !$overrideExisting) {
+ return;
+ }
+ $this->collCountries = new ObjectCollection();
+ $this->collCountries->setModel('\Thelia\Model\Country');
+ }
+
+ /**
+ * Gets an array of ChildCountry objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildArea is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCountry[] List of ChildCountry objects
+ * @throws PropelException
+ */
+ public function getCountries($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCountriesPartial && !$this->isNew();
+ if (null === $this->collCountries || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCountries) {
+ // return empty collection
+ $this->initCountries();
+ } else {
+ $collCountries = ChildCountryQuery::create(null, $criteria)
+ ->filterByArea($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCountriesPartial && count($collCountries)) {
+ $this->initCountries(false);
+
+ foreach ($collCountries as $obj) {
+ if (false == $this->collCountries->contains($obj)) {
+ $this->collCountries->append($obj);
+ }
+ }
+
+ $this->collCountriesPartial = true;
+ }
+
+ $collCountries->getInternalIterator()->rewind();
+
+ return $collCountries;
+ }
+
+ if ($partial && $this->collCountries) {
+ foreach ($this->collCountries as $obj) {
+ if ($obj->isNew()) {
+ $collCountries[] = $obj;
+ }
+ }
+ }
+
+ $this->collCountries = $collCountries;
+ $this->collCountriesPartial = false;
+ }
+ }
+
+ return $this->collCountries;
+ }
+
+ /**
+ * Sets a collection of Country objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $countries A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildArea The current object (for fluent API support)
+ */
+ public function setCountries(Collection $countries, ConnectionInterface $con = null)
+ {
+ $countriesToDelete = $this->getCountries(new Criteria(), $con)->diff($countries);
+
+
+ $this->countriesScheduledForDeletion = $countriesToDelete;
+
+ foreach ($countriesToDelete as $countryRemoved) {
+ $countryRemoved->setArea(null);
+ }
+
+ $this->collCountries = null;
+ foreach ($countries as $country) {
+ $this->addCountry($country);
+ }
+
+ $this->collCountries = $countries;
+ $this->collCountriesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Country objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Country objects.
+ * @throws PropelException
+ */
+ public function countCountries(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCountriesPartial && !$this->isNew();
+ if (null === $this->collCountries || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCountries) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCountries());
+ }
+
+ $query = ChildCountryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByArea($this)
+ ->count($con);
+ }
+
+ return count($this->collCountries);
+ }
+
+ /**
+ * Method called to associate a ChildCountry object to this object
+ * through the ChildCountry foreign key attribute.
+ *
+ * @param ChildCountry $l ChildCountry
+ * @return \Thelia\Model\Area The current object (for fluent API support)
+ */
+ public function addCountry(ChildCountry $l)
+ {
+ if ($this->collCountries === null) {
+ $this->initCountries();
+ $this->collCountriesPartial = true;
+ }
+
+ if (!in_array($l, $this->collCountries->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCountry($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Country $country The country object to add.
+ */
+ protected function doAddCountry($country)
+ {
+ $this->collCountries[]= $country;
+ $country->setArea($this);
+ }
+
+ /**
+ * @param Country $country The country object to remove.
+ * @return ChildArea The current object (for fluent API support)
+ */
+ public function removeCountry($country)
+ {
+ if ($this->getCountries()->contains($country)) {
+ $this->collCountries->remove($this->collCountries->search($country));
+ if (null === $this->countriesScheduledForDeletion) {
+ $this->countriesScheduledForDeletion = clone $this->collCountries;
+ $this->countriesScheduledForDeletion->clear();
+ }
+ $this->countriesScheduledForDeletion[]= $country;
+ $country->setArea(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collDelivzones collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addDelivzones()
+ */
+ public function clearDelivzones()
+ {
+ $this->collDelivzones = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collDelivzones collection loaded partially.
+ */
+ public function resetPartialDelivzones($v = true)
+ {
+ $this->collDelivzonesPartial = $v;
+ }
+
+ /**
+ * Initializes the collDelivzones collection.
+ *
+ * By default this just sets the collDelivzones collection to an empty array (like clearcollDelivzones());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initDelivzones($overrideExisting = true)
+ {
+ if (null !== $this->collDelivzones && !$overrideExisting) {
+ return;
+ }
+ $this->collDelivzones = new ObjectCollection();
+ $this->collDelivzones->setModel('\Thelia\Model\Delivzone');
+ }
+
+ /**
+ * Gets an array of ChildDelivzone objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildArea is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildDelivzone[] List of ChildDelivzone objects
+ * @throws PropelException
+ */
+ public function getDelivzones($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collDelivzonesPartial && !$this->isNew();
+ if (null === $this->collDelivzones || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDelivzones) {
+ // return empty collection
+ $this->initDelivzones();
+ } else {
+ $collDelivzones = ChildDelivzoneQuery::create(null, $criteria)
+ ->filterByArea($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collDelivzonesPartial && count($collDelivzones)) {
+ $this->initDelivzones(false);
+
+ foreach ($collDelivzones as $obj) {
+ if (false == $this->collDelivzones->contains($obj)) {
+ $this->collDelivzones->append($obj);
+ }
+ }
+
+ $this->collDelivzonesPartial = true;
+ }
+
+ $collDelivzones->getInternalIterator()->rewind();
+
+ return $collDelivzones;
+ }
+
+ if ($partial && $this->collDelivzones) {
+ foreach ($this->collDelivzones as $obj) {
+ if ($obj->isNew()) {
+ $collDelivzones[] = $obj;
+ }
+ }
+ }
+
+ $this->collDelivzones = $collDelivzones;
+ $this->collDelivzonesPartial = false;
+ }
+ }
+
+ return $this->collDelivzones;
+ }
+
+ /**
+ * Sets a collection of Delivzone objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $delivzones A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildArea The current object (for fluent API support)
+ */
+ public function setDelivzones(Collection $delivzones, ConnectionInterface $con = null)
+ {
+ $delivzonesToDelete = $this->getDelivzones(new Criteria(), $con)->diff($delivzones);
+
+
+ $this->delivzonesScheduledForDeletion = $delivzonesToDelete;
+
+ foreach ($delivzonesToDelete as $delivzoneRemoved) {
+ $delivzoneRemoved->setArea(null);
+ }
+
+ $this->collDelivzones = null;
+ foreach ($delivzones as $delivzone) {
+ $this->addDelivzone($delivzone);
+ }
+
+ $this->collDelivzones = $delivzones;
+ $this->collDelivzonesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Delivzone objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Delivzone objects.
+ * @throws PropelException
+ */
+ public function countDelivzones(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collDelivzonesPartial && !$this->isNew();
+ if (null === $this->collDelivzones || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDelivzones) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getDelivzones());
+ }
+
+ $query = ChildDelivzoneQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByArea($this)
+ ->count($con);
+ }
+
+ return count($this->collDelivzones);
+ }
+
+ /**
+ * Method called to associate a ChildDelivzone object to this object
+ * through the ChildDelivzone foreign key attribute.
+ *
+ * @param ChildDelivzone $l ChildDelivzone
+ * @return \Thelia\Model\Area The current object (for fluent API support)
+ */
+ public function addDelivzone(ChildDelivzone $l)
+ {
+ if ($this->collDelivzones === null) {
+ $this->initDelivzones();
+ $this->collDelivzonesPartial = true;
+ }
+
+ if (!in_array($l, $this->collDelivzones->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddDelivzone($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Delivzone $delivzone The delivzone object to add.
+ */
+ protected function doAddDelivzone($delivzone)
+ {
+ $this->collDelivzones[]= $delivzone;
+ $delivzone->setArea($this);
+ }
+
+ /**
+ * @param Delivzone $delivzone The delivzone object to remove.
+ * @return ChildArea The current object (for fluent API support)
+ */
+ public function removeDelivzone($delivzone)
+ {
+ if ($this->getDelivzones()->contains($delivzone)) {
+ $this->collDelivzones->remove($this->collDelivzones->search($delivzone));
+ if (null === $this->delivzonesScheduledForDeletion) {
+ $this->delivzonesScheduledForDeletion = clone $this->collDelivzones;
+ $this->delivzonesScheduledForDeletion->clear();
+ }
+ $this->delivzonesScheduledForDeletion[]= $delivzone;
+ $delivzone->setArea(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->name = null;
+ $this->unit = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collCountries) {
+ foreach ($this->collCountries as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collDelivzones) {
+ foreach ($this->collDelivzones as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collCountries instanceof Collection) {
+ $this->collCountries->clearIterator();
+ }
+ $this->collCountries = null;
+ if ($this->collDelivzones instanceof Collection) {
+ $this->collDelivzones->clearIterator();
+ }
+ $this->collDelivzones = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AreaTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildArea The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = AreaTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/AreaQuery.php b/core/lib/Thelia/Model/Base/AreaQuery.php
new file mode 100644
index 000000000..f583a30dd
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AreaQuery.php
@@ -0,0 +1,739 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildArea|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AreaTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AreaTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildArea A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, NAME, UNIT, CREATED_AT, UPDATED_AT FROM area WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildArea();
+ $obj->hydrate($row);
+ AreaTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildArea|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AreaTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AreaTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(AreaTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(AreaTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AreaTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the name column
+ *
+ * Example usage:
+ *
+ * $query->filterByName('fooValue'); // WHERE name = 'fooValue'
+ * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
+ *
+ *
+ * @param string $name The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function filterByName($name = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($name)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $name)) {
+ $name = str_replace('*', '%', $name);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AreaTableMap::NAME, $name, $comparison);
+ }
+
+ /**
+ * Filter the query on the unit column
+ *
+ * Example usage:
+ *
+ * $query->filterByUnit(1234); // WHERE unit = 1234
+ * $query->filterByUnit(array(12, 34)); // WHERE unit IN (12, 34)
+ * $query->filterByUnit(array('min' => 12)); // WHERE unit > 12
+ *
+ *
+ * @param mixed $unit The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function filterByUnit($unit = null, $comparison = null)
+ {
+ if (is_array($unit)) {
+ $useMinMax = false;
+ if (isset($unit['min'])) {
+ $this->addUsingAlias(AreaTableMap::UNIT, $unit['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($unit['max'])) {
+ $this->addUsingAlias(AreaTableMap::UNIT, $unit['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AreaTableMap::UNIT, $unit, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AreaTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AreaTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AreaTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AreaTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AreaTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AreaTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Country object
+ *
+ * @param \Thelia\Model\Country|ObjectCollection $country the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function filterByCountry($country, $comparison = null)
+ {
+ if ($country instanceof \Thelia\Model\Country) {
+ return $this
+ ->addUsingAlias(AreaTableMap::ID, $country->getAreaId(), $comparison);
+ } elseif ($country instanceof ObjectCollection) {
+ return $this
+ ->useCountryQuery()
+ ->filterByPrimaryKeys($country->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCountry() only accepts arguments of type \Thelia\Model\Country or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Country relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function joinCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Country');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Country');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Country relation Country object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CountryQuery A secondary query class using the current class as primary query
+ */
+ public function useCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCountry($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Delivzone object
+ *
+ * @param \Thelia\Model\Delivzone|ObjectCollection $delivzone the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function filterByDelivzone($delivzone, $comparison = null)
+ {
+ if ($delivzone instanceof \Thelia\Model\Delivzone) {
+ return $this
+ ->addUsingAlias(AreaTableMap::ID, $delivzone->getAreaId(), $comparison);
+ } elseif ($delivzone instanceof ObjectCollection) {
+ return $this
+ ->useDelivzoneQuery()
+ ->filterByPrimaryKeys($delivzone->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByDelivzone() only accepts arguments of type \Thelia\Model\Delivzone or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Delivzone relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function joinDelivzone($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Delivzone');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Delivzone');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Delivzone relation Delivzone object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\DelivzoneQuery A secondary query class using the current class as primary query
+ */
+ public function useDelivzoneQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinDelivzone($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Delivzone', '\Thelia\Model\DelivzoneQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildArea $area Object to remove from the list of results
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function prune($area = null)
+ {
+ if ($area) {
+ $this->addUsingAlias(AreaTableMap::ID, $area->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the area table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AreaTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ AreaTableMap::clearInstancePool();
+ AreaTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildArea or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildArea object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AreaTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(AreaTableMap::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->beginTransaction();
+
+
+ AreaTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ AreaTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AreaTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AreaTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AreaTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AreaTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AreaTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildAreaQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AreaTableMap::CREATED_AT);
+ }
+
+} // AreaQuery
diff --git a/core/lib/Thelia/Model/Base/Attribute.php b/core/lib/Thelia/Model/Base/Attribute.php
new file mode 100644
index 000000000..481398b95
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Attribute.php
@@ -0,0 +1,2919 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Attribute instance. If
+ * obj is an instance of Attribute, delegates to
+ * equals(Attribute). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Attribute The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Attribute The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Attribute The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AttributeTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Attribute The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = AttributeTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Attribute The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = AttributeTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Attribute The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = AttributeTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = AttributeTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Attribute object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AttributeTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildAttributeQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collAttributeAvs = null;
+
+ $this->collAttributeCombinations = null;
+
+ $this->collAttributeCategories = null;
+
+ $this->collAttributeI18ns = null;
+
+ $this->collCategories = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Attribute::setDeleted()
+ * @see Attribute::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildAttributeQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(AttributeTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(AttributeTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(AttributeTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AttributeTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->categoriesScheduledForDeletion !== null) {
+ if (!$this->categoriesScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->categoriesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($remotePk, $pk);
+ }
+
+ AttributeCategoryQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->categoriesScheduledForDeletion = null;
+ }
+
+ foreach ($this->getCategories() as $category) {
+ if ($category->isModified()) {
+ $category->save($con);
+ }
+ }
+ } elseif ($this->collCategories) {
+ foreach ($this->collCategories as $category) {
+ if ($category->isModified()) {
+ $category->save($con);
+ }
+ }
+ }
+
+ if ($this->attributeAvsScheduledForDeletion !== null) {
+ if (!$this->attributeAvsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\AttributeAvQuery::create()
+ ->filterByPrimaryKeys($this->attributeAvsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->attributeAvsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAttributeAvs !== null) {
+ foreach ($this->collAttributeAvs as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->attributeCombinationsScheduledForDeletion !== null) {
+ if (!$this->attributeCombinationsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\AttributeCombinationQuery::create()
+ ->filterByPrimaryKeys($this->attributeCombinationsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->attributeCombinationsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAttributeCombinations !== null) {
+ foreach ($this->collAttributeCombinations as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->attributeCategoriesScheduledForDeletion !== null) {
+ if (!$this->attributeCategoriesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\AttributeCategoryQuery::create()
+ ->filterByPrimaryKeys($this->attributeCategoriesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->attributeCategoriesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAttributeCategories !== null) {
+ foreach ($this->collAttributeCategories as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->attributeI18nsScheduledForDeletion !== null) {
+ if (!$this->attributeI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\AttributeI18nQuery::create()
+ ->filterByPrimaryKeys($this->attributeI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->attributeI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAttributeI18ns !== null) {
+ foreach ($this->collAttributeI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AttributeTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AttributeTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(AttributeTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(AttributeTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(AttributeTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO attribute (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AttributeTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getPosition();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Attribute'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Attribute'][$this->getPrimaryKey()] = true;
+ $keys = AttributeTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getPosition(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collAttributeAvs) {
+ $result['AttributeAvs'] = $this->collAttributeAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collAttributeCombinations) {
+ $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collAttributeCategories) {
+ $result['AttributeCategories'] = $this->collAttributeCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collAttributeI18ns) {
+ $result['AttributeI18ns'] = $this->collAttributeI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AttributeTableMap::translateFieldName($name, $type, TableMap::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->setPosition($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = AttributeTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setPosition($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * 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(AttributeTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(AttributeTableMap::ID)) $criteria->add(AttributeTableMap::ID, $this->id);
+ if ($this->isColumnModified(AttributeTableMap::POSITION)) $criteria->add(AttributeTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(AttributeTableMap::CREATED_AT)) $criteria->add(AttributeTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AttributeTableMap::UPDATED_AT)) $criteria->add(AttributeTableMap::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(AttributeTableMap::DATABASE_NAME);
+ $criteria->add(AttributeTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Attribute (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getAttributeAvs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeAv($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getAttributeCombinations() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeCombination($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getAttributeCategories() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeCategory($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getAttributeI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Attribute 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('AttributeAv' == $relationName) {
+ return $this->initAttributeAvs();
+ }
+ if ('AttributeCombination' == $relationName) {
+ return $this->initAttributeCombinations();
+ }
+ if ('AttributeCategory' == $relationName) {
+ return $this->initAttributeCategories();
+ }
+ if ('AttributeI18n' == $relationName) {
+ return $this->initAttributeI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collAttributeAvs collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAttributeAvs()
+ */
+ public function clearAttributeAvs()
+ {
+ $this->collAttributeAvs = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collAttributeAvs collection loaded partially.
+ */
+ public function resetPartialAttributeAvs($v = true)
+ {
+ $this->collAttributeAvsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAttributeAvs collection.
+ *
+ * By default this just sets the collAttributeAvs collection to an empty array (like clearcollAttributeAvs());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAttributeAvs($overrideExisting = true)
+ {
+ if (null !== $this->collAttributeAvs && !$overrideExisting) {
+ return;
+ }
+ $this->collAttributeAvs = new ObjectCollection();
+ $this->collAttributeAvs->setModel('\Thelia\Model\AttributeAv');
+ }
+
+ /**
+ * Gets an array of ChildAttributeAv objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildAttribute is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildAttributeAv[] List of ChildAttributeAv objects
+ * @throws PropelException
+ */
+ public function getAttributeAvs($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeAvsPartial && !$this->isNew();
+ if (null === $this->collAttributeAvs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeAvs) {
+ // return empty collection
+ $this->initAttributeAvs();
+ } else {
+ $collAttributeAvs = ChildAttributeAvQuery::create(null, $criteria)
+ ->filterByAttribute($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeAvsPartial && count($collAttributeAvs)) {
+ $this->initAttributeAvs(false);
+
+ foreach ($collAttributeAvs as $obj) {
+ if (false == $this->collAttributeAvs->contains($obj)) {
+ $this->collAttributeAvs->append($obj);
+ }
+ }
+
+ $this->collAttributeAvsPartial = true;
+ }
+
+ $collAttributeAvs->getInternalIterator()->rewind();
+
+ return $collAttributeAvs;
+ }
+
+ if ($partial && $this->collAttributeAvs) {
+ foreach ($this->collAttributeAvs as $obj) {
+ if ($obj->isNew()) {
+ $collAttributeAvs[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeAvs = $collAttributeAvs;
+ $this->collAttributeAvsPartial = false;
+ }
+ }
+
+ return $this->collAttributeAvs;
+ }
+
+ /**
+ * Sets a collection of AttributeAv objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $attributeAvs A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildAttribute The current object (for fluent API support)
+ */
+ public function setAttributeAvs(Collection $attributeAvs, ConnectionInterface $con = null)
+ {
+ $attributeAvsToDelete = $this->getAttributeAvs(new Criteria(), $con)->diff($attributeAvs);
+
+
+ $this->attributeAvsScheduledForDeletion = $attributeAvsToDelete;
+
+ foreach ($attributeAvsToDelete as $attributeAvRemoved) {
+ $attributeAvRemoved->setAttribute(null);
+ }
+
+ $this->collAttributeAvs = null;
+ foreach ($attributeAvs as $attributeAv) {
+ $this->addAttributeAv($attributeAv);
+ }
+
+ $this->collAttributeAvs = $attributeAvs;
+ $this->collAttributeAvsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related AttributeAv objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related AttributeAv objects.
+ * @throws PropelException
+ */
+ public function countAttributeAvs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeAvsPartial && !$this->isNew();
+ if (null === $this->collAttributeAvs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeAvs) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getAttributeAvs());
+ }
+
+ $query = ChildAttributeAvQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAttribute($this)
+ ->count($con);
+ }
+
+ return count($this->collAttributeAvs);
+ }
+
+ /**
+ * Method called to associate a ChildAttributeAv object to this object
+ * through the ChildAttributeAv foreign key attribute.
+ *
+ * @param ChildAttributeAv $l ChildAttributeAv
+ * @return \Thelia\Model\Attribute The current object (for fluent API support)
+ */
+ public function addAttributeAv(ChildAttributeAv $l)
+ {
+ if ($this->collAttributeAvs === null) {
+ $this->initAttributeAvs();
+ $this->collAttributeAvsPartial = true;
+ }
+
+ if (!in_array($l, $this->collAttributeAvs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeAv($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AttributeAv $attributeAv The attributeAv object to add.
+ */
+ protected function doAddAttributeAv($attributeAv)
+ {
+ $this->collAttributeAvs[]= $attributeAv;
+ $attributeAv->setAttribute($this);
+ }
+
+ /**
+ * @param AttributeAv $attributeAv The attributeAv object to remove.
+ * @return ChildAttribute The current object (for fluent API support)
+ */
+ public function removeAttributeAv($attributeAv)
+ {
+ if ($this->getAttributeAvs()->contains($attributeAv)) {
+ $this->collAttributeAvs->remove($this->collAttributeAvs->search($attributeAv));
+ if (null === $this->attributeAvsScheduledForDeletion) {
+ $this->attributeAvsScheduledForDeletion = clone $this->collAttributeAvs;
+ $this->attributeAvsScheduledForDeletion->clear();
+ }
+ $this->attributeAvsScheduledForDeletion[]= clone $attributeAv;
+ $attributeAv->setAttribute(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collAttributeCombinations collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAttributeCombinations()
+ */
+ public function clearAttributeCombinations()
+ {
+ $this->collAttributeCombinations = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collAttributeCombinations collection loaded partially.
+ */
+ public function resetPartialAttributeCombinations($v = true)
+ {
+ $this->collAttributeCombinationsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAttributeCombinations collection.
+ *
+ * By default this just sets the collAttributeCombinations collection to an empty array (like clearcollAttributeCombinations());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAttributeCombinations($overrideExisting = true)
+ {
+ if (null !== $this->collAttributeCombinations && !$overrideExisting) {
+ return;
+ }
+ $this->collAttributeCombinations = new ObjectCollection();
+ $this->collAttributeCombinations->setModel('\Thelia\Model\AttributeCombination');
+ }
+
+ /**
+ * Gets an array of ChildAttributeCombination objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildAttribute is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects
+ * @throws PropelException
+ */
+ public function getAttributeCombinations($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeCombinationsPartial && !$this->isNew();
+ if (null === $this->collAttributeCombinations || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCombinations) {
+ // return empty collection
+ $this->initAttributeCombinations();
+ } else {
+ $collAttributeCombinations = ChildAttributeCombinationQuery::create(null, $criteria)
+ ->filterByAttribute($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeCombinationsPartial && count($collAttributeCombinations)) {
+ $this->initAttributeCombinations(false);
+
+ foreach ($collAttributeCombinations as $obj) {
+ if (false == $this->collAttributeCombinations->contains($obj)) {
+ $this->collAttributeCombinations->append($obj);
+ }
+ }
+
+ $this->collAttributeCombinationsPartial = true;
+ }
+
+ $collAttributeCombinations->getInternalIterator()->rewind();
+
+ return $collAttributeCombinations;
+ }
+
+ if ($partial && $this->collAttributeCombinations) {
+ foreach ($this->collAttributeCombinations as $obj) {
+ if ($obj->isNew()) {
+ $collAttributeCombinations[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeCombinations = $collAttributeCombinations;
+ $this->collAttributeCombinationsPartial = false;
+ }
+ }
+
+ return $this->collAttributeCombinations;
+ }
+
+ /**
+ * Sets a collection of AttributeCombination objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $attributeCombinations A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildAttribute The current object (for fluent API support)
+ */
+ public function setAttributeCombinations(Collection $attributeCombinations, ConnectionInterface $con = null)
+ {
+ $attributeCombinationsToDelete = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->attributeCombinationsScheduledForDeletion = clone $attributeCombinationsToDelete;
+
+ foreach ($attributeCombinationsToDelete as $attributeCombinationRemoved) {
+ $attributeCombinationRemoved->setAttribute(null);
+ }
+
+ $this->collAttributeCombinations = null;
+ foreach ($attributeCombinations as $attributeCombination) {
+ $this->addAttributeCombination($attributeCombination);
+ }
+
+ $this->collAttributeCombinations = $attributeCombinations;
+ $this->collAttributeCombinationsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related AttributeCombination objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related AttributeCombination objects.
+ * @throws PropelException
+ */
+ public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeCombinationsPartial && !$this->isNew();
+ if (null === $this->collAttributeCombinations || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCombinations) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getAttributeCombinations());
+ }
+
+ $query = ChildAttributeCombinationQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAttribute($this)
+ ->count($con);
+ }
+
+ return count($this->collAttributeCombinations);
+ }
+
+ /**
+ * Method called to associate a ChildAttributeCombination object to this object
+ * through the ChildAttributeCombination foreign key attribute.
+ *
+ * @param ChildAttributeCombination $l ChildAttributeCombination
+ * @return \Thelia\Model\Attribute The current object (for fluent API support)
+ */
+ public function addAttributeCombination(ChildAttributeCombination $l)
+ {
+ if ($this->collAttributeCombinations === null) {
+ $this->initAttributeCombinations();
+ $this->collAttributeCombinationsPartial = true;
+ }
+
+ if (!in_array($l, $this->collAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeCombination($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AttributeCombination $attributeCombination The attributeCombination object to add.
+ */
+ protected function doAddAttributeCombination($attributeCombination)
+ {
+ $this->collAttributeCombinations[]= $attributeCombination;
+ $attributeCombination->setAttribute($this);
+ }
+
+ /**
+ * @param AttributeCombination $attributeCombination The attributeCombination object to remove.
+ * @return ChildAttribute The current object (for fluent API support)
+ */
+ public function removeAttributeCombination($attributeCombination)
+ {
+ if ($this->getAttributeCombinations()->contains($attributeCombination)) {
+ $this->collAttributeCombinations->remove($this->collAttributeCombinations->search($attributeCombination));
+ if (null === $this->attributeCombinationsScheduledForDeletion) {
+ $this->attributeCombinationsScheduledForDeletion = clone $this->collAttributeCombinations;
+ $this->attributeCombinationsScheduledForDeletion->clear();
+ }
+ $this->attributeCombinationsScheduledForDeletion[]= clone $attributeCombination;
+ $attributeCombination->setAttribute(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Attribute is new, it will return
+ * an empty collection; or if this Attribute has previously
+ * been saved, it will retrieve related AttributeCombinations 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 Attribute.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects
+ */
+ public function getAttributeCombinationsJoinAttributeAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildAttributeCombinationQuery::create(null, $criteria);
+ $query->joinWith('AttributeAv', $joinBehavior);
+
+ return $this->getAttributeCombinations($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Attribute is new, it will return
+ * an empty collection; or if this Attribute has previously
+ * been saved, it will retrieve related AttributeCombinations 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 Attribute.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects
+ */
+ public function getAttributeCombinationsJoinCombination($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildAttributeCombinationQuery::create(null, $criteria);
+ $query->joinWith('Combination', $joinBehavior);
+
+ return $this->getAttributeCombinations($query, $con);
+ }
+
+ /**
+ * Clears out the collAttributeCategories collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAttributeCategories()
+ */
+ public function clearAttributeCategories()
+ {
+ $this->collAttributeCategories = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collAttributeCategories collection loaded partially.
+ */
+ public function resetPartialAttributeCategories($v = true)
+ {
+ $this->collAttributeCategoriesPartial = $v;
+ }
+
+ /**
+ * Initializes the collAttributeCategories collection.
+ *
+ * By default this just sets the collAttributeCategories collection to an empty array (like clearcollAttributeCategories());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAttributeCategories($overrideExisting = true)
+ {
+ if (null !== $this->collAttributeCategories && !$overrideExisting) {
+ return;
+ }
+ $this->collAttributeCategories = new ObjectCollection();
+ $this->collAttributeCategories->setModel('\Thelia\Model\AttributeCategory');
+ }
+
+ /**
+ * Gets an array of ChildAttributeCategory objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildAttribute is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildAttributeCategory[] List of ChildAttributeCategory objects
+ * @throws PropelException
+ */
+ public function getAttributeCategories($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeCategoriesPartial && !$this->isNew();
+ if (null === $this->collAttributeCategories || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCategories) {
+ // return empty collection
+ $this->initAttributeCategories();
+ } else {
+ $collAttributeCategories = ChildAttributeCategoryQuery::create(null, $criteria)
+ ->filterByAttribute($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeCategoriesPartial && count($collAttributeCategories)) {
+ $this->initAttributeCategories(false);
+
+ foreach ($collAttributeCategories as $obj) {
+ if (false == $this->collAttributeCategories->contains($obj)) {
+ $this->collAttributeCategories->append($obj);
+ }
+ }
+
+ $this->collAttributeCategoriesPartial = true;
+ }
+
+ $collAttributeCategories->getInternalIterator()->rewind();
+
+ return $collAttributeCategories;
+ }
+
+ if ($partial && $this->collAttributeCategories) {
+ foreach ($this->collAttributeCategories as $obj) {
+ if ($obj->isNew()) {
+ $collAttributeCategories[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeCategories = $collAttributeCategories;
+ $this->collAttributeCategoriesPartial = false;
+ }
+ }
+
+ return $this->collAttributeCategories;
+ }
+
+ /**
+ * Sets a collection of AttributeCategory objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $attributeCategories A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildAttribute The current object (for fluent API support)
+ */
+ public function setAttributeCategories(Collection $attributeCategories, ConnectionInterface $con = null)
+ {
+ $attributeCategoriesToDelete = $this->getAttributeCategories(new Criteria(), $con)->diff($attributeCategories);
+
+
+ $this->attributeCategoriesScheduledForDeletion = $attributeCategoriesToDelete;
+
+ foreach ($attributeCategoriesToDelete as $attributeCategoryRemoved) {
+ $attributeCategoryRemoved->setAttribute(null);
+ }
+
+ $this->collAttributeCategories = null;
+ foreach ($attributeCategories as $attributeCategory) {
+ $this->addAttributeCategory($attributeCategory);
+ }
+
+ $this->collAttributeCategories = $attributeCategories;
+ $this->collAttributeCategoriesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related AttributeCategory objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related AttributeCategory objects.
+ * @throws PropelException
+ */
+ public function countAttributeCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeCategoriesPartial && !$this->isNew();
+ if (null === $this->collAttributeCategories || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCategories) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getAttributeCategories());
+ }
+
+ $query = ChildAttributeCategoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAttribute($this)
+ ->count($con);
+ }
+
+ return count($this->collAttributeCategories);
+ }
+
+ /**
+ * Method called to associate a ChildAttributeCategory object to this object
+ * through the ChildAttributeCategory foreign key attribute.
+ *
+ * @param ChildAttributeCategory $l ChildAttributeCategory
+ * @return \Thelia\Model\Attribute The current object (for fluent API support)
+ */
+ public function addAttributeCategory(ChildAttributeCategory $l)
+ {
+ if ($this->collAttributeCategories === null) {
+ $this->initAttributeCategories();
+ $this->collAttributeCategoriesPartial = true;
+ }
+
+ if (!in_array($l, $this->collAttributeCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeCategory($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AttributeCategory $attributeCategory The attributeCategory object to add.
+ */
+ protected function doAddAttributeCategory($attributeCategory)
+ {
+ $this->collAttributeCategories[]= $attributeCategory;
+ $attributeCategory->setAttribute($this);
+ }
+
+ /**
+ * @param AttributeCategory $attributeCategory The attributeCategory object to remove.
+ * @return ChildAttribute The current object (for fluent API support)
+ */
+ public function removeAttributeCategory($attributeCategory)
+ {
+ if ($this->getAttributeCategories()->contains($attributeCategory)) {
+ $this->collAttributeCategories->remove($this->collAttributeCategories->search($attributeCategory));
+ if (null === $this->attributeCategoriesScheduledForDeletion) {
+ $this->attributeCategoriesScheduledForDeletion = clone $this->collAttributeCategories;
+ $this->attributeCategoriesScheduledForDeletion->clear();
+ }
+ $this->attributeCategoriesScheduledForDeletion[]= clone $attributeCategory;
+ $attributeCategory->setAttribute(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Attribute is new, it will return
+ * an empty collection; or if this Attribute has previously
+ * been saved, it will retrieve related AttributeCategories 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 Attribute.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildAttributeCategory[] List of ChildAttributeCategory objects
+ */
+ public function getAttributeCategoriesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildAttributeCategoryQuery::create(null, $criteria);
+ $query->joinWith('Category', $joinBehavior);
+
+ return $this->getAttributeCategories($query, $con);
+ }
+
+ /**
+ * Clears out the collAttributeI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAttributeI18ns()
+ */
+ public function clearAttributeI18ns()
+ {
+ $this->collAttributeI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collAttributeI18ns collection loaded partially.
+ */
+ public function resetPartialAttributeI18ns($v = true)
+ {
+ $this->collAttributeI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAttributeI18ns collection.
+ *
+ * By default this just sets the collAttributeI18ns collection to an empty array (like clearcollAttributeI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAttributeI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collAttributeI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collAttributeI18ns = new ObjectCollection();
+ $this->collAttributeI18ns->setModel('\Thelia\Model\AttributeI18n');
+ }
+
+ /**
+ * Gets an array of ChildAttributeI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildAttribute is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildAttributeI18n[] List of ChildAttributeI18n objects
+ * @throws PropelException
+ */
+ public function getAttributeI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeI18nsPartial && !$this->isNew();
+ if (null === $this->collAttributeI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeI18ns) {
+ // return empty collection
+ $this->initAttributeI18ns();
+ } else {
+ $collAttributeI18ns = ChildAttributeI18nQuery::create(null, $criteria)
+ ->filterByAttribute($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeI18nsPartial && count($collAttributeI18ns)) {
+ $this->initAttributeI18ns(false);
+
+ foreach ($collAttributeI18ns as $obj) {
+ if (false == $this->collAttributeI18ns->contains($obj)) {
+ $this->collAttributeI18ns->append($obj);
+ }
+ }
+
+ $this->collAttributeI18nsPartial = true;
+ }
+
+ $collAttributeI18ns->getInternalIterator()->rewind();
+
+ return $collAttributeI18ns;
+ }
+
+ if ($partial && $this->collAttributeI18ns) {
+ foreach ($this->collAttributeI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collAttributeI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeI18ns = $collAttributeI18ns;
+ $this->collAttributeI18nsPartial = false;
+ }
+ }
+
+ return $this->collAttributeI18ns;
+ }
+
+ /**
+ * Sets a collection of AttributeI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $attributeI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildAttribute The current object (for fluent API support)
+ */
+ public function setAttributeI18ns(Collection $attributeI18ns, ConnectionInterface $con = null)
+ {
+ $attributeI18nsToDelete = $this->getAttributeI18ns(new Criteria(), $con)->diff($attributeI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->attributeI18nsScheduledForDeletion = clone $attributeI18nsToDelete;
+
+ foreach ($attributeI18nsToDelete as $attributeI18nRemoved) {
+ $attributeI18nRemoved->setAttribute(null);
+ }
+
+ $this->collAttributeI18ns = null;
+ foreach ($attributeI18ns as $attributeI18n) {
+ $this->addAttributeI18n($attributeI18n);
+ }
+
+ $this->collAttributeI18ns = $attributeI18ns;
+ $this->collAttributeI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related AttributeI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related AttributeI18n objects.
+ * @throws PropelException
+ */
+ public function countAttributeI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeI18nsPartial && !$this->isNew();
+ if (null === $this->collAttributeI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getAttributeI18ns());
+ }
+
+ $query = ChildAttributeI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAttribute($this)
+ ->count($con);
+ }
+
+ return count($this->collAttributeI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildAttributeI18n object to this object
+ * through the ChildAttributeI18n foreign key attribute.
+ *
+ * @param ChildAttributeI18n $l ChildAttributeI18n
+ * @return \Thelia\Model\Attribute The current object (for fluent API support)
+ */
+ public function addAttributeI18n(ChildAttributeI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collAttributeI18ns === null) {
+ $this->initAttributeI18ns();
+ $this->collAttributeI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collAttributeI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AttributeI18n $attributeI18n The attributeI18n object to add.
+ */
+ protected function doAddAttributeI18n($attributeI18n)
+ {
+ $this->collAttributeI18ns[]= $attributeI18n;
+ $attributeI18n->setAttribute($this);
+ }
+
+ /**
+ * @param AttributeI18n $attributeI18n The attributeI18n object to remove.
+ * @return ChildAttribute The current object (for fluent API support)
+ */
+ public function removeAttributeI18n($attributeI18n)
+ {
+ if ($this->getAttributeI18ns()->contains($attributeI18n)) {
+ $this->collAttributeI18ns->remove($this->collAttributeI18ns->search($attributeI18n));
+ if (null === $this->attributeI18nsScheduledForDeletion) {
+ $this->attributeI18nsScheduledForDeletion = clone $this->collAttributeI18ns;
+ $this->attributeI18nsScheduledForDeletion->clear();
+ }
+ $this->attributeI18nsScheduledForDeletion[]= clone $attributeI18n;
+ $attributeI18n->setAttribute(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collCategories collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCategories()
+ */
+ public function clearCategories()
+ {
+ $this->collCategories = null; // important to set this to NULL since that means it is uninitialized
+ $this->collCategoriesPartial = null;
+ }
+
+ /**
+ * Initializes the collCategories collection.
+ *
+ * By default this just sets the collCategories collection to an empty collection (like clearCategories());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initCategories()
+ {
+ $this->collCategories = new ObjectCollection();
+ $this->collCategories->setModel('\Thelia\Model\Category');
+ }
+
+ /**
+ * Gets a collection of ChildCategory objects related by a many-to-many relationship
+ * to the current object by way of the attribute_category cross-reference table.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildAttribute is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return ObjectCollection|ChildCategory[] List of ChildCategory objects
+ */
+ public function getCategories($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collCategories || null !== $criteria) {
+ if ($this->isNew() && null === $this->collCategories) {
+ // return empty collection
+ $this->initCategories();
+ } else {
+ $collCategories = ChildCategoryQuery::create(null, $criteria)
+ ->filterByAttribute($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collCategories;
+ }
+ $this->collCategories = $collCategories;
+ }
+ }
+
+ return $this->collCategories;
+ }
+
+ /**
+ * Sets a collection of Category objects related by a many-to-many relationship
+ * to the current object by way of the attribute_category cross-reference table.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $categories A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildAttribute The current object (for fluent API support)
+ */
+ public function setCategories(Collection $categories, ConnectionInterface $con = null)
+ {
+ $this->clearCategories();
+ $currentCategories = $this->getCategories();
+
+ $this->categoriesScheduledForDeletion = $currentCategories->diff($categories);
+
+ foreach ($categories as $category) {
+ if (!$currentCategories->contains($category)) {
+ $this->doAddCategory($category);
+ }
+ }
+
+ $this->collCategories = $categories;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildCategory objects related by a many-to-many relationship
+ * to the current object by way of the attribute_category cross-reference table.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param boolean $distinct Set to true to force count distinct
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return int the number of related ChildCategory objects
+ */
+ public function countCategories($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collCategories || null !== $criteria) {
+ if ($this->isNew() && null === $this->collCategories) {
+ return 0;
+ } else {
+ $query = ChildCategoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAttribute($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collCategories);
+ }
+ }
+
+ /**
+ * Associate a ChildCategory object to this object
+ * through the attribute_category cross reference table.
+ *
+ * @param ChildCategory $category The ChildAttributeCategory object to relate
+ * @return ChildAttribute The current object (for fluent API support)
+ */
+ public function addCategory(ChildCategory $category)
+ {
+ if ($this->collCategories === null) {
+ $this->initCategories();
+ }
+
+ if (!$this->collCategories->contains($category)) { // only add it if the **same** object is not already associated
+ $this->doAddCategory($category);
+ $this->collCategories[] = $category;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Category $category The category object to add.
+ */
+ protected function doAddCategory($category)
+ {
+ $attributeCategory = new ChildAttributeCategory();
+ $attributeCategory->setCategory($category);
+ $this->addAttributeCategory($attributeCategory);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$category->getAttributes()->contains($this)) {
+ $foreignCollection = $category->getAttributes();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildCategory object to this object
+ * through the attribute_category cross reference table.
+ *
+ * @param ChildCategory $category The ChildAttributeCategory object to relate
+ * @return ChildAttribute The current object (for fluent API support)
+ */
+ public function removeCategory(ChildCategory $category)
+ {
+ if ($this->getCategories()->contains($category)) {
+ $this->collCategories->remove($this->collCategories->search($category));
+
+ if (null === $this->categoriesScheduledForDeletion) {
+ $this->categoriesScheduledForDeletion = clone $this->collCategories;
+ $this->categoriesScheduledForDeletion->clear();
+ }
+
+ $this->categoriesScheduledForDeletion[] = $category;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collAttributeAvs) {
+ foreach ($this->collAttributeAvs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAttributeCombinations) {
+ foreach ($this->collAttributeCombinations as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAttributeCategories) {
+ foreach ($this->collAttributeCategories as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAttributeI18ns) {
+ foreach ($this->collAttributeI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCategories) {
+ foreach ($this->collCategories as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collAttributeAvs instanceof Collection) {
+ $this->collAttributeAvs->clearIterator();
+ }
+ $this->collAttributeAvs = null;
+ if ($this->collAttributeCombinations instanceof Collection) {
+ $this->collAttributeCombinations->clearIterator();
+ }
+ $this->collAttributeCombinations = null;
+ if ($this->collAttributeCategories instanceof Collection) {
+ $this->collAttributeCategories->clearIterator();
+ }
+ $this->collAttributeCategories = null;
+ if ($this->collAttributeI18ns instanceof Collection) {
+ $this->collAttributeI18ns->clearIterator();
+ }
+ $this->collAttributeI18ns = null;
+ if ($this->collCategories instanceof Collection) {
+ $this->collCategories->clearIterator();
+ }
+ $this->collCategories = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AttributeTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildAttribute The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = AttributeTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildAttribute The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAttributeI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collAttributeI18ns) {
+ foreach ($this->collAttributeI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildAttributeI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildAttributeI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addAttributeI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAttribute The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildAttributeI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collAttributeI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collAttributeI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAttributeI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/AttributeAv.php b/core/lib/Thelia/Model/Base/AttributeAv.php
new file mode 100644
index 000000000..baed904dd
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AttributeAv.php
@@ -0,0 +1,2257 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another AttributeAv instance. If
+ * obj is an instance of AttributeAv, delegates to
+ * equals(AttributeAv). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return AttributeAv The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return AttributeAv The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [attribute_id] column value.
+ *
+ * @return int
+ */
+ public function getAttributeId()
+ {
+
+ return $this->attribute_id;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AttributeAv The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AttributeAvTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [attribute_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AttributeAv The current object (for fluent API support)
+ */
+ public function setAttributeId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->attribute_id !== $v) {
+ $this->attribute_id = $v;
+ $this->modifiedColumns[] = AttributeAvTableMap::ATTRIBUTE_ID;
+ }
+
+ if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) {
+ $this->aAttribute = null;
+ }
+
+
+ return $this;
+ } // setAttributeId()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AttributeAv The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = AttributeAvTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\AttributeAv The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = AttributeAvTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\AttributeAv The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = AttributeAvTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeAvTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeAvTableMap::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->attribute_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeAvTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeAvTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeAvTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = AttributeAvTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\AttributeAv object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) {
+ $this->aAttribute = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AttributeAvTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildAttributeAvQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aAttribute = null;
+ $this->collAttributeCombinations = null;
+
+ $this->collAttributeAvI18ns = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see AttributeAv::setDeleted()
+ * @see AttributeAv::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildAttributeAvQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(AttributeAvTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(AttributeAvTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(AttributeAvTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AttributeAvTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aAttribute !== null) {
+ if ($this->aAttribute->isModified() || $this->aAttribute->isNew()) {
+ $affectedRows += $this->aAttribute->save($con);
+ }
+ $this->setAttribute($this->aAttribute);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->attributeCombinationsScheduledForDeletion !== null) {
+ if (!$this->attributeCombinationsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\AttributeCombinationQuery::create()
+ ->filterByPrimaryKeys($this->attributeCombinationsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->attributeCombinationsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAttributeCombinations !== null) {
+ foreach ($this->collAttributeCombinations as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->attributeAvI18nsScheduledForDeletion !== null) {
+ if (!$this->attributeAvI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\AttributeAvI18nQuery::create()
+ ->filterByPrimaryKeys($this->attributeAvI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->attributeAvI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAttributeAvI18ns !== null) {
+ foreach ($this->collAttributeAvI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AttributeAvTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeAvTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AttributeAvTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(AttributeAvTableMap::ATTRIBUTE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_ID';
+ }
+ if ($this->isColumnModified(AttributeAvTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(AttributeAvTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(AttributeAvTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO attribute_av (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'ATTRIBUTE_ID':
+ $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AttributeAvTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getAttributeId();
+ break;
+ case 2:
+ return $this->getPosition();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['AttributeAv'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['AttributeAv'][$this->getPrimaryKey()] = true;
+ $keys = AttributeAvTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getAttributeId(),
+ $keys[2] => $this->getPosition(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aAttribute) {
+ $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collAttributeCombinations) {
+ $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collAttributeAvI18ns) {
+ $result['AttributeAvI18ns'] = $this->collAttributeAvI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AttributeAvTableMap::translateFieldName($name, $type, TableMap::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->setAttributeId($value);
+ break;
+ case 2:
+ $this->setPosition($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = AttributeAvTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setAttributeId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * 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(AttributeAvTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(AttributeAvTableMap::ID)) $criteria->add(AttributeAvTableMap::ID, $this->id);
+ if ($this->isColumnModified(AttributeAvTableMap::ATTRIBUTE_ID)) $criteria->add(AttributeAvTableMap::ATTRIBUTE_ID, $this->attribute_id);
+ if ($this->isColumnModified(AttributeAvTableMap::POSITION)) $criteria->add(AttributeAvTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(AttributeAvTableMap::CREATED_AT)) $criteria->add(AttributeAvTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AttributeAvTableMap::UPDATED_AT)) $criteria->add(AttributeAvTableMap::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(AttributeAvTableMap::DATABASE_NAME);
+ $criteria->add(AttributeAvTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\AttributeAv (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setAttributeId($this->getAttributeId());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getAttributeCombinations() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeCombination($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getAttributeAvI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeAvI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\AttributeAv 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildAttribute object.
+ *
+ * @param ChildAttribute $v
+ * @return \Thelia\Model\AttributeAv The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setAttribute(ChildAttribute $v = null)
+ {
+ if ($v === null) {
+ $this->setAttributeId(NULL);
+ } else {
+ $this->setAttributeId($v->getId());
+ }
+
+ $this->aAttribute = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildAttribute object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeAv($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildAttribute object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildAttribute The associated ChildAttribute object.
+ * @throws PropelException
+ */
+ public function getAttribute(ConnectionInterface $con = null)
+ {
+ if ($this->aAttribute === null && ($this->attribute_id !== null)) {
+ $this->aAttribute = ChildAttributeQuery::create()->findPk($this->attribute_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aAttribute->addAttributeAvs($this);
+ */
+ }
+
+ return $this->aAttribute;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('AttributeCombination' == $relationName) {
+ return $this->initAttributeCombinations();
+ }
+ if ('AttributeAvI18n' == $relationName) {
+ return $this->initAttributeAvI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collAttributeCombinations collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAttributeCombinations()
+ */
+ public function clearAttributeCombinations()
+ {
+ $this->collAttributeCombinations = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collAttributeCombinations collection loaded partially.
+ */
+ public function resetPartialAttributeCombinations($v = true)
+ {
+ $this->collAttributeCombinationsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAttributeCombinations collection.
+ *
+ * By default this just sets the collAttributeCombinations collection to an empty array (like clearcollAttributeCombinations());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAttributeCombinations($overrideExisting = true)
+ {
+ if (null !== $this->collAttributeCombinations && !$overrideExisting) {
+ return;
+ }
+ $this->collAttributeCombinations = new ObjectCollection();
+ $this->collAttributeCombinations->setModel('\Thelia\Model\AttributeCombination');
+ }
+
+ /**
+ * Gets an array of ChildAttributeCombination objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildAttributeAv is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects
+ * @throws PropelException
+ */
+ public function getAttributeCombinations($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeCombinationsPartial && !$this->isNew();
+ if (null === $this->collAttributeCombinations || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCombinations) {
+ // return empty collection
+ $this->initAttributeCombinations();
+ } else {
+ $collAttributeCombinations = ChildAttributeCombinationQuery::create(null, $criteria)
+ ->filterByAttributeAv($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeCombinationsPartial && count($collAttributeCombinations)) {
+ $this->initAttributeCombinations(false);
+
+ foreach ($collAttributeCombinations as $obj) {
+ if (false == $this->collAttributeCombinations->contains($obj)) {
+ $this->collAttributeCombinations->append($obj);
+ }
+ }
+
+ $this->collAttributeCombinationsPartial = true;
+ }
+
+ $collAttributeCombinations->getInternalIterator()->rewind();
+
+ return $collAttributeCombinations;
+ }
+
+ if ($partial && $this->collAttributeCombinations) {
+ foreach ($this->collAttributeCombinations as $obj) {
+ if ($obj->isNew()) {
+ $collAttributeCombinations[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeCombinations = $collAttributeCombinations;
+ $this->collAttributeCombinationsPartial = false;
+ }
+ }
+
+ return $this->collAttributeCombinations;
+ }
+
+ /**
+ * Sets a collection of AttributeCombination objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $attributeCombinations A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildAttributeAv The current object (for fluent API support)
+ */
+ public function setAttributeCombinations(Collection $attributeCombinations, ConnectionInterface $con = null)
+ {
+ $attributeCombinationsToDelete = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->attributeCombinationsScheduledForDeletion = clone $attributeCombinationsToDelete;
+
+ foreach ($attributeCombinationsToDelete as $attributeCombinationRemoved) {
+ $attributeCombinationRemoved->setAttributeAv(null);
+ }
+
+ $this->collAttributeCombinations = null;
+ foreach ($attributeCombinations as $attributeCombination) {
+ $this->addAttributeCombination($attributeCombination);
+ }
+
+ $this->collAttributeCombinations = $attributeCombinations;
+ $this->collAttributeCombinationsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related AttributeCombination objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related AttributeCombination objects.
+ * @throws PropelException
+ */
+ public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeCombinationsPartial && !$this->isNew();
+ if (null === $this->collAttributeCombinations || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCombinations) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getAttributeCombinations());
+ }
+
+ $query = ChildAttributeCombinationQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAttributeAv($this)
+ ->count($con);
+ }
+
+ return count($this->collAttributeCombinations);
+ }
+
+ /**
+ * Method called to associate a ChildAttributeCombination object to this object
+ * through the ChildAttributeCombination foreign key attribute.
+ *
+ * @param ChildAttributeCombination $l ChildAttributeCombination
+ * @return \Thelia\Model\AttributeAv The current object (for fluent API support)
+ */
+ public function addAttributeCombination(ChildAttributeCombination $l)
+ {
+ if ($this->collAttributeCombinations === null) {
+ $this->initAttributeCombinations();
+ $this->collAttributeCombinationsPartial = true;
+ }
+
+ if (!in_array($l, $this->collAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeCombination($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AttributeCombination $attributeCombination The attributeCombination object to add.
+ */
+ protected function doAddAttributeCombination($attributeCombination)
+ {
+ $this->collAttributeCombinations[]= $attributeCombination;
+ $attributeCombination->setAttributeAv($this);
+ }
+
+ /**
+ * @param AttributeCombination $attributeCombination The attributeCombination object to remove.
+ * @return ChildAttributeAv The current object (for fluent API support)
+ */
+ public function removeAttributeCombination($attributeCombination)
+ {
+ if ($this->getAttributeCombinations()->contains($attributeCombination)) {
+ $this->collAttributeCombinations->remove($this->collAttributeCombinations->search($attributeCombination));
+ if (null === $this->attributeCombinationsScheduledForDeletion) {
+ $this->attributeCombinationsScheduledForDeletion = clone $this->collAttributeCombinations;
+ $this->attributeCombinationsScheduledForDeletion->clear();
+ }
+ $this->attributeCombinationsScheduledForDeletion[]= clone $attributeCombination;
+ $attributeCombination->setAttributeAv(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this AttributeAv is new, it will return
+ * an empty collection; or if this AttributeAv has previously
+ * been saved, it will retrieve related AttributeCombinations 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 AttributeAv.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects
+ */
+ public function getAttributeCombinationsJoinAttribute($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildAttributeCombinationQuery::create(null, $criteria);
+ $query->joinWith('Attribute', $joinBehavior);
+
+ return $this->getAttributeCombinations($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this AttributeAv is new, it will return
+ * an empty collection; or if this AttributeAv has previously
+ * been saved, it will retrieve related AttributeCombinations 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 AttributeAv.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects
+ */
+ public function getAttributeCombinationsJoinCombination($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildAttributeCombinationQuery::create(null, $criteria);
+ $query->joinWith('Combination', $joinBehavior);
+
+ return $this->getAttributeCombinations($query, $con);
+ }
+
+ /**
+ * Clears out the collAttributeAvI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAttributeAvI18ns()
+ */
+ public function clearAttributeAvI18ns()
+ {
+ $this->collAttributeAvI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collAttributeAvI18ns collection loaded partially.
+ */
+ public function resetPartialAttributeAvI18ns($v = true)
+ {
+ $this->collAttributeAvI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAttributeAvI18ns collection.
+ *
+ * By default this just sets the collAttributeAvI18ns collection to an empty array (like clearcollAttributeAvI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAttributeAvI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collAttributeAvI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collAttributeAvI18ns = new ObjectCollection();
+ $this->collAttributeAvI18ns->setModel('\Thelia\Model\AttributeAvI18n');
+ }
+
+ /**
+ * Gets an array of ChildAttributeAvI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildAttributeAv is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildAttributeAvI18n[] List of ChildAttributeAvI18n objects
+ * @throws PropelException
+ */
+ public function getAttributeAvI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeAvI18nsPartial && !$this->isNew();
+ if (null === $this->collAttributeAvI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeAvI18ns) {
+ // return empty collection
+ $this->initAttributeAvI18ns();
+ } else {
+ $collAttributeAvI18ns = ChildAttributeAvI18nQuery::create(null, $criteria)
+ ->filterByAttributeAv($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeAvI18nsPartial && count($collAttributeAvI18ns)) {
+ $this->initAttributeAvI18ns(false);
+
+ foreach ($collAttributeAvI18ns as $obj) {
+ if (false == $this->collAttributeAvI18ns->contains($obj)) {
+ $this->collAttributeAvI18ns->append($obj);
+ }
+ }
+
+ $this->collAttributeAvI18nsPartial = true;
+ }
+
+ $collAttributeAvI18ns->getInternalIterator()->rewind();
+
+ return $collAttributeAvI18ns;
+ }
+
+ if ($partial && $this->collAttributeAvI18ns) {
+ foreach ($this->collAttributeAvI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collAttributeAvI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeAvI18ns = $collAttributeAvI18ns;
+ $this->collAttributeAvI18nsPartial = false;
+ }
+ }
+
+ return $this->collAttributeAvI18ns;
+ }
+
+ /**
+ * Sets a collection of AttributeAvI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $attributeAvI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildAttributeAv The current object (for fluent API support)
+ */
+ public function setAttributeAvI18ns(Collection $attributeAvI18ns, ConnectionInterface $con = null)
+ {
+ $attributeAvI18nsToDelete = $this->getAttributeAvI18ns(new Criteria(), $con)->diff($attributeAvI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->attributeAvI18nsScheduledForDeletion = clone $attributeAvI18nsToDelete;
+
+ foreach ($attributeAvI18nsToDelete as $attributeAvI18nRemoved) {
+ $attributeAvI18nRemoved->setAttributeAv(null);
+ }
+
+ $this->collAttributeAvI18ns = null;
+ foreach ($attributeAvI18ns as $attributeAvI18n) {
+ $this->addAttributeAvI18n($attributeAvI18n);
+ }
+
+ $this->collAttributeAvI18ns = $attributeAvI18ns;
+ $this->collAttributeAvI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related AttributeAvI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related AttributeAvI18n objects.
+ * @throws PropelException
+ */
+ public function countAttributeAvI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeAvI18nsPartial && !$this->isNew();
+ if (null === $this->collAttributeAvI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeAvI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getAttributeAvI18ns());
+ }
+
+ $query = ChildAttributeAvI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByAttributeAv($this)
+ ->count($con);
+ }
+
+ return count($this->collAttributeAvI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildAttributeAvI18n object to this object
+ * through the ChildAttributeAvI18n foreign key attribute.
+ *
+ * @param ChildAttributeAvI18n $l ChildAttributeAvI18n
+ * @return \Thelia\Model\AttributeAv The current object (for fluent API support)
+ */
+ public function addAttributeAvI18n(ChildAttributeAvI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collAttributeAvI18ns === null) {
+ $this->initAttributeAvI18ns();
+ $this->collAttributeAvI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collAttributeAvI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeAvI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AttributeAvI18n $attributeAvI18n The attributeAvI18n object to add.
+ */
+ protected function doAddAttributeAvI18n($attributeAvI18n)
+ {
+ $this->collAttributeAvI18ns[]= $attributeAvI18n;
+ $attributeAvI18n->setAttributeAv($this);
+ }
+
+ /**
+ * @param AttributeAvI18n $attributeAvI18n The attributeAvI18n object to remove.
+ * @return ChildAttributeAv The current object (for fluent API support)
+ */
+ public function removeAttributeAvI18n($attributeAvI18n)
+ {
+ if ($this->getAttributeAvI18ns()->contains($attributeAvI18n)) {
+ $this->collAttributeAvI18ns->remove($this->collAttributeAvI18ns->search($attributeAvI18n));
+ if (null === $this->attributeAvI18nsScheduledForDeletion) {
+ $this->attributeAvI18nsScheduledForDeletion = clone $this->collAttributeAvI18ns;
+ $this->attributeAvI18nsScheduledForDeletion->clear();
+ }
+ $this->attributeAvI18nsScheduledForDeletion[]= clone $attributeAvI18n;
+ $attributeAvI18n->setAttributeAv(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->attribute_id = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collAttributeCombinations) {
+ foreach ($this->collAttributeCombinations as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAttributeAvI18ns) {
+ foreach ($this->collAttributeAvI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collAttributeCombinations instanceof Collection) {
+ $this->collAttributeCombinations->clearIterator();
+ }
+ $this->collAttributeCombinations = null;
+ if ($this->collAttributeAvI18ns instanceof Collection) {
+ $this->collAttributeAvI18ns->clearIterator();
+ }
+ $this->collAttributeAvI18ns = null;
+ $this->aAttribute = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AttributeAvTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildAttributeAv The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = AttributeAvTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildAttributeAv The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAttributeAvI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collAttributeAvI18ns) {
+ foreach ($this->collAttributeAvI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildAttributeAvI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildAttributeAvI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addAttributeAvI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAttributeAv The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildAttributeAvI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collAttributeAvI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collAttributeAvI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAttributeAvI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/AttributeAvI18n.php b/core/lib/Thelia/Model/Base/AttributeAvI18n.php
new file mode 100644
index 000000000..bcd1c7453
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AttributeAvI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\AttributeAvI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another AttributeAvI18n instance. If
+ * obj is an instance of AttributeAvI18n, delegates to
+ * equals(AttributeAvI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return AttributeAvI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return AttributeAvI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AttributeAvI18nTableMap::ID;
+ }
+
+ if ($this->aAttributeAv !== null && $this->aAttributeAv->getId() !== $v) {
+ $this->aAttributeAv = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = AttributeAvI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = AttributeAvI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = AttributeAvI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = AttributeAvI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = AttributeAvI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeAvI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeAvI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeAvI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeAvI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeAvI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AttributeAvI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = AttributeAvI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\AttributeAvI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aAttributeAv !== null && $this->id !== $this->aAttributeAv->getId()) {
+ $this->aAttributeAv = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AttributeAvI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildAttributeAvI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aAttributeAv = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see AttributeAvI18n::setDeleted()
+ * @see AttributeAvI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildAttributeAvI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AttributeAvI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aAttributeAv !== null) {
+ if ($this->aAttributeAv->isModified() || $this->aAttributeAv->isNew()) {
+ $affectedRows += $this->aAttributeAv->save($con);
+ }
+ $this->setAttributeAv($this->aAttributeAv);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AttributeAvI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(AttributeAvI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(AttributeAvI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(AttributeAvI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(AttributeAvI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(AttributeAvI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO attribute_av_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AttributeAvI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['AttributeAvI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['AttributeAvI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = AttributeAvI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aAttributeAv) {
+ $result['AttributeAv'] = $this->aAttributeAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AttributeAvI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = AttributeAvI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(AttributeAvI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(AttributeAvI18nTableMap::ID)) $criteria->add(AttributeAvI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(AttributeAvI18nTableMap::LOCALE)) $criteria->add(AttributeAvI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(AttributeAvI18nTableMap::TITLE)) $criteria->add(AttributeAvI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(AttributeAvI18nTableMap::DESCRIPTION)) $criteria->add(AttributeAvI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(AttributeAvI18nTableMap::CHAPO)) $criteria->add(AttributeAvI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(AttributeAvI18nTableMap::POSTSCRIPTUM)) $criteria->add(AttributeAvI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(AttributeAvI18nTableMap::DATABASE_NAME);
+ $criteria->add(AttributeAvI18nTableMap::ID, $this->id);
+ $criteria->add(AttributeAvI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\AttributeAvI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\AttributeAvI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildAttributeAv object.
+ *
+ * @param ChildAttributeAv $v
+ * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setAttributeAv(ChildAttributeAv $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aAttributeAv = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildAttributeAv object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeAvI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildAttributeAv object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildAttributeAv The associated ChildAttributeAv object.
+ * @throws PropelException
+ */
+ public function getAttributeAv(ConnectionInterface $con = null)
+ {
+ if ($this->aAttributeAv === null && ($this->id !== null)) {
+ $this->aAttributeAv = ChildAttributeAvQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aAttributeAv->addAttributeAvI18ns($this);
+ */
+ }
+
+ return $this->aAttributeAv;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aAttributeAv = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AttributeAvI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/AttributeAvI18nQuery.php b/core/lib/Thelia/Model/Base/AttributeAvI18nQuery.php
new file mode 100644
index 000000000..943e453a9
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AttributeAvI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAttributeAvI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AttributeAvI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AttributeAvI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAttributeAvI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM attribute_av_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildAttributeAvI18n();
+ $obj->hydrate($row);
+ AttributeAvI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAttributeAvI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildAttributeAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(AttributeAvI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(AttributeAvI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildAttributeAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(AttributeAvI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(AttributeAvI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByAttributeAv()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(AttributeAvI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(AttributeAvI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\AttributeAv object
+ *
+ * @param \Thelia\Model\AttributeAv|ObjectCollection $attributeAv The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByAttributeAv($attributeAv, $comparison = null)
+ {
+ if ($attributeAv instanceof \Thelia\Model\AttributeAv) {
+ return $this
+ ->addUsingAlias(AttributeAvI18nTableMap::ID, $attributeAv->getId(), $comparison);
+ } elseif ($attributeAv instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeAvI18nTableMap::ID, $attributeAv->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByAttributeAv() only accepts arguments of type \Thelia\Model\AttributeAv or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeAv relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAttributeAvI18nQuery The current query, for fluid interface
+ */
+ public function joinAttributeAv($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeAv');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AttributeAv');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeAv relation AttributeAv object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeAvQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeAvQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinAttributeAv($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeAv', '\Thelia\Model\AttributeAvQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildAttributeAvI18n $attributeAvI18n Object to remove from the list of results
+ *
+ * @return ChildAttributeAvI18nQuery The current query, for fluid interface
+ */
+ public function prune($attributeAvI18n = null)
+ {
+ if ($attributeAvI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(AttributeAvI18nTableMap::ID), $attributeAvI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(AttributeAvI18nTableMap::LOCALE), $attributeAvI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the attribute_av_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ AttributeAvI18nTableMap::clearInstancePool();
+ AttributeAvI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildAttributeAvI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildAttributeAvI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeAvI18nTableMap::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->beginTransaction();
+
+
+ AttributeAvI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ AttributeAvI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // AttributeAvI18nQuery
diff --git a/core/lib/Thelia/Model/Base/AttributeAvQuery.php b/core/lib/Thelia/Model/Base/AttributeAvQuery.php
new file mode 100644
index 000000000..4f724b4f4
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AttributeAvQuery.php
@@ -0,0 +1,890 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAttributeAv|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AttributeAvTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AttributeAvTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAttributeAv A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, ATTRIBUTE_ID, POSITION, CREATED_AT, UPDATED_AT FROM attribute_av WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildAttributeAv();
+ $obj->hydrate($row);
+ AttributeAvTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAttributeAv|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AttributeAvTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AttributeAvTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(AttributeAvTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(AttributeAvTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the attribute_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAttributeId(1234); // WHERE attribute_id = 1234
+ * $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34)
+ * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12
+ *
+ *
+ * @see filterByAttribute()
+ *
+ * @param mixed $attributeId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByAttributeId($attributeId = null, $comparison = null)
+ {
+ if (is_array($attributeId)) {
+ $useMinMax = false;
+ if (isset($attributeId['min'])) {
+ $this->addUsingAlias(AttributeAvTableMap::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($attributeId['max'])) {
+ $this->addUsingAlias(AttributeAvTableMap::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvTableMap::ATTRIBUTE_ID, $attributeId, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(AttributeAvTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(AttributeAvTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AttributeAvTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AttributeAvTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AttributeAvTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AttributeAvTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeAvTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Attribute object
+ *
+ * @param \Thelia\Model\Attribute|ObjectCollection $attribute The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByAttribute($attribute, $comparison = null)
+ {
+ if ($attribute instanceof \Thelia\Model\Attribute) {
+ return $this
+ ->addUsingAlias(AttributeAvTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison);
+ } elseif ($attribute instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeAvTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Attribute relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Attribute');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Attribute');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Attribute relation Attribute object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttribute($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\AttributeCombination object
+ *
+ * @param \Thelia\Model\AttributeCombination|ObjectCollection $attributeCombination the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByAttributeCombination($attributeCombination, $comparison = null)
+ {
+ if ($attributeCombination instanceof \Thelia\Model\AttributeCombination) {
+ return $this
+ ->addUsingAlias(AttributeAvTableMap::ID, $attributeCombination->getAttributeAvId(), $comparison);
+ } elseif ($attributeCombination instanceof ObjectCollection) {
+ return $this
+ ->useAttributeCombinationQuery()
+ ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeCombination() only accepts arguments of type \Thelia\Model\AttributeCombination or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeCombination relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function joinAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeCombination');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AttributeCombination');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeCombination relation AttributeCombination object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeCombinationQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeCombination($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeCombination', '\Thelia\Model\AttributeCombinationQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\AttributeAvI18n object
+ *
+ * @param \Thelia\Model\AttributeAvI18n|ObjectCollection $attributeAvI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function filterByAttributeAvI18n($attributeAvI18n, $comparison = null)
+ {
+ if ($attributeAvI18n instanceof \Thelia\Model\AttributeAvI18n) {
+ return $this
+ ->addUsingAlias(AttributeAvTableMap::ID, $attributeAvI18n->getId(), $comparison);
+ } elseif ($attributeAvI18n instanceof ObjectCollection) {
+ return $this
+ ->useAttributeAvI18nQuery()
+ ->filterByPrimaryKeys($attributeAvI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeAvI18n() only accepts arguments of type \Thelia\Model\AttributeAvI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeAvI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function joinAttributeAvI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeAvI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AttributeAvI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeAvI18n relation AttributeAvI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeAvI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeAvI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinAttributeAvI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeAvI18n', '\Thelia\Model\AttributeAvI18nQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildAttributeAv $attributeAv Object to remove from the list of results
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function prune($attributeAv = null)
+ {
+ if ($attributeAv) {
+ $this->addUsingAlias(AttributeAvTableMap::ID, $attributeAv->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the attribute_av table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ AttributeAvTableMap::clearInstancePool();
+ AttributeAvTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildAttributeAv or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildAttributeAv object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeAvTableMap::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->beginTransaction();
+
+
+ AttributeAvTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ AttributeAvTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AttributeAvTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AttributeAvTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AttributeAvTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AttributeAvTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AttributeAvTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AttributeAvTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'AttributeAvI18n';
+
+ return $this
+ ->joinAttributeAvI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildAttributeAvQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('AttributeAvI18n');
+ $this->with['AttributeAvI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildAttributeAvI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeAvI18n', '\Thelia\Model\AttributeAvI18nQuery');
+ }
+
+} // AttributeAvQuery
diff --git a/core/lib/Thelia/Model/Base/AttributeCategory.php b/core/lib/Thelia/Model/Base/AttributeCategory.php
new file mode 100644
index 000000000..691fa43ad
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AttributeCategory.php
@@ -0,0 +1,1495 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another AttributeCategory instance. If
+ * obj is an instance of AttributeCategory, delegates to
+ * equals(AttributeCategory). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return AttributeCategory The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return AttributeCategory The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+
+ return $this->category_id;
+ }
+
+ /**
+ * Get the [attribute_id] column value.
+ *
+ * @return int
+ */
+ public function getAttributeId()
+ {
+
+ return $this->attribute_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AttributeCategory The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AttributeCategoryTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AttributeCategory The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = AttributeCategoryTableMap::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Set the value of [attribute_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AttributeCategory The current object (for fluent API support)
+ */
+ public function setAttributeId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->attribute_id !== $v) {
+ $this->attribute_id = $v;
+ $this->modifiedColumns[] = AttributeCategoryTableMap::ATTRIBUTE_ID;
+ }
+
+ if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) {
+ $this->aAttribute = null;
+ }
+
+
+ return $this;
+ } // setAttributeId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\AttributeCategory The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = AttributeCategoryTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\AttributeCategory The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = AttributeCategoryTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeCategoryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeCategoryTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->category_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeCategoryTableMap::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->attribute_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeCategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeCategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = AttributeCategoryTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\AttributeCategory object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) {
+ $this->aAttribute = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AttributeCategoryTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildAttributeCategoryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCategory = null;
+ $this->aAttribute = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see AttributeCategory::setDeleted()
+ * @see AttributeCategory::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildAttributeCategoryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(AttributeCategoryTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AttributeCategoryTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->aAttribute !== null) {
+ if ($this->aAttribute->isModified() || $this->aAttribute->isNew()) {
+ $affectedRows += $this->aAttribute->save($con);
+ }
+ $this->setAttribute($this->aAttribute);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AttributeCategoryTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeCategoryTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AttributeCategoryTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(AttributeCategoryTableMap::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CATEGORY_ID';
+ }
+ if ($this->isColumnModified(AttributeCategoryTableMap::ATTRIBUTE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_ID';
+ }
+ if ($this->isColumnModified(AttributeCategoryTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO attribute_category (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'CATEGORY_ID':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ case 'ATTRIBUTE_ID':
+ $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AttributeCategoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getCategoryId();
+ break;
+ case 2:
+ return $this->getAttributeId();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['AttributeCategory'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['AttributeCategory'][$this->getPrimaryKey()] = true;
+ $keys = AttributeCategoryTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCategoryId(),
+ $keys[2] => $this->getAttributeId(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aAttribute) {
+ $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AttributeCategoryTableMap::translateFieldName($name, $type, TableMap::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->setCategoryId($value);
+ break;
+ case 2:
+ $this->setAttributeId($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = AttributeCategoryTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setAttributeId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * 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(AttributeCategoryTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(AttributeCategoryTableMap::ID)) $criteria->add(AttributeCategoryTableMap::ID, $this->id);
+ if ($this->isColumnModified(AttributeCategoryTableMap::CATEGORY_ID)) $criteria->add(AttributeCategoryTableMap::CATEGORY_ID, $this->category_id);
+ if ($this->isColumnModified(AttributeCategoryTableMap::ATTRIBUTE_ID)) $criteria->add(AttributeCategoryTableMap::ATTRIBUTE_ID, $this->attribute_id);
+ if ($this->isColumnModified(AttributeCategoryTableMap::CREATED_AT)) $criteria->add(AttributeCategoryTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) $criteria->add(AttributeCategoryTableMap::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(AttributeCategoryTableMap::DATABASE_NAME);
+ $criteria->add(AttributeCategoryTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\AttributeCategory (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCategoryId($this->getCategoryId());
+ $copyObj->setAttributeId($this->getAttributeId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\AttributeCategory 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCategory object.
+ *
+ * @param ChildCategory $v
+ * @return \Thelia\Model\AttributeCategory The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCategory(ChildCategory $v = null)
+ {
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
+ }
+
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCategory object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeCategory($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCategory object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCategory The associated ChildCategory object.
+ * @throws PropelException
+ */
+ public function getCategory(ConnectionInterface $con = null)
+ {
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCategory->addAttributeCategories($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Declares an association between this object and a ChildAttribute object.
+ *
+ * @param ChildAttribute $v
+ * @return \Thelia\Model\AttributeCategory The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setAttribute(ChildAttribute $v = null)
+ {
+ if ($v === null) {
+ $this->setAttributeId(NULL);
+ } else {
+ $this->setAttributeId($v->getId());
+ }
+
+ $this->aAttribute = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildAttribute object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeCategory($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildAttribute object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildAttribute The associated ChildAttribute object.
+ * @throws PropelException
+ */
+ public function getAttribute(ConnectionInterface $con = null)
+ {
+ if ($this->aAttribute === null && ($this->attribute_id !== null)) {
+ $this->aAttribute = ChildAttributeQuery::create()->findPk($this->attribute_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aAttribute->addAttributeCategories($this);
+ */
+ }
+
+ return $this->aAttribute;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->category_id = null;
+ $this->attribute_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCategory = null;
+ $this->aAttribute = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AttributeCategoryTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildAttributeCategory The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = AttributeCategoryTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/AttributeCategoryQuery.php b/core/lib/Thelia/Model/Base/AttributeCategoryQuery.php
new file mode 100644
index 000000000..d325d2037
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AttributeCategoryQuery.php
@@ -0,0 +1,759 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAttributeCategory|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AttributeCategoryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AttributeCategoryTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAttributeCategory A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CATEGORY_ID, ATTRIBUTE_ID, CREATED_AT, UPDATED_AT FROM attribute_category WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildAttributeCategory();
+ $obj->hydrate($row);
+ AttributeCategoryTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAttributeCategory|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AttributeCategoryTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AttributeCategoryTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(AttributeCategoryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(AttributeCategoryTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCategoryTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId)) {
+ $useMinMax = false;
+ if (isset($categoryId['min'])) {
+ $this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($categoryId['max'])) {
+ $this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the attribute_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAttributeId(1234); // WHERE attribute_id = 1234
+ * $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34)
+ * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12
+ *
+ *
+ * @see filterByAttribute()
+ *
+ * @param mixed $attributeId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterByAttributeId($attributeId = null, $comparison = null)
+ {
+ if (is_array($attributeId)) {
+ $useMinMax = false;
+ if (isset($attributeId['min'])) {
+ $this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($attributeId['max'])) {
+ $this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Category object
+ *
+ * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCategory($category, $comparison = null)
+ {
+ if ($category instanceof \Thelia\Model\Category) {
+ return $this
+ ->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Category relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Category');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Category');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Category relation Category object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Attribute object
+ *
+ * @param \Thelia\Model\Attribute|ObjectCollection $attribute The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function filterByAttribute($attribute, $comparison = null)
+ {
+ if ($attribute instanceof \Thelia\Model\Attribute) {
+ return $this
+ ->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison);
+ } elseif ($attribute instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Attribute relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Attribute');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Attribute');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Attribute relation Attribute object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttribute($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildAttributeCategory $attributeCategory Object to remove from the list of results
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function prune($attributeCategory = null)
+ {
+ if ($attributeCategory) {
+ $this->addUsingAlias(AttributeCategoryTableMap::ID, $attributeCategory->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the attribute_category table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ AttributeCategoryTableMap::clearInstancePool();
+ AttributeCategoryTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildAttributeCategory or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildAttributeCategory object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCategoryTableMap::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->beginTransaction();
+
+
+ AttributeCategoryTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ AttributeCategoryTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AttributeCategoryTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AttributeCategoryTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AttributeCategoryTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildAttributeCategoryQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AttributeCategoryTableMap::CREATED_AT);
+ }
+
+} // AttributeCategoryQuery
diff --git a/core/lib/Thelia/Model/Base/AttributeCombination.php b/core/lib/Thelia/Model/Base/AttributeCombination.php
new file mode 100644
index 000000000..53e671777
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AttributeCombination.php
@@ -0,0 +1,1643 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another AttributeCombination instance. If
+ * obj is an instance of AttributeCombination, delegates to
+ * equals(AttributeCombination). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return AttributeCombination The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return AttributeCombination The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [attribute_id] column value.
+ *
+ * @return int
+ */
+ public function getAttributeId()
+ {
+
+ return $this->attribute_id;
+ }
+
+ /**
+ * Get the [combination_id] column value.
+ *
+ * @return int
+ */
+ public function getCombinationId()
+ {
+
+ return $this->combination_id;
+ }
+
+ /**
+ * Get the [attribute_av_id] column value.
+ *
+ * @return int
+ */
+ public function getAttributeAvId()
+ {
+
+ return $this->attribute_av_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AttributeCombination The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AttributeCombinationTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [attribute_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AttributeCombination The current object (for fluent API support)
+ */
+ public function setAttributeId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->attribute_id !== $v) {
+ $this->attribute_id = $v;
+ $this->modifiedColumns[] = AttributeCombinationTableMap::ATTRIBUTE_ID;
+ }
+
+ if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) {
+ $this->aAttribute = null;
+ }
+
+
+ return $this;
+ } // setAttributeId()
+
+ /**
+ * Set the value of [combination_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AttributeCombination The current object (for fluent API support)
+ */
+ public function setCombinationId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->combination_id !== $v) {
+ $this->combination_id = $v;
+ $this->modifiedColumns[] = AttributeCombinationTableMap::COMBINATION_ID;
+ }
+
+ if ($this->aCombination !== null && $this->aCombination->getId() !== $v) {
+ $this->aCombination = null;
+ }
+
+
+ return $this;
+ } // setCombinationId()
+
+ /**
+ * Set the value of [attribute_av_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AttributeCombination The current object (for fluent API support)
+ */
+ public function setAttributeAvId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->attribute_av_id !== $v) {
+ $this->attribute_av_id = $v;
+ $this->modifiedColumns[] = AttributeCombinationTableMap::ATTRIBUTE_AV_ID;
+ }
+
+ if ($this->aAttributeAv !== null && $this->aAttributeAv->getId() !== $v) {
+ $this->aAttributeAv = null;
+ }
+
+
+ return $this;
+ } // setAttributeAvId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\AttributeCombination The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = AttributeCombinationTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\AttributeCombination The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = AttributeCombinationTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeCombinationTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeCombinationTableMap::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->attribute_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeCombinationTableMap::translateFieldName('CombinationId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->combination_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeCombinationTableMap::translateFieldName('AttributeAvId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->attribute_av_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeCombinationTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AttributeCombinationTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = AttributeCombinationTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\AttributeCombination object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) {
+ $this->aAttribute = null;
+ }
+ if ($this->aCombination !== null && $this->combination_id !== $this->aCombination->getId()) {
+ $this->aCombination = null;
+ }
+ if ($this->aAttributeAv !== null && $this->attribute_av_id !== $this->aAttributeAv->getId()) {
+ $this->aAttributeAv = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AttributeCombinationTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildAttributeCombinationQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aAttribute = null;
+ $this->aAttributeAv = null;
+ $this->aCombination = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see AttributeCombination::setDeleted()
+ * @see AttributeCombination::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeCombinationTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildAttributeCombinationQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeCombinationTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(AttributeCombinationTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(AttributeCombinationTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(AttributeCombinationTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AttributeCombinationTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aAttribute !== null) {
+ if ($this->aAttribute->isModified() || $this->aAttribute->isNew()) {
+ $affectedRows += $this->aAttribute->save($con);
+ }
+ $this->setAttribute($this->aAttribute);
+ }
+
+ if ($this->aAttributeAv !== null) {
+ if ($this->aAttributeAv->isModified() || $this->aAttributeAv->isNew()) {
+ $affectedRows += $this->aAttributeAv->save($con);
+ }
+ $this->setAttributeAv($this->aAttributeAv);
+ }
+
+ if ($this->aCombination !== null) {
+ if ($this->aCombination->isModified() || $this->aCombination->isNew()) {
+ $affectedRows += $this->aCombination->save($con);
+ }
+ $this->setCombination($this->aCombination);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = AttributeCombinationTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeCombinationTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AttributeCombinationTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(AttributeCombinationTableMap::ATTRIBUTE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_ID';
+ }
+ if ($this->isColumnModified(AttributeCombinationTableMap::COMBINATION_ID)) {
+ $modifiedColumns[':p' . $index++] = 'COMBINATION_ID';
+ }
+ if ($this->isColumnModified(AttributeCombinationTableMap::ATTRIBUTE_AV_ID)) {
+ $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_ID';
+ }
+ if ($this->isColumnModified(AttributeCombinationTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(AttributeCombinationTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO attribute_combination (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'ATTRIBUTE_ID':
+ $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT);
+ break;
+ case 'COMBINATION_ID':
+ $stmt->bindValue($identifier, $this->combination_id, PDO::PARAM_INT);
+ break;
+ case 'ATTRIBUTE_AV_ID':
+ $stmt->bindValue($identifier, $this->attribute_av_id, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AttributeCombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getAttributeId();
+ break;
+ case 2:
+ return $this->getCombinationId();
+ break;
+ case 3:
+ return $this->getAttributeAvId();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['AttributeCombination'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['AttributeCombination'][serialize($this->getPrimaryKey())] = true;
+ $keys = AttributeCombinationTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getAttributeId(),
+ $keys[2] => $this->getCombinationId(),
+ $keys[3] => $this->getAttributeAvId(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aAttribute) {
+ $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aAttributeAv) {
+ $result['AttributeAv'] = $this->aAttributeAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCombination) {
+ $result['Combination'] = $this->aCombination->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AttributeCombinationTableMap::translateFieldName($name, $type, TableMap::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->setAttributeId($value);
+ break;
+ case 2:
+ $this->setCombinationId($value);
+ break;
+ case 3:
+ $this->setAttributeAvId($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = AttributeCombinationTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setAttributeId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCombinationId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setAttributeAvId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(AttributeCombinationTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(AttributeCombinationTableMap::ID)) $criteria->add(AttributeCombinationTableMap::ID, $this->id);
+ if ($this->isColumnModified(AttributeCombinationTableMap::ATTRIBUTE_ID)) $criteria->add(AttributeCombinationTableMap::ATTRIBUTE_ID, $this->attribute_id);
+ if ($this->isColumnModified(AttributeCombinationTableMap::COMBINATION_ID)) $criteria->add(AttributeCombinationTableMap::COMBINATION_ID, $this->combination_id);
+ if ($this->isColumnModified(AttributeCombinationTableMap::ATTRIBUTE_AV_ID)) $criteria->add(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $this->attribute_av_id);
+ if ($this->isColumnModified(AttributeCombinationTableMap::CREATED_AT)) $criteria->add(AttributeCombinationTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(AttributeCombinationTableMap::UPDATED_AT)) $criteria->add(AttributeCombinationTableMap::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(AttributeCombinationTableMap::DATABASE_NAME);
+ $criteria->add(AttributeCombinationTableMap::ID, $this->id);
+ $criteria->add(AttributeCombinationTableMap::ATTRIBUTE_ID, $this->attribute_id);
+ $criteria->add(AttributeCombinationTableMap::COMBINATION_ID, $this->combination_id);
+ $criteria->add(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $this->attribute_av_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getAttributeId();
+ $pks[2] = $this->getCombinationId();
+ $pks[3] = $this->getAttributeAvId();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setAttributeId($keys[1]);
+ $this->setCombinationId($keys[2]);
+ $this->setAttributeAvId($keys[3]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getAttributeId()) && (null === $this->getCombinationId()) && (null === $this->getAttributeAvId());
+ }
+
+ /**
+ * 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 \Thelia\Model\AttributeCombination (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setAttributeId($this->getAttributeId());
+ $copyObj->setCombinationId($this->getCombinationId());
+ $copyObj->setAttributeAvId($this->getAttributeAvId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\AttributeCombination 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildAttribute object.
+ *
+ * @param ChildAttribute $v
+ * @return \Thelia\Model\AttributeCombination The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setAttribute(ChildAttribute $v = null)
+ {
+ if ($v === null) {
+ $this->setAttributeId(NULL);
+ } else {
+ $this->setAttributeId($v->getId());
+ }
+
+ $this->aAttribute = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildAttribute object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeCombination($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildAttribute object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildAttribute The associated ChildAttribute object.
+ * @throws PropelException
+ */
+ public function getAttribute(ConnectionInterface $con = null)
+ {
+ if ($this->aAttribute === null && ($this->attribute_id !== null)) {
+ $this->aAttribute = ChildAttributeQuery::create()->findPk($this->attribute_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aAttribute->addAttributeCombinations($this);
+ */
+ }
+
+ return $this->aAttribute;
+ }
+
+ /**
+ * Declares an association between this object and a ChildAttributeAv object.
+ *
+ * @param ChildAttributeAv $v
+ * @return \Thelia\Model\AttributeCombination The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setAttributeAv(ChildAttributeAv $v = null)
+ {
+ if ($v === null) {
+ $this->setAttributeAvId(NULL);
+ } else {
+ $this->setAttributeAvId($v->getId());
+ }
+
+ $this->aAttributeAv = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildAttributeAv object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeCombination($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildAttributeAv object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildAttributeAv The associated ChildAttributeAv object.
+ * @throws PropelException
+ */
+ public function getAttributeAv(ConnectionInterface $con = null)
+ {
+ if ($this->aAttributeAv === null && ($this->attribute_av_id !== null)) {
+ $this->aAttributeAv = ChildAttributeAvQuery::create()->findPk($this->attribute_av_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aAttributeAv->addAttributeCombinations($this);
+ */
+ }
+
+ return $this->aAttributeAv;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCombination object.
+ *
+ * @param ChildCombination $v
+ * @return \Thelia\Model\AttributeCombination The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCombination(ChildCombination $v = null)
+ {
+ if ($v === null) {
+ $this->setCombinationId(NULL);
+ } else {
+ $this->setCombinationId($v->getId());
+ }
+
+ $this->aCombination = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCombination object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeCombination($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCombination object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCombination The associated ChildCombination object.
+ * @throws PropelException
+ */
+ public function getCombination(ConnectionInterface $con = null)
+ {
+ if ($this->aCombination === null && ($this->combination_id !== null)) {
+ $this->aCombination = ChildCombinationQuery::create()->findPk($this->combination_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCombination->addAttributeCombinations($this);
+ */
+ }
+
+ return $this->aCombination;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->attribute_id = null;
+ $this->combination_id = null;
+ $this->attribute_av_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aAttribute = null;
+ $this->aAttributeAv = null;
+ $this->aCombination = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AttributeCombinationTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildAttributeCombination The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = AttributeCombinationTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/AttributeCombinationQuery.php b/core/lib/Thelia/Model/Base/AttributeCombinationQuery.php
new file mode 100644
index 000000000..6ccd2fcba
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AttributeCombinationQuery.php
@@ -0,0 +1,909 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34, 56, 78), $con);
+ *
+ *
+ * @param array[$id, $attribute_id, $combination_id, $attribute_av_id] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAttributeCombination|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AttributeCombinationTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2], (string) $key[3]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AttributeCombinationTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAttributeCombination A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, ATTRIBUTE_ID, COMBINATION_ID, ATTRIBUTE_AV_ID, CREATED_AT, UPDATED_AT FROM attribute_combination WHERE ID = :p0 AND ATTRIBUTE_ID = :p1 AND COMBINATION_ID = :p2 AND ATTRIBUTE_AV_ID = :p3';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
+ $stmt->bindValue(':p2', $key[2], PDO::PARAM_INT);
+ $stmt->bindValue(':p3', $key[3], PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildAttributeCombination();
+ $obj->hydrate($row);
+ AttributeCombinationTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2], (string) $key[3])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAttributeCombination|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(AttributeCombinationTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_ID, $key[1], Criteria::EQUAL);
+ $this->addUsingAlias(AttributeCombinationTableMap::COMBINATION_ID, $key[2], Criteria::EQUAL);
+ $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $key[3], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(AttributeCombinationTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(AttributeCombinationTableMap::ATTRIBUTE_ID, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $cton2 = $this->getNewCriterion(AttributeCombinationTableMap::COMBINATION_ID, $key[2], Criteria::EQUAL);
+ $cton0->addAnd($cton2);
+ $cton3 = $this->getNewCriterion(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $key[3], Criteria::EQUAL);
+ $cton0->addAnd($cton3);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(AttributeCombinationTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(AttributeCombinationTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCombinationTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the attribute_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAttributeId(1234); // WHERE attribute_id = 1234
+ * $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34)
+ * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12
+ *
+ *
+ * @see filterByAttribute()
+ *
+ * @param mixed $attributeId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByAttributeId($attributeId = null, $comparison = null)
+ {
+ if (is_array($attributeId)) {
+ $useMinMax = false;
+ if (isset($attributeId['min'])) {
+ $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($attributeId['max'])) {
+ $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_ID, $attributeId, $comparison);
+ }
+
+ /**
+ * Filter the query on the combination_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCombinationId(1234); // WHERE combination_id = 1234
+ * $query->filterByCombinationId(array(12, 34)); // WHERE combination_id IN (12, 34)
+ * $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id > 12
+ *
+ *
+ * @see filterByCombination()
+ *
+ * @param mixed $combinationId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByCombinationId($combinationId = null, $comparison = null)
+ {
+ if (is_array($combinationId)) {
+ $useMinMax = false;
+ if (isset($combinationId['min'])) {
+ $this->addUsingAlias(AttributeCombinationTableMap::COMBINATION_ID, $combinationId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($combinationId['max'])) {
+ $this->addUsingAlias(AttributeCombinationTableMap::COMBINATION_ID, $combinationId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCombinationTableMap::COMBINATION_ID, $combinationId, $comparison);
+ }
+
+ /**
+ * Filter the query on the attribute_av_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAttributeAvId(1234); // WHERE attribute_av_id = 1234
+ * $query->filterByAttributeAvId(array(12, 34)); // WHERE attribute_av_id IN (12, 34)
+ * $query->filterByAttributeAvId(array('min' => 12)); // WHERE attribute_av_id > 12
+ *
+ *
+ * @see filterByAttributeAv()
+ *
+ * @param mixed $attributeAvId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByAttributeAvId($attributeAvId = null, $comparison = null)
+ {
+ if (is_array($attributeAvId)) {
+ $useMinMax = false;
+ if (isset($attributeAvId['min'])) {
+ $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $attributeAvId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($attributeAvId['max'])) {
+ $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $attributeAvId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $attributeAvId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AttributeCombinationTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AttributeCombinationTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCombinationTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AttributeCombinationTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AttributeCombinationTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeCombinationTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Attribute object
+ *
+ * @param \Thelia\Model\Attribute|ObjectCollection $attribute The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByAttribute($attribute, $comparison = null)
+ {
+ if ($attribute instanceof \Thelia\Model\Attribute) {
+ return $this
+ ->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison);
+ } elseif ($attribute instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Attribute relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Attribute');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Attribute');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Attribute relation Attribute object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttribute($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\AttributeAv object
+ *
+ * @param \Thelia\Model\AttributeAv|ObjectCollection $attributeAv The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByAttributeAv($attributeAv, $comparison = null)
+ {
+ if ($attributeAv instanceof \Thelia\Model\AttributeAv) {
+ return $this
+ ->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $attributeAv->getId(), $comparison);
+ } elseif ($attributeAv instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $attributeAv->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByAttributeAv() only accepts arguments of type \Thelia\Model\AttributeAv or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeAv relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function joinAttributeAv($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeAv');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AttributeAv');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeAv relation AttributeAv object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeAvQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeAv($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeAv', '\Thelia\Model\AttributeAvQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Combination object
+ *
+ * @param \Thelia\Model\Combination|ObjectCollection $combination The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function filterByCombination($combination, $comparison = null)
+ {
+ if ($combination instanceof \Thelia\Model\Combination) {
+ return $this
+ ->addUsingAlias(AttributeCombinationTableMap::COMBINATION_ID, $combination->getId(), $comparison);
+ } elseif ($combination instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeCombinationTableMap::COMBINATION_ID, $combination->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCombination() only accepts arguments of type \Thelia\Model\Combination or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Combination relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function joinCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Combination');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Combination');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Combination relation Combination object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CombinationQuery A secondary query class using the current class as primary query
+ */
+ public function useCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCombination($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Combination', '\Thelia\Model\CombinationQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildAttributeCombination $attributeCombination Object to remove from the list of results
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function prune($attributeCombination = null)
+ {
+ if ($attributeCombination) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(AttributeCombinationTableMap::ID), $attributeCombination->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(AttributeCombinationTableMap::ATTRIBUTE_ID), $attributeCombination->getAttributeId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond2', $this->getAliasedColName(AttributeCombinationTableMap::COMBINATION_ID), $attributeCombination->getCombinationId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond3', $this->getAliasedColName(AttributeCombinationTableMap::ATTRIBUTE_AV_ID), $attributeCombination->getAttributeAvId(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2', 'pruneCond3'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the attribute_combination table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeCombinationTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ AttributeCombinationTableMap::clearInstancePool();
+ AttributeCombinationTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildAttributeCombination or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildAttributeCombination object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeCombinationTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeCombinationTableMap::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->beginTransaction();
+
+
+ AttributeCombinationTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ AttributeCombinationTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AttributeCombinationTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AttributeCombinationTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AttributeCombinationTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AttributeCombinationTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AttributeCombinationTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildAttributeCombinationQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AttributeCombinationTableMap::CREATED_AT);
+ }
+
+} // AttributeCombinationQuery
diff --git a/core/lib/Thelia/Model/Base/AttributeI18n.php b/core/lib/Thelia/Model/Base/AttributeI18n.php
new file mode 100644
index 000000000..b8865769c
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AttributeI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\AttributeI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another AttributeI18n instance. If
+ * obj is an instance of AttributeI18n, delegates to
+ * equals(AttributeI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return AttributeI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return AttributeI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\AttributeI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = AttributeI18nTableMap::ID;
+ }
+
+ if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) {
+ $this->aAttribute = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = AttributeI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = AttributeI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = AttributeI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = AttributeI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\AttributeI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = AttributeI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AttributeI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = AttributeI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\AttributeI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aAttribute !== null && $this->id !== $this->aAttribute->getId()) {
+ $this->aAttribute = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AttributeI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildAttributeI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aAttribute = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see AttributeI18n::setDeleted()
+ * @see AttributeI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildAttributeI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ AttributeI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aAttribute !== null) {
+ if ($this->aAttribute->isModified() || $this->aAttribute->isNew()) {
+ $affectedRows += $this->aAttribute->save($con);
+ }
+ $this->setAttribute($this->aAttribute);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(AttributeI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(AttributeI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(AttributeI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(AttributeI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(AttributeI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(AttributeI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO attribute_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AttributeI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['AttributeI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['AttributeI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = AttributeI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aAttribute) {
+ $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = AttributeI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = AttributeI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(AttributeI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(AttributeI18nTableMap::ID)) $criteria->add(AttributeI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(AttributeI18nTableMap::LOCALE)) $criteria->add(AttributeI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(AttributeI18nTableMap::TITLE)) $criteria->add(AttributeI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(AttributeI18nTableMap::DESCRIPTION)) $criteria->add(AttributeI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(AttributeI18nTableMap::CHAPO)) $criteria->add(AttributeI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(AttributeI18nTableMap::POSTSCRIPTUM)) $criteria->add(AttributeI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(AttributeI18nTableMap::DATABASE_NAME);
+ $criteria->add(AttributeI18nTableMap::ID, $this->id);
+ $criteria->add(AttributeI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\AttributeI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\AttributeI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildAttribute object.
+ *
+ * @param ChildAttribute $v
+ * @return \Thelia\Model\AttributeI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setAttribute(ChildAttribute $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aAttribute = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildAttribute object, it will not be re-added.
+ if ($v !== null) {
+ $v->addAttributeI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildAttribute object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildAttribute The associated ChildAttribute object.
+ * @throws PropelException
+ */
+ public function getAttribute(ConnectionInterface $con = null)
+ {
+ if ($this->aAttribute === null && ($this->id !== null)) {
+ $this->aAttribute = ChildAttributeQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aAttribute->addAttributeI18ns($this);
+ */
+ }
+
+ return $this->aAttribute;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aAttribute = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(AttributeI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/AttributeI18nQuery.php b/core/lib/Thelia/Model/Base/AttributeI18nQuery.php
new file mode 100644
index 000000000..c553af9a2
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AttributeI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAttributeI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AttributeI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AttributeI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAttributeI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM attribute_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildAttributeI18n();
+ $obj->hydrate($row);
+ AttributeI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAttributeI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildAttributeI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(AttributeI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(AttributeI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildAttributeI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(AttributeI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(AttributeI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByAttribute()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(AttributeI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(AttributeI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Attribute object
+ *
+ * @param \Thelia\Model\Attribute|ObjectCollection $attribute The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeI18nQuery The current query, for fluid interface
+ */
+ public function filterByAttribute($attribute, $comparison = null)
+ {
+ if ($attribute instanceof \Thelia\Model\Attribute) {
+ return $this
+ ->addUsingAlias(AttributeI18nTableMap::ID, $attribute->getId(), $comparison);
+ } elseif ($attribute instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(AttributeI18nTableMap::ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Attribute relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAttributeI18nQuery The current query, for fluid interface
+ */
+ public function joinAttribute($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Attribute');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Attribute');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Attribute relation Attribute object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinAttribute($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildAttributeI18n $attributeI18n Object to remove from the list of results
+ *
+ * @return ChildAttributeI18nQuery The current query, for fluid interface
+ */
+ public function prune($attributeI18n = null)
+ {
+ if ($attributeI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(AttributeI18nTableMap::ID), $attributeI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(AttributeI18nTableMap::LOCALE), $attributeI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the attribute_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ AttributeI18nTableMap::clearInstancePool();
+ AttributeI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildAttributeI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildAttributeI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeI18nTableMap::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->beginTransaction();
+
+
+ AttributeI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ AttributeI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // AttributeI18nQuery
diff --git a/core/lib/Thelia/Model/Base/AttributeQuery.php b/core/lib/Thelia/Model/Base/AttributeQuery.php
new file mode 100644
index 000000000..cbb690efb
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/AttributeQuery.php
@@ -0,0 +1,935 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildAttribute|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = AttributeTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(AttributeTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAttribute A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, POSITION, CREATED_AT, UPDATED_AT FROM attribute WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildAttribute();
+ $obj->hydrate($row);
+ AttributeTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildAttribute|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(AttributeTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(AttributeTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(AttributeTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(AttributeTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(AttributeTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(AttributeTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(AttributeTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(AttributeTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(AttributeTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(AttributeTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(AttributeTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\AttributeAv object
+ *
+ * @param \Thelia\Model\AttributeAv|ObjectCollection $attributeAv the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function filterByAttributeAv($attributeAv, $comparison = null)
+ {
+ if ($attributeAv instanceof \Thelia\Model\AttributeAv) {
+ return $this
+ ->addUsingAlias(AttributeTableMap::ID, $attributeAv->getAttributeId(), $comparison);
+ } elseif ($attributeAv instanceof ObjectCollection) {
+ return $this
+ ->useAttributeAvQuery()
+ ->filterByPrimaryKeys($attributeAv->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeAv() only accepts arguments of type \Thelia\Model\AttributeAv or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeAv relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function joinAttributeAv($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeAv');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AttributeAv');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeAv relation AttributeAv object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeAvQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeAv($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeAv', '\Thelia\Model\AttributeAvQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\AttributeCombination object
+ *
+ * @param \Thelia\Model\AttributeCombination|ObjectCollection $attributeCombination the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function filterByAttributeCombination($attributeCombination, $comparison = null)
+ {
+ if ($attributeCombination instanceof \Thelia\Model\AttributeCombination) {
+ return $this
+ ->addUsingAlias(AttributeTableMap::ID, $attributeCombination->getAttributeId(), $comparison);
+ } elseif ($attributeCombination instanceof ObjectCollection) {
+ return $this
+ ->useAttributeCombinationQuery()
+ ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeCombination() only accepts arguments of type \Thelia\Model\AttributeCombination or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeCombination relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function joinAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeCombination');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AttributeCombination');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeCombination relation AttributeCombination object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeCombinationQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeCombination($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeCombination', '\Thelia\Model\AttributeCombinationQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\AttributeCategory object
+ *
+ * @param \Thelia\Model\AttributeCategory|ObjectCollection $attributeCategory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function filterByAttributeCategory($attributeCategory, $comparison = null)
+ {
+ if ($attributeCategory instanceof \Thelia\Model\AttributeCategory) {
+ return $this
+ ->addUsingAlias(AttributeTableMap::ID, $attributeCategory->getAttributeId(), $comparison);
+ } elseif ($attributeCategory instanceof ObjectCollection) {
+ return $this
+ ->useAttributeCategoryQuery()
+ ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeCategory() only accepts arguments of type \Thelia\Model\AttributeCategory or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeCategory relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeCategory');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AttributeCategory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeCategory relation AttributeCategory object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeCategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\AttributeI18n object
+ *
+ * @param \Thelia\Model\AttributeI18n|ObjectCollection $attributeI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function filterByAttributeI18n($attributeI18n, $comparison = null)
+ {
+ if ($attributeI18n instanceof \Thelia\Model\AttributeI18n) {
+ return $this
+ ->addUsingAlias(AttributeTableMap::ID, $attributeI18n->getId(), $comparison);
+ } elseif ($attributeI18n instanceof ObjectCollection) {
+ return $this
+ ->useAttributeI18nQuery()
+ ->filterByPrimaryKeys($attributeI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeI18n() only accepts arguments of type \Thelia\Model\AttributeI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function joinAttributeI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AttributeI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeI18n relation AttributeI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinAttributeI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeI18n', '\Thelia\Model\AttributeI18nQuery');
+ }
+
+ /**
+ * Filter the query by a related Category object
+ * using the attribute_category table as cross reference
+ *
+ * @param Category $category the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function filterByCategory($category, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useAttributeCategoryQuery()
+ ->filterByCategory($category, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildAttribute $attribute Object to remove from the list of results
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function prune($attribute = null)
+ {
+ if ($attribute) {
+ $this->addUsingAlias(AttributeTableMap::ID, $attribute->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the attribute table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ AttributeTableMap::clearInstancePool();
+ AttributeTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildAttribute or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildAttribute object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(AttributeTableMap::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->beginTransaction();
+
+
+ AttributeTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ AttributeTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AttributeTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(AttributeTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AttributeTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AttributeTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(AttributeTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(AttributeTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'AttributeI18n';
+
+ return $this
+ ->joinAttributeI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildAttributeQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('AttributeI18n');
+ $this->with['AttributeI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildAttributeI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeI18n', '\Thelia\Model\AttributeI18nQuery');
+ }
+
+} // AttributeQuery
diff --git a/core/lib/Thelia/Model/Base/Category.php b/core/lib/Thelia/Model/Base/Category.php
new file mode 100644
index 000000000..a5df03229
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Category.php
@@ -0,0 +1,5709 @@
+version = 0;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\Category object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Category instance. If
+ * obj is an instance of Category, delegates to
+ * equals(Category). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Category The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Category The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [parent] column value.
+ *
+ * @return int
+ */
+ public function getParent()
+ {
+
+ return $this->parent;
+ }
+
+ /**
+ * Get the [link] column value.
+ *
+ * @return string
+ */
+ public function getLink()
+ {
+
+ return $this->link;
+ }
+
+ /**
+ * Get the [visible] column value.
+ *
+ * @return int
+ */
+ public function getVisible()
+ {
+
+ return $this->visible;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getVersionCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->version_created_at;
+ } else {
+ return $this->version_created_at !== null ? $this->version_created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CategoryTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [parent] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function setParent($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->parent !== $v) {
+ $this->parent = $v;
+ $this->modifiedColumns[] = CategoryTableMap::PARENT;
+ }
+
+
+ return $this;
+ } // setParent()
+
+ /**
+ * Set the value of [link] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function setLink($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->link !== $v) {
+ $this->link = $v;
+ $this->modifiedColumns[] = CategoryTableMap::LINK;
+ }
+
+
+ return $this;
+ } // setLink()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function setVisible($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->visible !== $v) {
+ $this->visible = $v;
+ $this->modifiedColumns[] = CategoryTableMap::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = CategoryTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = CategoryTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = CategoryTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = CategoryTableMap::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ if ($dt !== $this->version_created_at) {
+ $this->version_created_at = $dt;
+ $this->modifiedColumns[] = CategoryTableMap::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = CategoryTableMap::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->version !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CategoryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CategoryTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->parent = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryTableMap::translateFieldName('Link', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->link = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->visible = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CategoryTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CategoryTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CategoryTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version_created_by = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 10; // 10 = CategoryTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Category object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CategoryTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCategoryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collProductCategories = null;
+
+ $this->collFeatureCategories = null;
+
+ $this->collAttributeCategories = null;
+
+ $this->collContentAssocs = null;
+
+ $this->collImages = null;
+
+ $this->collDocuments = null;
+
+ $this->collRewritings = null;
+
+ $this->collCategoryI18ns = null;
+
+ $this->collCategoryVersions = null;
+
+ $this->collProducts = null;
+ $this->collFeatures = null;
+ $this->collAttributes = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Category::setDeleted()
+ * @see Category::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCategoryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ // versionable behavior
+ if ($this->isVersioningNecessary()) {
+ $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
+ if (!$this->isColumnModified(CategoryTableMap::VERSION_CREATED_AT)) {
+ $this->setVersionCreatedAt(time());
+ }
+ $createVersion = true; // for postSave hook
+ }
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CategoryTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CategoryTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CategoryTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ // versionable behavior
+ if (isset($createVersion)) {
+ $this->addVersion($con);
+ }
+ CategoryTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->productsScheduledForDeletion !== null) {
+ if (!$this->productsScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->productsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($remotePk, $pk);
+ }
+
+ ProductCategoryQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->productsScheduledForDeletion = null;
+ }
+
+ foreach ($this->getProducts() as $product) {
+ if ($product->isModified()) {
+ $product->save($con);
+ }
+ }
+ } elseif ($this->collProducts) {
+ foreach ($this->collProducts as $product) {
+ if ($product->isModified()) {
+ $product->save($con);
+ }
+ }
+ }
+
+ if ($this->featuresScheduledForDeletion !== null) {
+ if (!$this->featuresScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->featuresScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($pk, $remotePk);
+ }
+
+ FeatureCategoryQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->featuresScheduledForDeletion = null;
+ }
+
+ foreach ($this->getFeatures() as $feature) {
+ if ($feature->isModified()) {
+ $feature->save($con);
+ }
+ }
+ } elseif ($this->collFeatures) {
+ foreach ($this->collFeatures as $feature) {
+ if ($feature->isModified()) {
+ $feature->save($con);
+ }
+ }
+ }
+
+ if ($this->attributesScheduledForDeletion !== null) {
+ if (!$this->attributesScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->attributesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($pk, $remotePk);
+ }
+
+ AttributeCategoryQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->attributesScheduledForDeletion = null;
+ }
+
+ foreach ($this->getAttributes() as $attribute) {
+ if ($attribute->isModified()) {
+ $attribute->save($con);
+ }
+ }
+ } elseif ($this->collAttributes) {
+ foreach ($this->collAttributes as $attribute) {
+ if ($attribute->isModified()) {
+ $attribute->save($con);
+ }
+ }
+ }
+
+ if ($this->productCategoriesScheduledForDeletion !== null) {
+ if (!$this->productCategoriesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ProductCategoryQuery::create()
+ ->filterByPrimaryKeys($this->productCategoriesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->productCategoriesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collProductCategories !== null) {
+ foreach ($this->collProductCategories as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->featureCategoriesScheduledForDeletion !== null) {
+ if (!$this->featureCategoriesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\FeatureCategoryQuery::create()
+ ->filterByPrimaryKeys($this->featureCategoriesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->featureCategoriesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collFeatureCategories !== null) {
+ foreach ($this->collFeatureCategories as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->attributeCategoriesScheduledForDeletion !== null) {
+ if (!$this->attributeCategoriesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\AttributeCategoryQuery::create()
+ ->filterByPrimaryKeys($this->attributeCategoriesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->attributeCategoriesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAttributeCategories !== null) {
+ foreach ($this->collAttributeCategories as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->contentAssocsScheduledForDeletion !== null) {
+ if (!$this->contentAssocsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ContentAssocQuery::create()
+ ->filterByPrimaryKeys($this->contentAssocsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->contentAssocsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collContentAssocs !== null) {
+ foreach ($this->collContentAssocs as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->imagesScheduledForDeletion !== null) {
+ if (!$this->imagesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ImageQuery::create()
+ ->filterByPrimaryKeys($this->imagesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->imagesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collImages !== null) {
+ foreach ($this->collImages as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->documentsScheduledForDeletion !== null) {
+ if (!$this->documentsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\DocumentQuery::create()
+ ->filterByPrimaryKeys($this->documentsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->documentsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collDocuments !== null) {
+ foreach ($this->collDocuments as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->rewritingsScheduledForDeletion !== null) {
+ if (!$this->rewritingsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\RewritingQuery::create()
+ ->filterByPrimaryKeys($this->rewritingsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->rewritingsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collRewritings !== null) {
+ foreach ($this->collRewritings as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->categoryI18nsScheduledForDeletion !== null) {
+ if (!$this->categoryI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\CategoryI18nQuery::create()
+ ->filterByPrimaryKeys($this->categoryI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->categoryI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCategoryI18ns !== null) {
+ foreach ($this->collCategoryI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->categoryVersionsScheduledForDeletion !== null) {
+ if (!$this->categoryVersionsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\CategoryVersionQuery::create()
+ ->filterByPrimaryKeys($this->categoryVersionsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->categoryVersionsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCategoryVersions !== null) {
+ foreach ($this->collCategoryVersions as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CategoryTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CategoryTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CategoryTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CategoryTableMap::PARENT)) {
+ $modifiedColumns[':p' . $index++] = 'PARENT';
+ }
+ if ($this->isColumnModified(CategoryTableMap::LINK)) {
+ $modifiedColumns[':p' . $index++] = 'LINK';
+ }
+ if ($this->isColumnModified(CategoryTableMap::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = 'VISIBLE';
+ }
+ if ($this->isColumnModified(CategoryTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(CategoryTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CategoryTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+ if ($this->isColumnModified(CategoryTableMap::VERSION)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION';
+ }
+ if ($this->isColumnModified(CategoryTableMap::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT';
+ }
+ if ($this->isColumnModified(CategoryTableMap::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO category (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'PARENT':
+ $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT);
+ break;
+ case 'LINK':
+ $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR);
+ break;
+ case 'VISIBLE':
+ $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case 'VERSION_CREATED_AT':
+ $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION_CREATED_BY':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CategoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getParent();
+ break;
+ case 2:
+ return $this->getLink();
+ break;
+ case 3:
+ return $this->getVisible();
+ break;
+ case 4:
+ return $this->getPosition();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ case 7:
+ return $this->getVersion();
+ break;
+ case 8:
+ return $this->getVersionCreatedAt();
+ break;
+ case 9:
+ return $this->getVersionCreatedBy();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Category'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Category'][$this->getPrimaryKey()] = true;
+ $keys = CategoryTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getParent(),
+ $keys[2] => $this->getLink(),
+ $keys[3] => $this->getVisible(),
+ $keys[4] => $this->getPosition(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ $keys[7] => $this->getVersion(),
+ $keys[8] => $this->getVersionCreatedAt(),
+ $keys[9] => $this->getVersionCreatedBy(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collProductCategories) {
+ $result['ProductCategories'] = $this->collProductCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFeatureCategories) {
+ $result['FeatureCategories'] = $this->collFeatureCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collAttributeCategories) {
+ $result['AttributeCategories'] = $this->collAttributeCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collContentAssocs) {
+ $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collImages) {
+ $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collDocuments) {
+ $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collRewritings) {
+ $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCategoryI18ns) {
+ $result['CategoryI18ns'] = $this->collCategoryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCategoryVersions) {
+ $result['CategoryVersions'] = $this->collCategoryVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CategoryTableMap::translateFieldName($name, $type, TableMap::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->setParent($value);
+ break;
+ case 2:
+ $this->setLink($value);
+ break;
+ case 3:
+ $this->setVisible($value);
+ break;
+ case 4:
+ $this->setPosition($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ case 7:
+ $this->setVersion($value);
+ break;
+ case 8:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 9:
+ $this->setVersionCreatedBy($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CategoryTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]);
+ }
+
+ /**
+ * 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(CategoryTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CategoryTableMap::ID)) $criteria->add(CategoryTableMap::ID, $this->id);
+ if ($this->isColumnModified(CategoryTableMap::PARENT)) $criteria->add(CategoryTableMap::PARENT, $this->parent);
+ if ($this->isColumnModified(CategoryTableMap::LINK)) $criteria->add(CategoryTableMap::LINK, $this->link);
+ if ($this->isColumnModified(CategoryTableMap::VISIBLE)) $criteria->add(CategoryTableMap::VISIBLE, $this->visible);
+ if ($this->isColumnModified(CategoryTableMap::POSITION)) $criteria->add(CategoryTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(CategoryTableMap::CREATED_AT)) $criteria->add(CategoryTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CategoryTableMap::UPDATED_AT)) $criteria->add(CategoryTableMap::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(CategoryTableMap::VERSION)) $criteria->add(CategoryTableMap::VERSION, $this->version);
+ if ($this->isColumnModified(CategoryTableMap::VERSION_CREATED_AT)) $criteria->add(CategoryTableMap::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(CategoryTableMap::VERSION_CREATED_BY)) $criteria->add(CategoryTableMap::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(CategoryTableMap::DATABASE_NAME);
+ $criteria->add(CategoryTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Category (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setParent($this->getParent());
+ $copyObj->setLink($this->getLink());
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+
+ 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->getProductCategories() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addProductCategory($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getFeatureCategories() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFeatureCategory($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getAttributeCategories() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeCategory($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getContentAssocs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addContentAssoc($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getImages() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addImage($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getDocuments() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addDocument($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getRewritings() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addRewriting($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getCategoryI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCategoryI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getCategoryVersions() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCategoryVersion($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Category 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('ProductCategory' == $relationName) {
+ return $this->initProductCategories();
+ }
+ if ('FeatureCategory' == $relationName) {
+ return $this->initFeatureCategories();
+ }
+ if ('AttributeCategory' == $relationName) {
+ return $this->initAttributeCategories();
+ }
+ if ('ContentAssoc' == $relationName) {
+ return $this->initContentAssocs();
+ }
+ if ('Image' == $relationName) {
+ return $this->initImages();
+ }
+ if ('Document' == $relationName) {
+ return $this->initDocuments();
+ }
+ if ('Rewriting' == $relationName) {
+ return $this->initRewritings();
+ }
+ if ('CategoryI18n' == $relationName) {
+ return $this->initCategoryI18ns();
+ }
+ if ('CategoryVersion' == $relationName) {
+ return $this->initCategoryVersions();
+ }
+ }
+
+ /**
+ * Clears out the collProductCategories collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addProductCategories()
+ */
+ public function clearProductCategories()
+ {
+ $this->collProductCategories = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collProductCategories collection loaded partially.
+ */
+ public function resetPartialProductCategories($v = true)
+ {
+ $this->collProductCategoriesPartial = $v;
+ }
+
+ /**
+ * Initializes the collProductCategories collection.
+ *
+ * By default this just sets the collProductCategories collection to an empty array (like clearcollProductCategories());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initProductCategories($overrideExisting = true)
+ {
+ if (null !== $this->collProductCategories && !$overrideExisting) {
+ return;
+ }
+ $this->collProductCategories = new ObjectCollection();
+ $this->collProductCategories->setModel('\Thelia\Model\ProductCategory');
+ }
+
+ /**
+ * Gets an array of ChildProductCategory objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCategory is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildProductCategory[] List of ChildProductCategory objects
+ * @throws PropelException
+ */
+ public function getProductCategories($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collProductCategoriesPartial && !$this->isNew();
+ if (null === $this->collProductCategories || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProductCategories) {
+ // return empty collection
+ $this->initProductCategories();
+ } else {
+ $collProductCategories = ChildProductCategoryQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collProductCategoriesPartial && count($collProductCategories)) {
+ $this->initProductCategories(false);
+
+ foreach ($collProductCategories as $obj) {
+ if (false == $this->collProductCategories->contains($obj)) {
+ $this->collProductCategories->append($obj);
+ }
+ }
+
+ $this->collProductCategoriesPartial = true;
+ }
+
+ $collProductCategories->getInternalIterator()->rewind();
+
+ return $collProductCategories;
+ }
+
+ if ($partial && $this->collProductCategories) {
+ foreach ($this->collProductCategories as $obj) {
+ if ($obj->isNew()) {
+ $collProductCategories[] = $obj;
+ }
+ }
+ }
+
+ $this->collProductCategories = $collProductCategories;
+ $this->collProductCategoriesPartial = false;
+ }
+ }
+
+ return $this->collProductCategories;
+ }
+
+ /**
+ * Sets a collection of ProductCategory objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $productCategories A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function setProductCategories(Collection $productCategories, ConnectionInterface $con = null)
+ {
+ $productCategoriesToDelete = $this->getProductCategories(new Criteria(), $con)->diff($productCategories);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->productCategoriesScheduledForDeletion = clone $productCategoriesToDelete;
+
+ foreach ($productCategoriesToDelete as $productCategoryRemoved) {
+ $productCategoryRemoved->setCategory(null);
+ }
+
+ $this->collProductCategories = null;
+ foreach ($productCategories as $productCategory) {
+ $this->addProductCategory($productCategory);
+ }
+
+ $this->collProductCategories = $productCategories;
+ $this->collProductCategoriesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ProductCategory objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ProductCategory objects.
+ * @throws PropelException
+ */
+ public function countProductCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collProductCategoriesPartial && !$this->isNew();
+ if (null === $this->collProductCategories || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProductCategories) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getProductCategories());
+ }
+
+ $query = ChildProductCategoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+
+ return count($this->collProductCategories);
+ }
+
+ /**
+ * Method called to associate a ChildProductCategory object to this object
+ * through the ChildProductCategory foreign key attribute.
+ *
+ * @param ChildProductCategory $l ChildProductCategory
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function addProductCategory(ChildProductCategory $l)
+ {
+ if ($this->collProductCategories === null) {
+ $this->initProductCategories();
+ $this->collProductCategoriesPartial = true;
+ }
+
+ if (!in_array($l, $this->collProductCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddProductCategory($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ProductCategory $productCategory The productCategory object to add.
+ */
+ protected function doAddProductCategory($productCategory)
+ {
+ $this->collProductCategories[]= $productCategory;
+ $productCategory->setCategory($this);
+ }
+
+ /**
+ * @param ProductCategory $productCategory The productCategory object to remove.
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function removeProductCategory($productCategory)
+ {
+ if ($this->getProductCategories()->contains($productCategory)) {
+ $this->collProductCategories->remove($this->collProductCategories->search($productCategory));
+ if (null === $this->productCategoriesScheduledForDeletion) {
+ $this->productCategoriesScheduledForDeletion = clone $this->collProductCategories;
+ $this->productCategoriesScheduledForDeletion->clear();
+ }
+ $this->productCategoriesScheduledForDeletion[]= clone $productCategory;
+ $productCategory->setCategory(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related ProductCategories 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 Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildProductCategory[] List of ChildProductCategory objects
+ */
+ public function getProductCategoriesJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildProductCategoryQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getProductCategories($query, $con);
+ }
+
+ /**
+ * Clears out the collFeatureCategories collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addFeatureCategories()
+ */
+ public function clearFeatureCategories()
+ {
+ $this->collFeatureCategories = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collFeatureCategories collection loaded partially.
+ */
+ public function resetPartialFeatureCategories($v = true)
+ {
+ $this->collFeatureCategoriesPartial = $v;
+ }
+
+ /**
+ * Initializes the collFeatureCategories collection.
+ *
+ * By default this just sets the collFeatureCategories collection to an empty array (like clearcollFeatureCategories());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initFeatureCategories($overrideExisting = true)
+ {
+ if (null !== $this->collFeatureCategories && !$overrideExisting) {
+ return;
+ }
+ $this->collFeatureCategories = new ObjectCollection();
+ $this->collFeatureCategories->setModel('\Thelia\Model\FeatureCategory');
+ }
+
+ /**
+ * Gets an array of ChildFeatureCategory objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCategory is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildFeatureCategory[] List of ChildFeatureCategory objects
+ * @throws PropelException
+ */
+ public function getFeatureCategories($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureCategoriesPartial && !$this->isNew();
+ if (null === $this->collFeatureCategories || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureCategories) {
+ // return empty collection
+ $this->initFeatureCategories();
+ } else {
+ $collFeatureCategories = ChildFeatureCategoryQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collFeatureCategoriesPartial && count($collFeatureCategories)) {
+ $this->initFeatureCategories(false);
+
+ foreach ($collFeatureCategories as $obj) {
+ if (false == $this->collFeatureCategories->contains($obj)) {
+ $this->collFeatureCategories->append($obj);
+ }
+ }
+
+ $this->collFeatureCategoriesPartial = true;
+ }
+
+ $collFeatureCategories->getInternalIterator()->rewind();
+
+ return $collFeatureCategories;
+ }
+
+ if ($partial && $this->collFeatureCategories) {
+ foreach ($this->collFeatureCategories as $obj) {
+ if ($obj->isNew()) {
+ $collFeatureCategories[] = $obj;
+ }
+ }
+ }
+
+ $this->collFeatureCategories = $collFeatureCategories;
+ $this->collFeatureCategoriesPartial = false;
+ }
+ }
+
+ return $this->collFeatureCategories;
+ }
+
+ /**
+ * Sets a collection of FeatureCategory objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $featureCategories A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function setFeatureCategories(Collection $featureCategories, ConnectionInterface $con = null)
+ {
+ $featureCategoriesToDelete = $this->getFeatureCategories(new Criteria(), $con)->diff($featureCategories);
+
+
+ $this->featureCategoriesScheduledForDeletion = $featureCategoriesToDelete;
+
+ foreach ($featureCategoriesToDelete as $featureCategoryRemoved) {
+ $featureCategoryRemoved->setCategory(null);
+ }
+
+ $this->collFeatureCategories = null;
+ foreach ($featureCategories as $featureCategory) {
+ $this->addFeatureCategory($featureCategory);
+ }
+
+ $this->collFeatureCategories = $featureCategories;
+ $this->collFeatureCategoriesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related FeatureCategory objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related FeatureCategory objects.
+ * @throws PropelException
+ */
+ public function countFeatureCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureCategoriesPartial && !$this->isNew();
+ if (null === $this->collFeatureCategories || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureCategories) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getFeatureCategories());
+ }
+
+ $query = ChildFeatureCategoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+
+ return count($this->collFeatureCategories);
+ }
+
+ /**
+ * Method called to associate a ChildFeatureCategory object to this object
+ * through the ChildFeatureCategory foreign key attribute.
+ *
+ * @param ChildFeatureCategory $l ChildFeatureCategory
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function addFeatureCategory(ChildFeatureCategory $l)
+ {
+ if ($this->collFeatureCategories === null) {
+ $this->initFeatureCategories();
+ $this->collFeatureCategoriesPartial = true;
+ }
+
+ if (!in_array($l, $this->collFeatureCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddFeatureCategory($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param FeatureCategory $featureCategory The featureCategory object to add.
+ */
+ protected function doAddFeatureCategory($featureCategory)
+ {
+ $this->collFeatureCategories[]= $featureCategory;
+ $featureCategory->setCategory($this);
+ }
+
+ /**
+ * @param FeatureCategory $featureCategory The featureCategory object to remove.
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function removeFeatureCategory($featureCategory)
+ {
+ if ($this->getFeatureCategories()->contains($featureCategory)) {
+ $this->collFeatureCategories->remove($this->collFeatureCategories->search($featureCategory));
+ if (null === $this->featureCategoriesScheduledForDeletion) {
+ $this->featureCategoriesScheduledForDeletion = clone $this->collFeatureCategories;
+ $this->featureCategoriesScheduledForDeletion->clear();
+ }
+ $this->featureCategoriesScheduledForDeletion[]= clone $featureCategory;
+ $featureCategory->setCategory(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related FeatureCategories 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 Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildFeatureCategory[] List of ChildFeatureCategory objects
+ */
+ public function getFeatureCategoriesJoinFeature($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildFeatureCategoryQuery::create(null, $criteria);
+ $query->joinWith('Feature', $joinBehavior);
+
+ return $this->getFeatureCategories($query, $con);
+ }
+
+ /**
+ * Clears out the collAttributeCategories collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAttributeCategories()
+ */
+ public function clearAttributeCategories()
+ {
+ $this->collAttributeCategories = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collAttributeCategories collection loaded partially.
+ */
+ public function resetPartialAttributeCategories($v = true)
+ {
+ $this->collAttributeCategoriesPartial = $v;
+ }
+
+ /**
+ * Initializes the collAttributeCategories collection.
+ *
+ * By default this just sets the collAttributeCategories collection to an empty array (like clearcollAttributeCategories());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAttributeCategories($overrideExisting = true)
+ {
+ if (null !== $this->collAttributeCategories && !$overrideExisting) {
+ return;
+ }
+ $this->collAttributeCategories = new ObjectCollection();
+ $this->collAttributeCategories->setModel('\Thelia\Model\AttributeCategory');
+ }
+
+ /**
+ * Gets an array of ChildAttributeCategory objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCategory is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildAttributeCategory[] List of ChildAttributeCategory objects
+ * @throws PropelException
+ */
+ public function getAttributeCategories($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeCategoriesPartial && !$this->isNew();
+ if (null === $this->collAttributeCategories || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCategories) {
+ // return empty collection
+ $this->initAttributeCategories();
+ } else {
+ $collAttributeCategories = ChildAttributeCategoryQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeCategoriesPartial && count($collAttributeCategories)) {
+ $this->initAttributeCategories(false);
+
+ foreach ($collAttributeCategories as $obj) {
+ if (false == $this->collAttributeCategories->contains($obj)) {
+ $this->collAttributeCategories->append($obj);
+ }
+ }
+
+ $this->collAttributeCategoriesPartial = true;
+ }
+
+ $collAttributeCategories->getInternalIterator()->rewind();
+
+ return $collAttributeCategories;
+ }
+
+ if ($partial && $this->collAttributeCategories) {
+ foreach ($this->collAttributeCategories as $obj) {
+ if ($obj->isNew()) {
+ $collAttributeCategories[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeCategories = $collAttributeCategories;
+ $this->collAttributeCategoriesPartial = false;
+ }
+ }
+
+ return $this->collAttributeCategories;
+ }
+
+ /**
+ * Sets a collection of AttributeCategory objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $attributeCategories A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function setAttributeCategories(Collection $attributeCategories, ConnectionInterface $con = null)
+ {
+ $attributeCategoriesToDelete = $this->getAttributeCategories(new Criteria(), $con)->diff($attributeCategories);
+
+
+ $this->attributeCategoriesScheduledForDeletion = $attributeCategoriesToDelete;
+
+ foreach ($attributeCategoriesToDelete as $attributeCategoryRemoved) {
+ $attributeCategoryRemoved->setCategory(null);
+ }
+
+ $this->collAttributeCategories = null;
+ foreach ($attributeCategories as $attributeCategory) {
+ $this->addAttributeCategory($attributeCategory);
+ }
+
+ $this->collAttributeCategories = $attributeCategories;
+ $this->collAttributeCategoriesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related AttributeCategory objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related AttributeCategory objects.
+ * @throws PropelException
+ */
+ public function countAttributeCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeCategoriesPartial && !$this->isNew();
+ if (null === $this->collAttributeCategories || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCategories) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getAttributeCategories());
+ }
+
+ $query = ChildAttributeCategoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+
+ return count($this->collAttributeCategories);
+ }
+
+ /**
+ * Method called to associate a ChildAttributeCategory object to this object
+ * through the ChildAttributeCategory foreign key attribute.
+ *
+ * @param ChildAttributeCategory $l ChildAttributeCategory
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function addAttributeCategory(ChildAttributeCategory $l)
+ {
+ if ($this->collAttributeCategories === null) {
+ $this->initAttributeCategories();
+ $this->collAttributeCategoriesPartial = true;
+ }
+
+ if (!in_array($l, $this->collAttributeCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeCategory($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AttributeCategory $attributeCategory The attributeCategory object to add.
+ */
+ protected function doAddAttributeCategory($attributeCategory)
+ {
+ $this->collAttributeCategories[]= $attributeCategory;
+ $attributeCategory->setCategory($this);
+ }
+
+ /**
+ * @param AttributeCategory $attributeCategory The attributeCategory object to remove.
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function removeAttributeCategory($attributeCategory)
+ {
+ if ($this->getAttributeCategories()->contains($attributeCategory)) {
+ $this->collAttributeCategories->remove($this->collAttributeCategories->search($attributeCategory));
+ if (null === $this->attributeCategoriesScheduledForDeletion) {
+ $this->attributeCategoriesScheduledForDeletion = clone $this->collAttributeCategories;
+ $this->attributeCategoriesScheduledForDeletion->clear();
+ }
+ $this->attributeCategoriesScheduledForDeletion[]= clone $attributeCategory;
+ $attributeCategory->setCategory(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related AttributeCategories 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 Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildAttributeCategory[] List of ChildAttributeCategory objects
+ */
+ public function getAttributeCategoriesJoinAttribute($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildAttributeCategoryQuery::create(null, $criteria);
+ $query->joinWith('Attribute', $joinBehavior);
+
+ return $this->getAttributeCategories($query, $con);
+ }
+
+ /**
+ * Clears out the collContentAssocs collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addContentAssocs()
+ */
+ public function clearContentAssocs()
+ {
+ $this->collContentAssocs = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collContentAssocs collection loaded partially.
+ */
+ public function resetPartialContentAssocs($v = true)
+ {
+ $this->collContentAssocsPartial = $v;
+ }
+
+ /**
+ * Initializes the collContentAssocs collection.
+ *
+ * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initContentAssocs($overrideExisting = true)
+ {
+ if (null !== $this->collContentAssocs && !$overrideExisting) {
+ return;
+ }
+ $this->collContentAssocs = new ObjectCollection();
+ $this->collContentAssocs->setModel('\Thelia\Model\ContentAssoc');
+ }
+
+ /**
+ * Gets an array of ChildContentAssoc objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCategory is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects
+ * @throws PropelException
+ */
+ public function getContentAssocs($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collContentAssocsPartial && !$this->isNew();
+ if (null === $this->collContentAssocs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentAssocs) {
+ // return empty collection
+ $this->initContentAssocs();
+ } else {
+ $collContentAssocs = ChildContentAssocQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) {
+ $this->initContentAssocs(false);
+
+ foreach ($collContentAssocs as $obj) {
+ if (false == $this->collContentAssocs->contains($obj)) {
+ $this->collContentAssocs->append($obj);
+ }
+ }
+
+ $this->collContentAssocsPartial = true;
+ }
+
+ $collContentAssocs->getInternalIterator()->rewind();
+
+ return $collContentAssocs;
+ }
+
+ if ($partial && $this->collContentAssocs) {
+ foreach ($this->collContentAssocs as $obj) {
+ if ($obj->isNew()) {
+ $collContentAssocs[] = $obj;
+ }
+ }
+ }
+
+ $this->collContentAssocs = $collContentAssocs;
+ $this->collContentAssocsPartial = false;
+ }
+ }
+
+ return $this->collContentAssocs;
+ }
+
+ /**
+ * Sets a collection of ContentAssoc objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $contentAssocs A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function setContentAssocs(Collection $contentAssocs, ConnectionInterface $con = null)
+ {
+ $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs);
+
+
+ $this->contentAssocsScheduledForDeletion = $contentAssocsToDelete;
+
+ foreach ($contentAssocsToDelete as $contentAssocRemoved) {
+ $contentAssocRemoved->setCategory(null);
+ }
+
+ $this->collContentAssocs = null;
+ foreach ($contentAssocs as $contentAssoc) {
+ $this->addContentAssoc($contentAssoc);
+ }
+
+ $this->collContentAssocs = $contentAssocs;
+ $this->collContentAssocsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ContentAssoc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ContentAssoc objects.
+ * @throws PropelException
+ */
+ public function countContentAssocs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collContentAssocsPartial && !$this->isNew();
+ if (null === $this->collContentAssocs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentAssocs) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getContentAssocs());
+ }
+
+ $query = ChildContentAssocQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+
+ return count($this->collContentAssocs);
+ }
+
+ /**
+ * Method called to associate a ChildContentAssoc object to this object
+ * through the ChildContentAssoc foreign key attribute.
+ *
+ * @param ChildContentAssoc $l ChildContentAssoc
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function addContentAssoc(ChildContentAssoc $l)
+ {
+ if ($this->collContentAssocs === null) {
+ $this->initContentAssocs();
+ $this->collContentAssocsPartial = true;
+ }
+
+ if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddContentAssoc($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ContentAssoc $contentAssoc The contentAssoc object to add.
+ */
+ protected function doAddContentAssoc($contentAssoc)
+ {
+ $this->collContentAssocs[]= $contentAssoc;
+ $contentAssoc->setCategory($this);
+ }
+
+ /**
+ * @param ContentAssoc $contentAssoc The contentAssoc object to remove.
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function removeContentAssoc($contentAssoc)
+ {
+ if ($this->getContentAssocs()->contains($contentAssoc)) {
+ $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc));
+ if (null === $this->contentAssocsScheduledForDeletion) {
+ $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs;
+ $this->contentAssocsScheduledForDeletion->clear();
+ }
+ $this->contentAssocsScheduledForDeletion[]= $contentAssoc;
+ $contentAssoc->setCategory(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related ContentAssocs 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 Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects
+ */
+ public function getContentAssocsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildContentAssocQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getContentAssocs($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related ContentAssocs 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 Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects
+ */
+ public function getContentAssocsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildContentAssocQuery::create(null, $criteria);
+ $query->joinWith('Content', $joinBehavior);
+
+ return $this->getContentAssocs($query, $con);
+ }
+
+ /**
+ * Clears out the collImages collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addImages()
+ */
+ public function clearImages()
+ {
+ $this->collImages = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collImages collection loaded partially.
+ */
+ public function resetPartialImages($v = true)
+ {
+ $this->collImagesPartial = $v;
+ }
+
+ /**
+ * Initializes the collImages collection.
+ *
+ * By default this just sets the collImages collection to an empty array (like clearcollImages());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initImages($overrideExisting = true)
+ {
+ if (null !== $this->collImages && !$overrideExisting) {
+ return;
+ }
+ $this->collImages = new ObjectCollection();
+ $this->collImages->setModel('\Thelia\Model\Image');
+ }
+
+ /**
+ * Gets an array of ChildImage objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCategory is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildImage[] List of ChildImage objects
+ * @throws PropelException
+ */
+ public function getImages($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collImagesPartial && !$this->isNew();
+ if (null === $this->collImages || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collImages) {
+ // return empty collection
+ $this->initImages();
+ } else {
+ $collImages = ChildImageQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collImagesPartial && count($collImages)) {
+ $this->initImages(false);
+
+ foreach ($collImages as $obj) {
+ if (false == $this->collImages->contains($obj)) {
+ $this->collImages->append($obj);
+ }
+ }
+
+ $this->collImagesPartial = true;
+ }
+
+ $collImages->getInternalIterator()->rewind();
+
+ return $collImages;
+ }
+
+ if ($partial && $this->collImages) {
+ foreach ($this->collImages as $obj) {
+ if ($obj->isNew()) {
+ $collImages[] = $obj;
+ }
+ }
+ }
+
+ $this->collImages = $collImages;
+ $this->collImagesPartial = false;
+ }
+ }
+
+ return $this->collImages;
+ }
+
+ /**
+ * Sets a collection of Image objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $images A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function setImages(Collection $images, ConnectionInterface $con = null)
+ {
+ $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images);
+
+
+ $this->imagesScheduledForDeletion = $imagesToDelete;
+
+ foreach ($imagesToDelete as $imageRemoved) {
+ $imageRemoved->setCategory(null);
+ }
+
+ $this->collImages = null;
+ foreach ($images as $image) {
+ $this->addImage($image);
+ }
+
+ $this->collImages = $images;
+ $this->collImagesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Image objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Image objects.
+ * @throws PropelException
+ */
+ public function countImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collImagesPartial && !$this->isNew();
+ if (null === $this->collImages || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collImages) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getImages());
+ }
+
+ $query = ChildImageQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+
+ return count($this->collImages);
+ }
+
+ /**
+ * Method called to associate a ChildImage object to this object
+ * through the ChildImage foreign key attribute.
+ *
+ * @param ChildImage $l ChildImage
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function addImage(ChildImage $l)
+ {
+ if ($this->collImages === null) {
+ $this->initImages();
+ $this->collImagesPartial = true;
+ }
+
+ if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddImage($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Image $image The image object to add.
+ */
+ protected function doAddImage($image)
+ {
+ $this->collImages[]= $image;
+ $image->setCategory($this);
+ }
+
+ /**
+ * @param Image $image The image object to remove.
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function removeImage($image)
+ {
+ if ($this->getImages()->contains($image)) {
+ $this->collImages->remove($this->collImages->search($image));
+ if (null === $this->imagesScheduledForDeletion) {
+ $this->imagesScheduledForDeletion = clone $this->collImages;
+ $this->imagesScheduledForDeletion->clear();
+ }
+ $this->imagesScheduledForDeletion[]= $image;
+ $image->setCategory(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related Images 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 Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildImage[] List of ChildImage objects
+ */
+ public function getImagesJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildImageQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getImages($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related Images 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 Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildImage[] List of ChildImage objects
+ */
+ public function getImagesJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildImageQuery::create(null, $criteria);
+ $query->joinWith('Content', $joinBehavior);
+
+ return $this->getImages($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related Images 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 Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildImage[] List of ChildImage objects
+ */
+ public function getImagesJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildImageQuery::create(null, $criteria);
+ $query->joinWith('Folder', $joinBehavior);
+
+ return $this->getImages($query, $con);
+ }
+
+ /**
+ * Clears out the collDocuments collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addDocuments()
+ */
+ public function clearDocuments()
+ {
+ $this->collDocuments = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collDocuments collection loaded partially.
+ */
+ public function resetPartialDocuments($v = true)
+ {
+ $this->collDocumentsPartial = $v;
+ }
+
+ /**
+ * Initializes the collDocuments collection.
+ *
+ * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initDocuments($overrideExisting = true)
+ {
+ if (null !== $this->collDocuments && !$overrideExisting) {
+ return;
+ }
+ $this->collDocuments = new ObjectCollection();
+ $this->collDocuments->setModel('\Thelia\Model\Document');
+ }
+
+ /**
+ * Gets an array of ChildDocument objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCategory is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ * @throws PropelException
+ */
+ public function getDocuments($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collDocumentsPartial && !$this->isNew();
+ if (null === $this->collDocuments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocuments) {
+ // return empty collection
+ $this->initDocuments();
+ } else {
+ $collDocuments = ChildDocumentQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collDocumentsPartial && count($collDocuments)) {
+ $this->initDocuments(false);
+
+ foreach ($collDocuments as $obj) {
+ if (false == $this->collDocuments->contains($obj)) {
+ $this->collDocuments->append($obj);
+ }
+ }
+
+ $this->collDocumentsPartial = true;
+ }
+
+ $collDocuments->getInternalIterator()->rewind();
+
+ return $collDocuments;
+ }
+
+ if ($partial && $this->collDocuments) {
+ foreach ($this->collDocuments as $obj) {
+ if ($obj->isNew()) {
+ $collDocuments[] = $obj;
+ }
+ }
+ }
+
+ $this->collDocuments = $collDocuments;
+ $this->collDocumentsPartial = false;
+ }
+ }
+
+ return $this->collDocuments;
+ }
+
+ /**
+ * Sets a collection of Document objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $documents A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function setDocuments(Collection $documents, ConnectionInterface $con = null)
+ {
+ $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents);
+
+
+ $this->documentsScheduledForDeletion = $documentsToDelete;
+
+ foreach ($documentsToDelete as $documentRemoved) {
+ $documentRemoved->setCategory(null);
+ }
+
+ $this->collDocuments = null;
+ foreach ($documents as $document) {
+ $this->addDocument($document);
+ }
+
+ $this->collDocuments = $documents;
+ $this->collDocumentsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Document objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Document objects.
+ * @throws PropelException
+ */
+ public function countDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collDocumentsPartial && !$this->isNew();
+ if (null === $this->collDocuments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocuments) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getDocuments());
+ }
+
+ $query = ChildDocumentQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+
+ return count($this->collDocuments);
+ }
+
+ /**
+ * Method called to associate a ChildDocument object to this object
+ * through the ChildDocument foreign key attribute.
+ *
+ * @param ChildDocument $l ChildDocument
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function addDocument(ChildDocument $l)
+ {
+ if ($this->collDocuments === null) {
+ $this->initDocuments();
+ $this->collDocumentsPartial = true;
+ }
+
+ if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddDocument($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Document $document The document object to add.
+ */
+ protected function doAddDocument($document)
+ {
+ $this->collDocuments[]= $document;
+ $document->setCategory($this);
+ }
+
+ /**
+ * @param Document $document The document object to remove.
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function removeDocument($document)
+ {
+ if ($this->getDocuments()->contains($document)) {
+ $this->collDocuments->remove($this->collDocuments->search($document));
+ if (null === $this->documentsScheduledForDeletion) {
+ $this->documentsScheduledForDeletion = clone $this->collDocuments;
+ $this->documentsScheduledForDeletion->clear();
+ }
+ $this->documentsScheduledForDeletion[]= $document;
+ $document->setCategory(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related Documents 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 Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ */
+ public function getDocumentsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildDocumentQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related Documents 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 Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ */
+ public function getDocumentsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildDocumentQuery::create(null, $criteria);
+ $query->joinWith('Content', $joinBehavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related Documents 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 Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ */
+ public function getDocumentsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildDocumentQuery::create(null, $criteria);
+ $query->joinWith('Folder', $joinBehavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+ /**
+ * Clears out the collRewritings collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addRewritings()
+ */
+ public function clearRewritings()
+ {
+ $this->collRewritings = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collRewritings collection loaded partially.
+ */
+ public function resetPartialRewritings($v = true)
+ {
+ $this->collRewritingsPartial = $v;
+ }
+
+ /**
+ * Initializes the collRewritings collection.
+ *
+ * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initRewritings($overrideExisting = true)
+ {
+ if (null !== $this->collRewritings && !$overrideExisting) {
+ return;
+ }
+ $this->collRewritings = new ObjectCollection();
+ $this->collRewritings->setModel('\Thelia\Model\Rewriting');
+ }
+
+ /**
+ * Gets an array of ChildRewriting objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCategory is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ * @throws PropelException
+ */
+ public function getRewritings($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ // return empty collection
+ $this->initRewritings();
+ } else {
+ $collRewritings = ChildRewritingQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collRewritingsPartial && count($collRewritings)) {
+ $this->initRewritings(false);
+
+ foreach ($collRewritings as $obj) {
+ if (false == $this->collRewritings->contains($obj)) {
+ $this->collRewritings->append($obj);
+ }
+ }
+
+ $this->collRewritingsPartial = true;
+ }
+
+ $collRewritings->getInternalIterator()->rewind();
+
+ return $collRewritings;
+ }
+
+ if ($partial && $this->collRewritings) {
+ foreach ($this->collRewritings as $obj) {
+ if ($obj->isNew()) {
+ $collRewritings[] = $obj;
+ }
+ }
+ }
+
+ $this->collRewritings = $collRewritings;
+ $this->collRewritingsPartial = false;
+ }
+ }
+
+ return $this->collRewritings;
+ }
+
+ /**
+ * Sets a collection of Rewriting objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $rewritings A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function setRewritings(Collection $rewritings, ConnectionInterface $con = null)
+ {
+ $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings);
+
+
+ $this->rewritingsScheduledForDeletion = $rewritingsToDelete;
+
+ foreach ($rewritingsToDelete as $rewritingRemoved) {
+ $rewritingRemoved->setCategory(null);
+ }
+
+ $this->collRewritings = null;
+ foreach ($rewritings as $rewriting) {
+ $this->addRewriting($rewriting);
+ }
+
+ $this->collRewritings = $rewritings;
+ $this->collRewritingsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Rewriting objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Rewriting objects.
+ * @throws PropelException
+ */
+ public function countRewritings(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getRewritings());
+ }
+
+ $query = ChildRewritingQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+
+ return count($this->collRewritings);
+ }
+
+ /**
+ * Method called to associate a ChildRewriting object to this object
+ * through the ChildRewriting foreign key attribute.
+ *
+ * @param ChildRewriting $l ChildRewriting
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function addRewriting(ChildRewriting $l)
+ {
+ if ($this->collRewritings === null) {
+ $this->initRewritings();
+ $this->collRewritingsPartial = true;
+ }
+
+ if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddRewriting($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Rewriting $rewriting The rewriting object to add.
+ */
+ protected function doAddRewriting($rewriting)
+ {
+ $this->collRewritings[]= $rewriting;
+ $rewriting->setCategory($this);
+ }
+
+ /**
+ * @param Rewriting $rewriting The rewriting object to remove.
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function removeRewriting($rewriting)
+ {
+ if ($this->getRewritings()->contains($rewriting)) {
+ $this->collRewritings->remove($this->collRewritings->search($rewriting));
+ if (null === $this->rewritingsScheduledForDeletion) {
+ $this->rewritingsScheduledForDeletion = clone $this->collRewritings;
+ $this->rewritingsScheduledForDeletion->clear();
+ }
+ $this->rewritingsScheduledForDeletion[]= $rewriting;
+ $rewriting->setCategory(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related Rewritings 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 Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ */
+ public function getRewritingsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildRewritingQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getRewritings($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related Rewritings 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 Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ */
+ public function getRewritingsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildRewritingQuery::create(null, $criteria);
+ $query->joinWith('Folder', $joinBehavior);
+
+ return $this->getRewritings($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Category is new, it will return
+ * an empty collection; or if this Category has previously
+ * been saved, it will retrieve related Rewritings 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 Category.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ */
+ public function getRewritingsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildRewritingQuery::create(null, $criteria);
+ $query->joinWith('Content', $joinBehavior);
+
+ return $this->getRewritings($query, $con);
+ }
+
+ /**
+ * Clears out the collCategoryI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCategoryI18ns()
+ */
+ public function clearCategoryI18ns()
+ {
+ $this->collCategoryI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCategoryI18ns collection loaded partially.
+ */
+ public function resetPartialCategoryI18ns($v = true)
+ {
+ $this->collCategoryI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collCategoryI18ns collection.
+ *
+ * By default this just sets the collCategoryI18ns collection to an empty array (like clearcollCategoryI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCategoryI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collCategoryI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collCategoryI18ns = new ObjectCollection();
+ $this->collCategoryI18ns->setModel('\Thelia\Model\CategoryI18n');
+ }
+
+ /**
+ * Gets an array of ChildCategoryI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCategory is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCategoryI18n[] List of ChildCategoryI18n objects
+ * @throws PropelException
+ */
+ public function getCategoryI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCategoryI18nsPartial && !$this->isNew();
+ if (null === $this->collCategoryI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCategoryI18ns) {
+ // return empty collection
+ $this->initCategoryI18ns();
+ } else {
+ $collCategoryI18ns = ChildCategoryI18nQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCategoryI18nsPartial && count($collCategoryI18ns)) {
+ $this->initCategoryI18ns(false);
+
+ foreach ($collCategoryI18ns as $obj) {
+ if (false == $this->collCategoryI18ns->contains($obj)) {
+ $this->collCategoryI18ns->append($obj);
+ }
+ }
+
+ $this->collCategoryI18nsPartial = true;
+ }
+
+ $collCategoryI18ns->getInternalIterator()->rewind();
+
+ return $collCategoryI18ns;
+ }
+
+ if ($partial && $this->collCategoryI18ns) {
+ foreach ($this->collCategoryI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collCategoryI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collCategoryI18ns = $collCategoryI18ns;
+ $this->collCategoryI18nsPartial = false;
+ }
+ }
+
+ return $this->collCategoryI18ns;
+ }
+
+ /**
+ * Sets a collection of CategoryI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $categoryI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function setCategoryI18ns(Collection $categoryI18ns, ConnectionInterface $con = null)
+ {
+ $categoryI18nsToDelete = $this->getCategoryI18ns(new Criteria(), $con)->diff($categoryI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->categoryI18nsScheduledForDeletion = clone $categoryI18nsToDelete;
+
+ foreach ($categoryI18nsToDelete as $categoryI18nRemoved) {
+ $categoryI18nRemoved->setCategory(null);
+ }
+
+ $this->collCategoryI18ns = null;
+ foreach ($categoryI18ns as $categoryI18n) {
+ $this->addCategoryI18n($categoryI18n);
+ }
+
+ $this->collCategoryI18ns = $categoryI18ns;
+ $this->collCategoryI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CategoryI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CategoryI18n objects.
+ * @throws PropelException
+ */
+ public function countCategoryI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCategoryI18nsPartial && !$this->isNew();
+ if (null === $this->collCategoryI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCategoryI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCategoryI18ns());
+ }
+
+ $query = ChildCategoryI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+
+ return count($this->collCategoryI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildCategoryI18n object to this object
+ * through the ChildCategoryI18n foreign key attribute.
+ *
+ * @param ChildCategoryI18n $l ChildCategoryI18n
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function addCategoryI18n(ChildCategoryI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collCategoryI18ns === null) {
+ $this->initCategoryI18ns();
+ $this->collCategoryI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collCategoryI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCategoryI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CategoryI18n $categoryI18n The categoryI18n object to add.
+ */
+ protected function doAddCategoryI18n($categoryI18n)
+ {
+ $this->collCategoryI18ns[]= $categoryI18n;
+ $categoryI18n->setCategory($this);
+ }
+
+ /**
+ * @param CategoryI18n $categoryI18n The categoryI18n object to remove.
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function removeCategoryI18n($categoryI18n)
+ {
+ if ($this->getCategoryI18ns()->contains($categoryI18n)) {
+ $this->collCategoryI18ns->remove($this->collCategoryI18ns->search($categoryI18n));
+ if (null === $this->categoryI18nsScheduledForDeletion) {
+ $this->categoryI18nsScheduledForDeletion = clone $this->collCategoryI18ns;
+ $this->categoryI18nsScheduledForDeletion->clear();
+ }
+ $this->categoryI18nsScheduledForDeletion[]= clone $categoryI18n;
+ $categoryI18n->setCategory(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collCategoryVersions collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCategoryVersions()
+ */
+ public function clearCategoryVersions()
+ {
+ $this->collCategoryVersions = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCategoryVersions collection loaded partially.
+ */
+ public function resetPartialCategoryVersions($v = true)
+ {
+ $this->collCategoryVersionsPartial = $v;
+ }
+
+ /**
+ * Initializes the collCategoryVersions collection.
+ *
+ * By default this just sets the collCategoryVersions collection to an empty array (like clearcollCategoryVersions());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCategoryVersions($overrideExisting = true)
+ {
+ if (null !== $this->collCategoryVersions && !$overrideExisting) {
+ return;
+ }
+ $this->collCategoryVersions = new ObjectCollection();
+ $this->collCategoryVersions->setModel('\Thelia\Model\CategoryVersion');
+ }
+
+ /**
+ * Gets an array of ChildCategoryVersion objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCategory is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCategoryVersion[] List of ChildCategoryVersion objects
+ * @throws PropelException
+ */
+ public function getCategoryVersions($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCategoryVersionsPartial && !$this->isNew();
+ if (null === $this->collCategoryVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCategoryVersions) {
+ // return empty collection
+ $this->initCategoryVersions();
+ } else {
+ $collCategoryVersions = ChildCategoryVersionQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCategoryVersionsPartial && count($collCategoryVersions)) {
+ $this->initCategoryVersions(false);
+
+ foreach ($collCategoryVersions as $obj) {
+ if (false == $this->collCategoryVersions->contains($obj)) {
+ $this->collCategoryVersions->append($obj);
+ }
+ }
+
+ $this->collCategoryVersionsPartial = true;
+ }
+
+ $collCategoryVersions->getInternalIterator()->rewind();
+
+ return $collCategoryVersions;
+ }
+
+ if ($partial && $this->collCategoryVersions) {
+ foreach ($this->collCategoryVersions as $obj) {
+ if ($obj->isNew()) {
+ $collCategoryVersions[] = $obj;
+ }
+ }
+ }
+
+ $this->collCategoryVersions = $collCategoryVersions;
+ $this->collCategoryVersionsPartial = false;
+ }
+ }
+
+ return $this->collCategoryVersions;
+ }
+
+ /**
+ * Sets a collection of CategoryVersion objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $categoryVersions A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function setCategoryVersions(Collection $categoryVersions, ConnectionInterface $con = null)
+ {
+ $categoryVersionsToDelete = $this->getCategoryVersions(new Criteria(), $con)->diff($categoryVersions);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->categoryVersionsScheduledForDeletion = clone $categoryVersionsToDelete;
+
+ foreach ($categoryVersionsToDelete as $categoryVersionRemoved) {
+ $categoryVersionRemoved->setCategory(null);
+ }
+
+ $this->collCategoryVersions = null;
+ foreach ($categoryVersions as $categoryVersion) {
+ $this->addCategoryVersion($categoryVersion);
+ }
+
+ $this->collCategoryVersions = $categoryVersions;
+ $this->collCategoryVersionsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CategoryVersion objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CategoryVersion objects.
+ * @throws PropelException
+ */
+ public function countCategoryVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCategoryVersionsPartial && !$this->isNew();
+ if (null === $this->collCategoryVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCategoryVersions) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCategoryVersions());
+ }
+
+ $query = ChildCategoryVersionQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+
+ return count($this->collCategoryVersions);
+ }
+
+ /**
+ * Method called to associate a ChildCategoryVersion object to this object
+ * through the ChildCategoryVersion foreign key attribute.
+ *
+ * @param ChildCategoryVersion $l ChildCategoryVersion
+ * @return \Thelia\Model\Category The current object (for fluent API support)
+ */
+ public function addCategoryVersion(ChildCategoryVersion $l)
+ {
+ if ($this->collCategoryVersions === null) {
+ $this->initCategoryVersions();
+ $this->collCategoryVersionsPartial = true;
+ }
+
+ if (!in_array($l, $this->collCategoryVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCategoryVersion($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CategoryVersion $categoryVersion The categoryVersion object to add.
+ */
+ protected function doAddCategoryVersion($categoryVersion)
+ {
+ $this->collCategoryVersions[]= $categoryVersion;
+ $categoryVersion->setCategory($this);
+ }
+
+ /**
+ * @param CategoryVersion $categoryVersion The categoryVersion object to remove.
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function removeCategoryVersion($categoryVersion)
+ {
+ if ($this->getCategoryVersions()->contains($categoryVersion)) {
+ $this->collCategoryVersions->remove($this->collCategoryVersions->search($categoryVersion));
+ if (null === $this->categoryVersionsScheduledForDeletion) {
+ $this->categoryVersionsScheduledForDeletion = clone $this->collCategoryVersions;
+ $this->categoryVersionsScheduledForDeletion->clear();
+ }
+ $this->categoryVersionsScheduledForDeletion[]= clone $categoryVersion;
+ $categoryVersion->setCategory(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collProducts collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addProducts()
+ */
+ public function clearProducts()
+ {
+ $this->collProducts = null; // important to set this to NULL since that means it is uninitialized
+ $this->collProductsPartial = null;
+ }
+
+ /**
+ * Initializes the collProducts collection.
+ *
+ * By default this just sets the collProducts collection to an empty collection (like clearProducts());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initProducts()
+ {
+ $this->collProducts = new ObjectCollection();
+ $this->collProducts->setModel('\Thelia\Model\Product');
+ }
+
+ /**
+ * Gets a collection of ChildProduct objects related by a many-to-many relationship
+ * to the current object by way of the product_category cross-reference table.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCategory is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return ObjectCollection|ChildProduct[] List of ChildProduct objects
+ */
+ public function getProducts($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collProducts || null !== $criteria) {
+ if ($this->isNew() && null === $this->collProducts) {
+ // return empty collection
+ $this->initProducts();
+ } else {
+ $collProducts = ChildProductQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collProducts;
+ }
+ $this->collProducts = $collProducts;
+ }
+ }
+
+ return $this->collProducts;
+ }
+
+ /**
+ * Sets a collection of Product objects related by a many-to-many relationship
+ * to the current object by way of the product_category cross-reference table.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $products A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function setProducts(Collection $products, ConnectionInterface $con = null)
+ {
+ $this->clearProducts();
+ $currentProducts = $this->getProducts();
+
+ $this->productsScheduledForDeletion = $currentProducts->diff($products);
+
+ foreach ($products as $product) {
+ if (!$currentProducts->contains($product)) {
+ $this->doAddProduct($product);
+ }
+ }
+
+ $this->collProducts = $products;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildProduct objects related by a many-to-many relationship
+ * to the current object by way of the product_category cross-reference table.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param boolean $distinct Set to true to force count distinct
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return int the number of related ChildProduct objects
+ */
+ public function countProducts($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collProducts || null !== $criteria) {
+ if ($this->isNew() && null === $this->collProducts) {
+ return 0;
+ } else {
+ $query = ChildProductQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collProducts);
+ }
+ }
+
+ /**
+ * Associate a ChildProduct object to this object
+ * through the product_category cross reference table.
+ *
+ * @param ChildProduct $product The ChildProductCategory object to relate
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function addProduct(ChildProduct $product)
+ {
+ if ($this->collProducts === null) {
+ $this->initProducts();
+ }
+
+ if (!$this->collProducts->contains($product)) { // only add it if the **same** object is not already associated
+ $this->doAddProduct($product);
+ $this->collProducts[] = $product;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Product $product The product object to add.
+ */
+ protected function doAddProduct($product)
+ {
+ $productCategory = new ChildProductCategory();
+ $productCategory->setProduct($product);
+ $this->addProductCategory($productCategory);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$product->getCategories()->contains($this)) {
+ $foreignCollection = $product->getCategories();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildProduct object to this object
+ * through the product_category cross reference table.
+ *
+ * @param ChildProduct $product The ChildProductCategory object to relate
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function removeProduct(ChildProduct $product)
+ {
+ if ($this->getProducts()->contains($product)) {
+ $this->collProducts->remove($this->collProducts->search($product));
+
+ if (null === $this->productsScheduledForDeletion) {
+ $this->productsScheduledForDeletion = clone $this->collProducts;
+ $this->productsScheduledForDeletion->clear();
+ }
+
+ $this->productsScheduledForDeletion[] = $product;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collFeatures collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addFeatures()
+ */
+ public function clearFeatures()
+ {
+ $this->collFeatures = null; // important to set this to NULL since that means it is uninitialized
+ $this->collFeaturesPartial = null;
+ }
+
+ /**
+ * Initializes the collFeatures collection.
+ *
+ * By default this just sets the collFeatures collection to an empty collection (like clearFeatures());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initFeatures()
+ {
+ $this->collFeatures = new ObjectCollection();
+ $this->collFeatures->setModel('\Thelia\Model\Feature');
+ }
+
+ /**
+ * Gets a collection of ChildFeature objects related by a many-to-many relationship
+ * to the current object by way of the feature_category cross-reference table.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCategory is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return ObjectCollection|ChildFeature[] List of ChildFeature objects
+ */
+ public function getFeatures($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collFeatures || null !== $criteria) {
+ if ($this->isNew() && null === $this->collFeatures) {
+ // return empty collection
+ $this->initFeatures();
+ } else {
+ $collFeatures = ChildFeatureQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collFeatures;
+ }
+ $this->collFeatures = $collFeatures;
+ }
+ }
+
+ return $this->collFeatures;
+ }
+
+ /**
+ * Sets a collection of Feature objects related by a many-to-many relationship
+ * to the current object by way of the feature_category cross-reference table.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $features A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function setFeatures(Collection $features, ConnectionInterface $con = null)
+ {
+ $this->clearFeatures();
+ $currentFeatures = $this->getFeatures();
+
+ $this->featuresScheduledForDeletion = $currentFeatures->diff($features);
+
+ foreach ($features as $feature) {
+ if (!$currentFeatures->contains($feature)) {
+ $this->doAddFeature($feature);
+ }
+ }
+
+ $this->collFeatures = $features;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildFeature objects related by a many-to-many relationship
+ * to the current object by way of the feature_category cross-reference table.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param boolean $distinct Set to true to force count distinct
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return int the number of related ChildFeature objects
+ */
+ public function countFeatures($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collFeatures || null !== $criteria) {
+ if ($this->isNew() && null === $this->collFeatures) {
+ return 0;
+ } else {
+ $query = ChildFeatureQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collFeatures);
+ }
+ }
+
+ /**
+ * Associate a ChildFeature object to this object
+ * through the feature_category cross reference table.
+ *
+ * @param ChildFeature $feature The ChildFeatureCategory object to relate
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function addFeature(ChildFeature $feature)
+ {
+ if ($this->collFeatures === null) {
+ $this->initFeatures();
+ }
+
+ if (!$this->collFeatures->contains($feature)) { // only add it if the **same** object is not already associated
+ $this->doAddFeature($feature);
+ $this->collFeatures[] = $feature;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Feature $feature The feature object to add.
+ */
+ protected function doAddFeature($feature)
+ {
+ $featureCategory = new ChildFeatureCategory();
+ $featureCategory->setFeature($feature);
+ $this->addFeatureCategory($featureCategory);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$feature->getCategories()->contains($this)) {
+ $foreignCollection = $feature->getCategories();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildFeature object to this object
+ * through the feature_category cross reference table.
+ *
+ * @param ChildFeature $feature The ChildFeatureCategory object to relate
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function removeFeature(ChildFeature $feature)
+ {
+ if ($this->getFeatures()->contains($feature)) {
+ $this->collFeatures->remove($this->collFeatures->search($feature));
+
+ if (null === $this->featuresScheduledForDeletion) {
+ $this->featuresScheduledForDeletion = clone $this->collFeatures;
+ $this->featuresScheduledForDeletion->clear();
+ }
+
+ $this->featuresScheduledForDeletion[] = $feature;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collAttributes collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAttributes()
+ */
+ public function clearAttributes()
+ {
+ $this->collAttributes = null; // important to set this to NULL since that means it is uninitialized
+ $this->collAttributesPartial = null;
+ }
+
+ /**
+ * Initializes the collAttributes collection.
+ *
+ * By default this just sets the collAttributes collection to an empty collection (like clearAttributes());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initAttributes()
+ {
+ $this->collAttributes = new ObjectCollection();
+ $this->collAttributes->setModel('\Thelia\Model\Attribute');
+ }
+
+ /**
+ * Gets a collection of ChildAttribute objects related by a many-to-many relationship
+ * to the current object by way of the attribute_category cross-reference table.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCategory is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return ObjectCollection|ChildAttribute[] List of ChildAttribute objects
+ */
+ public function getAttributes($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collAttributes || null !== $criteria) {
+ if ($this->isNew() && null === $this->collAttributes) {
+ // return empty collection
+ $this->initAttributes();
+ } else {
+ $collAttributes = ChildAttributeQuery::create(null, $criteria)
+ ->filterByCategory($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collAttributes;
+ }
+ $this->collAttributes = $collAttributes;
+ }
+ }
+
+ return $this->collAttributes;
+ }
+
+ /**
+ * Sets a collection of Attribute objects related by a many-to-many relationship
+ * to the current object by way of the attribute_category cross-reference table.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $attributes A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function setAttributes(Collection $attributes, ConnectionInterface $con = null)
+ {
+ $this->clearAttributes();
+ $currentAttributes = $this->getAttributes();
+
+ $this->attributesScheduledForDeletion = $currentAttributes->diff($attributes);
+
+ foreach ($attributes as $attribute) {
+ if (!$currentAttributes->contains($attribute)) {
+ $this->doAddAttribute($attribute);
+ }
+ }
+
+ $this->collAttributes = $attributes;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildAttribute objects related by a many-to-many relationship
+ * to the current object by way of the attribute_category cross-reference table.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param boolean $distinct Set to true to force count distinct
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return int the number of related ChildAttribute objects
+ */
+ public function countAttributes($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collAttributes || null !== $criteria) {
+ if ($this->isNew() && null === $this->collAttributes) {
+ return 0;
+ } else {
+ $query = ChildAttributeQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCategory($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collAttributes);
+ }
+ }
+
+ /**
+ * Associate a ChildAttribute object to this object
+ * through the attribute_category cross reference table.
+ *
+ * @param ChildAttribute $attribute The ChildAttributeCategory object to relate
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function addAttribute(ChildAttribute $attribute)
+ {
+ if ($this->collAttributes === null) {
+ $this->initAttributes();
+ }
+
+ if (!$this->collAttributes->contains($attribute)) { // only add it if the **same** object is not already associated
+ $this->doAddAttribute($attribute);
+ $this->collAttributes[] = $attribute;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Attribute $attribute The attribute object to add.
+ */
+ protected function doAddAttribute($attribute)
+ {
+ $attributeCategory = new ChildAttributeCategory();
+ $attributeCategory->setAttribute($attribute);
+ $this->addAttributeCategory($attributeCategory);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$attribute->getCategories()->contains($this)) {
+ $foreignCollection = $attribute->getCategories();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildAttribute object to this object
+ * through the attribute_category cross reference table.
+ *
+ * @param ChildAttribute $attribute The ChildAttributeCategory object to relate
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function removeAttribute(ChildAttribute $attribute)
+ {
+ if ($this->getAttributes()->contains($attribute)) {
+ $this->collAttributes->remove($this->collAttributes->search($attribute));
+
+ if (null === $this->attributesScheduledForDeletion) {
+ $this->attributesScheduledForDeletion = clone $this->collAttributes;
+ $this->attributesScheduledForDeletion->clear();
+ }
+
+ $this->attributesScheduledForDeletion[] = $attribute;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->parent = null;
+ $this->link = null;
+ $this->visible = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collProductCategories) {
+ foreach ($this->collProductCategories as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collFeatureCategories) {
+ foreach ($this->collFeatureCategories as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAttributeCategories) {
+ foreach ($this->collAttributeCategories as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collContentAssocs) {
+ foreach ($this->collContentAssocs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collImages) {
+ foreach ($this->collImages as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collDocuments) {
+ foreach ($this->collDocuments as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collRewritings) {
+ foreach ($this->collRewritings as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCategoryI18ns) {
+ foreach ($this->collCategoryI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCategoryVersions) {
+ foreach ($this->collCategoryVersions as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collProducts) {
+ foreach ($this->collProducts as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collFeatures) {
+ foreach ($this->collFeatures as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAttributes) {
+ foreach ($this->collAttributes as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collProductCategories instanceof Collection) {
+ $this->collProductCategories->clearIterator();
+ }
+ $this->collProductCategories = null;
+ if ($this->collFeatureCategories instanceof Collection) {
+ $this->collFeatureCategories->clearIterator();
+ }
+ $this->collFeatureCategories = null;
+ if ($this->collAttributeCategories instanceof Collection) {
+ $this->collAttributeCategories->clearIterator();
+ }
+ $this->collAttributeCategories = null;
+ if ($this->collContentAssocs instanceof Collection) {
+ $this->collContentAssocs->clearIterator();
+ }
+ $this->collContentAssocs = null;
+ if ($this->collImages instanceof Collection) {
+ $this->collImages->clearIterator();
+ }
+ $this->collImages = null;
+ if ($this->collDocuments instanceof Collection) {
+ $this->collDocuments->clearIterator();
+ }
+ $this->collDocuments = null;
+ if ($this->collRewritings instanceof Collection) {
+ $this->collRewritings->clearIterator();
+ }
+ $this->collRewritings = null;
+ if ($this->collCategoryI18ns instanceof Collection) {
+ $this->collCategoryI18ns->clearIterator();
+ }
+ $this->collCategoryI18ns = null;
+ if ($this->collCategoryVersions instanceof Collection) {
+ $this->collCategoryVersions->clearIterator();
+ }
+ $this->collCategoryVersions = null;
+ if ($this->collProducts instanceof Collection) {
+ $this->collProducts->clearIterator();
+ }
+ $this->collProducts = null;
+ if ($this->collFeatures instanceof Collection) {
+ $this->collFeatures->clearIterator();
+ }
+ $this->collFeatures = null;
+ if ($this->collAttributes instanceof Collection) {
+ $this->collAttributes->clearIterator();
+ }
+ $this->collAttributes = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CategoryTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = CategoryTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCategoryI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collCategoryI18ns) {
+ foreach ($this->collCategoryI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildCategoryI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildCategoryI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addCategoryI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildCategoryI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collCategoryI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collCategoryI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCategoryI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CategoryI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CategoryI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CategoryI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CategoryI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ // versionable behavior
+
+ /**
+ * Enforce a new Version of this object upon next save.
+ *
+ * @return \Thelia\Model\Category
+ */
+ public function enforceVersioning()
+ {
+ $this->enforceVersion = true;
+
+ return $this;
+ }
+
+ /**
+ * Checks whether the current state must be recorded as a version
+ *
+ * @return boolean
+ */
+ public function isVersioningNecessary($con = null)
+ {
+ if ($this->alreadyInSave) {
+ return false;
+ }
+
+ if ($this->enforceVersion) {
+ return true;
+ }
+
+ if (ChildCategoryQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Creates a version of the current object and saves it.
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ChildCategoryVersion A version object
+ */
+ public function addVersion($con = null)
+ {
+ $this->enforceVersion = false;
+
+ $version = new ChildCategoryVersion();
+ $version->setId($this->getId());
+ $version->setParent($this->getParent());
+ $version->setLink($this->getLink());
+ $version->setVisible($this->getVisible());
+ $version->setPosition($this->getPosition());
+ $version->setCreatedAt($this->getCreatedAt());
+ $version->setUpdatedAt($this->getUpdatedAt());
+ $version->setVersion($this->getVersion());
+ $version->setVersionCreatedAt($this->getVersionCreatedAt());
+ $version->setVersionCreatedBy($this->getVersionCreatedBy());
+ $version->setCategory($this);
+ $version->save($con);
+
+ return $version;
+ }
+
+ /**
+ * Sets the properties of the current object to the value they had at a specific version
+ *
+ * @param integer $versionNumber The version number to read
+ * @param ConnectionInterface $con The connection to use
+ *
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function toVersion($versionNumber, $con = null)
+ {
+ $version = $this->getOneVersion($versionNumber, $con);
+ if (!$version) {
+ throw new PropelException(sprintf('No ChildCategory object found with version %d', $version));
+ }
+ $this->populateFromVersion($version, $con);
+
+ return $this;
+ }
+
+ /**
+ * Sets the properties of the current object to the value they had at a specific version
+ *
+ * @param ChildCategoryVersion $version The version object to use
+ * @param ConnectionInterface $con the connection to use
+ * @param array $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects.
+ *
+ * @return ChildCategory The current object (for fluent API support)
+ */
+ public function populateFromVersion($version, $con = null, &$loadedObjects = array())
+ {
+ $loadedObjects['ChildCategory'][$version->getId()][$version->getVersion()] = $this;
+ $this->setId($version->getId());
+ $this->setParent($version->getParent());
+ $this->setLink($version->getLink());
+ $this->setVisible($version->getVisible());
+ $this->setPosition($version->getPosition());
+ $this->setCreatedAt($version->getCreatedAt());
+ $this->setUpdatedAt($version->getUpdatedAt());
+ $this->setVersion($version->getVersion());
+ $this->setVersionCreatedAt($version->getVersionCreatedAt());
+ $this->setVersionCreatedBy($version->getVersionCreatedBy());
+
+ return $this;
+ }
+
+ /**
+ * Gets the latest persisted version number for the current object
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return integer
+ */
+ public function getLastVersionNumber($con = null)
+ {
+ $v = ChildCategoryVersionQuery::create()
+ ->filterByCategory($this)
+ ->orderByVersion('desc')
+ ->findOne($con);
+ if (!$v) {
+ return 0;
+ }
+
+ return $v->getVersion();
+ }
+
+ /**
+ * Checks whether the current object is the latest one
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return Boolean
+ */
+ public function isLastVersion($con = null)
+ {
+ return $this->getLastVersionNumber($con) == $this->getVersion();
+ }
+
+ /**
+ * Retrieves a version object for this entity and a version number
+ *
+ * @param integer $versionNumber The version number to read
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ChildCategoryVersion A version object
+ */
+ public function getOneVersion($versionNumber, $con = null)
+ {
+ return ChildCategoryVersionQuery::create()
+ ->filterByCategory($this)
+ ->filterByVersion($versionNumber)
+ ->findOne($con);
+ }
+
+ /**
+ * Gets all the versions of this object, in incremental order
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ObjectCollection A list of ChildCategoryVersion objects
+ */
+ public function getAllVersions($con = null)
+ {
+ $criteria = new Criteria();
+ $criteria->addAscendingOrderByColumn(CategoryVersionTableMap::VERSION);
+
+ return $this->getCategoryVersions($criteria, $con);
+ }
+
+ /**
+ * Compares the current object with another of its version.
+ *
+ * print_r($book->compareVersion(1));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $versionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param ConnectionInterface $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->toArray();
+ $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Compares two versions of the current object.
+ *
+ * print_r($book->compareVersions(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $fromVersionNumber
+ * @param integer $toVersionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param ConnectionInterface $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
+ $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Computes the diff between two versions.
+ *
+ * print_r($book->computeDiff(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param array $fromVersion An array representing the original version.
+ * @param array $toVersion An array representing the destination version.
+ * @param string $keys Main key used for the result diff (versions|columns).
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
+ {
+ $fromVersionNumber = $fromVersion['Version'];
+ $toVersionNumber = $toVersion['Version'];
+ $ignoredColumns = array_merge(array(
+ 'Version',
+ 'VersionCreatedAt',
+ 'VersionCreatedBy',
+ ), $ignoredColumns);
+ $diff = array();
+ foreach ($fromVersion as $key => $value) {
+ if (in_array($key, $ignoredColumns)) {
+ continue;
+ }
+ if ($toVersion[$key] != $value) {
+ switch ($keys) {
+ case 'versions':
+ $diff[$fromVersionNumber][$key] = $value;
+ $diff[$toVersionNumber][$key] = $toVersion[$key];
+ break;
+ default:
+ $diff[$key] = array(
+ $fromVersionNumber => $value,
+ $toVersionNumber => $toVersion[$key],
+ );
+ break;
+ }
+ }
+ }
+
+ return $diff;
+ }
+ /**
+ * retrieve the last $number versions.
+ *
+ * @param Integer $number the number of record to return.
+ * @return PropelCollection|array \Thelia\Model\CategoryVersion[] List of \Thelia\Model\CategoryVersion objects
+ */
+ public function getLastVersions($number = 10, $criteria = null, $con = null)
+ {
+ $criteria = ChildCategoryVersionQuery::create(null, $criteria);
+ $criteria->addDescendingOrderByColumn(CategoryVersionTableMap::VERSION);
+ $criteria->limit($number);
+
+ return $this->getCategoryVersions($criteria, $con);
+ }
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/CategoryI18n.php b/core/lib/Thelia/Model/Base/CategoryI18n.php
new file mode 100644
index 000000000..65fa17063
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CategoryI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\CategoryI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CategoryI18n instance. If
+ * obj is an instance of CategoryI18n, delegates to
+ * equals(CategoryI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CategoryI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CategoryI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\CategoryI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CategoryI18nTableMap::ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CategoryI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = CategoryI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CategoryI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = CategoryI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CategoryI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = CategoryI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CategoryI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = CategoryI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CategoryI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = CategoryI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CategoryI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CategoryI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = CategoryI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\CategoryI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCategory !== null && $this->id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CategoryI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCategoryI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCategory = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CategoryI18n::setDeleted()
+ * @see CategoryI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCategoryI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CategoryI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CategoryI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CategoryI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(CategoryI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(CategoryI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(CategoryI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(CategoryI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO category_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CategoryI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CategoryI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CategoryI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = CategoryI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CategoryI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CategoryI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(CategoryI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CategoryI18nTableMap::ID)) $criteria->add(CategoryI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(CategoryI18nTableMap::LOCALE)) $criteria->add(CategoryI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(CategoryI18nTableMap::TITLE)) $criteria->add(CategoryI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(CategoryI18nTableMap::DESCRIPTION)) $criteria->add(CategoryI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(CategoryI18nTableMap::CHAPO)) $criteria->add(CategoryI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(CategoryI18nTableMap::POSTSCRIPTUM)) $criteria->add(CategoryI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(CategoryI18nTableMap::DATABASE_NAME);
+ $criteria->add(CategoryI18nTableMap::ID, $this->id);
+ $criteria->add(CategoryI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\CategoryI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\CategoryI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCategory object.
+ *
+ * @param ChildCategory $v
+ * @return \Thelia\Model\CategoryI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCategory(ChildCategory $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCategory object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCategoryI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCategory object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCategory The associated ChildCategory object.
+ * @throws PropelException
+ */
+ public function getCategory(ConnectionInterface $con = null)
+ {
+ if ($this->aCategory === null && ($this->id !== null)) {
+ $this->aCategory = ChildCategoryQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCategory->addCategoryI18ns($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCategory = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CategoryI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/CategoryI18nQuery.php b/core/lib/Thelia/Model/Base/CategoryI18nQuery.php
new file mode 100644
index 000000000..595a72aa9
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CategoryI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCategoryI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CategoryI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CategoryI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCategoryI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM category_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildCategoryI18n();
+ $obj->hydrate($row);
+ CategoryI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCategoryI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCategoryI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(CategoryI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(CategoryI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCategoryI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(CategoryI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(CategoryI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CategoryI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CategoryI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Category object
+ *
+ * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryI18nQuery The current query, for fluid interface
+ */
+ public function filterByCategory($category, $comparison = null)
+ {
+ if ($category instanceof \Thelia\Model\Category) {
+ return $this
+ ->addUsingAlias(CategoryI18nTableMap::ID, $category->getId(), $comparison);
+ } elseif ($category instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CategoryI18nTableMap::ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Category relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCategoryI18nQuery The current query, for fluid interface
+ */
+ public function joinCategory($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Category');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Category');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Category relation Category object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCategoryI18n $categoryI18n Object to remove from the list of results
+ *
+ * @return ChildCategoryI18nQuery The current query, for fluid interface
+ */
+ public function prune($categoryI18n = null)
+ {
+ if ($categoryI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(CategoryI18nTableMap::ID), $categoryI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(CategoryI18nTableMap::LOCALE), $categoryI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the category_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CategoryI18nTableMap::clearInstancePool();
+ CategoryI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCategoryI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCategoryI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryI18nTableMap::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->beginTransaction();
+
+
+ CategoryI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CategoryI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // CategoryI18nQuery
diff --git a/core/lib/Thelia/Model/Base/CategoryQuery.php b/core/lib/Thelia/Model/Base/CategoryQuery.php
new file mode 100644
index 000000000..caf05cbec
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CategoryQuery.php
@@ -0,0 +1,1637 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCategory|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CategoryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CategoryTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCategory A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, PARENT, LINK, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM category WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildCategory();
+ $obj->hydrate($row);
+ CategoryTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCategory|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CategoryTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CategoryTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CategoryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CategoryTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the parent column
+ *
+ * Example usage:
+ *
+ * $query->filterByParent(1234); // WHERE parent = 1234
+ * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34)
+ * $query->filterByParent(array('min' => 12)); // WHERE parent > 12
+ *
+ *
+ * @param mixed $parent The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByParent($parent = null, $comparison = null)
+ {
+ if (is_array($parent)) {
+ $useMinMax = false;
+ if (isset($parent['min'])) {
+ $this->addUsingAlias(CategoryTableMap::PARENT, $parent['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($parent['max'])) {
+ $this->addUsingAlias(CategoryTableMap::PARENT, $parent['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryTableMap::PARENT, $parent, $comparison);
+ }
+
+ /**
+ * Filter the query on the link column
+ *
+ * Example usage:
+ *
+ * $query->filterByLink('fooValue'); // WHERE link = 'fooValue'
+ * $query->filterByLink('%fooValue%'); // WHERE link LIKE '%fooValue%'
+ *
+ *
+ * @param string $link The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByLink($link = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($link)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $link)) {
+ $link = str_replace('*', '%', $link);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryTableMap::LINK, $link, $comparison);
+ }
+
+ /**
+ * Filter the query on the visible column
+ *
+ * Example usage:
+ *
+ * $query->filterByVisible(1234); // WHERE visible = 1234
+ * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
+ * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
+ *
+ *
+ * @param mixed $visible The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByVisible($visible = null, $comparison = null)
+ {
+ if (is_array($visible)) {
+ $useMinMax = false;
+ if (isset($visible['min'])) {
+ $this->addUsingAlias(CategoryTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(CategoryTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryTableMap::VISIBLE, $visible, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(CategoryTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(CategoryTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CategoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CategoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CategoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CategoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(CategoryTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(CategoryTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryTableMap::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(CategoryTableMap::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(CategoryTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ProductCategory object
+ *
+ * @param \Thelia\Model\ProductCategory|ObjectCollection $productCategory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByProductCategory($productCategory, $comparison = null)
+ {
+ if ($productCategory instanceof \Thelia\Model\ProductCategory) {
+ return $this
+ ->addUsingAlias(CategoryTableMap::ID, $productCategory->getCategoryId(), $comparison);
+ } elseif ($productCategory instanceof ObjectCollection) {
+ return $this
+ ->useProductCategoryQuery()
+ ->filterByPrimaryKeys($productCategory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByProductCategory() only accepts arguments of type \Thelia\Model\ProductCategory or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ProductCategory relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function joinProductCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ProductCategory');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ProductCategory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ProductCategory relation ProductCategory object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductCategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useProductCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinProductCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ProductCategory', '\Thelia\Model\ProductCategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\FeatureCategory object
+ *
+ * @param \Thelia\Model\FeatureCategory|ObjectCollection $featureCategory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByFeatureCategory($featureCategory, $comparison = null)
+ {
+ if ($featureCategory instanceof \Thelia\Model\FeatureCategory) {
+ return $this
+ ->addUsingAlias(CategoryTableMap::ID, $featureCategory->getCategoryId(), $comparison);
+ } elseif ($featureCategory instanceof ObjectCollection) {
+ return $this
+ ->useFeatureCategoryQuery()
+ ->filterByPrimaryKeys($featureCategory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureCategory() only accepts arguments of type \Thelia\Model\FeatureCategory or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureCategory relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function joinFeatureCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureCategory');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureCategory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureCategory relation FeatureCategory object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureCategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeatureCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureCategory', '\Thelia\Model\FeatureCategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\AttributeCategory object
+ *
+ * @param \Thelia\Model\AttributeCategory|ObjectCollection $attributeCategory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByAttributeCategory($attributeCategory, $comparison = null)
+ {
+ if ($attributeCategory instanceof \Thelia\Model\AttributeCategory) {
+ return $this
+ ->addUsingAlias(CategoryTableMap::ID, $attributeCategory->getCategoryId(), $comparison);
+ } elseif ($attributeCategory instanceof ObjectCollection) {
+ return $this
+ ->useAttributeCategoryQuery()
+ ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeCategory() only accepts arguments of type \Thelia\Model\AttributeCategory or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeCategory relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeCategory');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AttributeCategory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeCategory relation AttributeCategory object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeCategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ContentAssoc object
+ *
+ * @param \Thelia\Model\ContentAssoc|ObjectCollection $contentAssoc the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByContentAssoc($contentAssoc, $comparison = null)
+ {
+ if ($contentAssoc instanceof \Thelia\Model\ContentAssoc) {
+ return $this
+ ->addUsingAlias(CategoryTableMap::ID, $contentAssoc->getCategoryId(), $comparison);
+ } elseif ($contentAssoc instanceof ObjectCollection) {
+ return $this
+ ->useContentAssocQuery()
+ ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByContentAssoc() only accepts arguments of type \Thelia\Model\ContentAssoc or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ContentAssoc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ContentAssoc');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ContentAssoc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ContentAssoc relation ContentAssoc object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query
+ */
+ public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinContentAssoc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Image object
+ *
+ * @param \Thelia\Model\Image|ObjectCollection $image the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByImage($image, $comparison = null)
+ {
+ if ($image instanceof \Thelia\Model\Image) {
+ return $this
+ ->addUsingAlias(CategoryTableMap::ID, $image->getCategoryId(), $comparison);
+ } elseif ($image instanceof ObjectCollection) {
+ return $this
+ ->useImageQuery()
+ ->filterByPrimaryKeys($image->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Image relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Image');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Image');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Image relation Image object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
+ */
+ public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinImage($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Document object
+ *
+ * @param \Thelia\Model\Document|ObjectCollection $document the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByDocument($document, $comparison = null)
+ {
+ if ($document instanceof \Thelia\Model\Document) {
+ return $this
+ ->addUsingAlias(CategoryTableMap::ID, $document->getCategoryId(), $comparison);
+ } elseif ($document instanceof ObjectCollection) {
+ return $this
+ ->useDocumentQuery()
+ ->filterByPrimaryKeys($document->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Document relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Document');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Document');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Document relation Document object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query
+ */
+ public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinDocument($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Rewriting object
+ *
+ * @param \Thelia\Model\Rewriting|ObjectCollection $rewriting the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByRewriting($rewriting, $comparison = null)
+ {
+ if ($rewriting instanceof \Thelia\Model\Rewriting) {
+ return $this
+ ->addUsingAlias(CategoryTableMap::ID, $rewriting->getCategoryId(), $comparison);
+ } elseif ($rewriting instanceof ObjectCollection) {
+ return $this
+ ->useRewritingQuery()
+ ->filterByPrimaryKeys($rewriting->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByRewriting() only accepts arguments of type \Thelia\Model\Rewriting or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Rewriting relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Rewriting');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Rewriting');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Rewriting relation Rewriting object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query
+ */
+ public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinRewriting($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\CategoryI18n object
+ *
+ * @param \Thelia\Model\CategoryI18n|ObjectCollection $categoryI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCategoryI18n($categoryI18n, $comparison = null)
+ {
+ if ($categoryI18n instanceof \Thelia\Model\CategoryI18n) {
+ return $this
+ ->addUsingAlias(CategoryTableMap::ID, $categoryI18n->getId(), $comparison);
+ } elseif ($categoryI18n instanceof ObjectCollection) {
+ return $this
+ ->useCategoryI18nQuery()
+ ->filterByPrimaryKeys($categoryI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCategoryI18n() only accepts arguments of type \Thelia\Model\CategoryI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CategoryI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function joinCategoryI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CategoryI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'CategoryI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CategoryI18n relation CategoryI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CategoryI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinCategoryI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CategoryI18n', '\Thelia\Model\CategoryI18nQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\CategoryVersion object
+ *
+ * @param \Thelia\Model\CategoryVersion|ObjectCollection $categoryVersion the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCategoryVersion($categoryVersion, $comparison = null)
+ {
+ if ($categoryVersion instanceof \Thelia\Model\CategoryVersion) {
+ return $this
+ ->addUsingAlias(CategoryTableMap::ID, $categoryVersion->getId(), $comparison);
+ } elseif ($categoryVersion instanceof ObjectCollection) {
+ return $this
+ ->useCategoryVersionQuery()
+ ->filterByPrimaryKeys($categoryVersion->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCategoryVersion() only accepts arguments of type \Thelia\Model\CategoryVersion or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CategoryVersion relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function joinCategoryVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CategoryVersion');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'CategoryVersion');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CategoryVersion relation CategoryVersion object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CategoryVersionQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryVersionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCategoryVersion($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CategoryVersion', '\Thelia\Model\CategoryVersionQuery');
+ }
+
+ /**
+ * Filter the query by a related Product object
+ * using the product_category table as cross reference
+ *
+ * @param Product $product the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByProduct($product, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useProductCategoryQuery()
+ ->filterByProduct($product, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Filter the query by a related Feature object
+ * using the feature_category table as cross reference
+ *
+ * @param Feature $feature the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByFeature($feature, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useFeatureCategoryQuery()
+ ->filterByFeature($feature, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Filter the query by a related Attribute object
+ * using the attribute_category table as cross reference
+ *
+ * @param Attribute $attribute the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function filterByAttribute($attribute, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useAttributeCategoryQuery()
+ ->filterByAttribute($attribute, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCategory $category Object to remove from the list of results
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function prune($category = null)
+ {
+ if ($category) {
+ $this->addUsingAlias(CategoryTableMap::ID, $category->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the category table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CategoryTableMap::clearInstancePool();
+ CategoryTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCategory or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCategory object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryTableMap::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->beginTransaction();
+
+
+ CategoryTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CategoryTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CategoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CategoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CategoryTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CategoryTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CategoryTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CategoryTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'CategoryI18n';
+
+ return $this
+ ->joinCategoryI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCategoryQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('CategoryI18n');
+ $this->with['CategoryI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCategoryI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CategoryI18n', '\Thelia\Model\CategoryI18nQuery');
+ }
+
+ // versionable behavior
+
+ /**
+ * Checks whether versioning is enabled
+ *
+ * @return boolean
+ */
+ static public function isVersioningEnabled()
+ {
+ return self::$isVersioningEnabled;
+ }
+
+ /**
+ * Enables versioning
+ */
+ static public function enableVersioning()
+ {
+ self::$isVersioningEnabled = true;
+ }
+
+ /**
+ * Disables versioning
+ */
+ static public function disableVersioning()
+ {
+ self::$isVersioningEnabled = false;
+ }
+
+} // CategoryQuery
diff --git a/core/lib/Thelia/Model/Base/CategoryVersion.php b/core/lib/Thelia/Model/Base/CategoryVersion.php
new file mode 100644
index 000000000..807e26b79
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CategoryVersion.php
@@ -0,0 +1,1709 @@
+version = 0;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\CategoryVersion object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CategoryVersion instance. If
+ * obj is an instance of CategoryVersion, delegates to
+ * equals(CategoryVersion). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CategoryVersion The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CategoryVersion The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [parent] column value.
+ *
+ * @return int
+ */
+ public function getParent()
+ {
+
+ return $this->parent;
+ }
+
+ /**
+ * Get the [link] column value.
+ *
+ * @return string
+ */
+ public function getLink()
+ {
+
+ return $this->link;
+ }
+
+ /**
+ * Get the [visible] column value.
+ *
+ * @return int
+ */
+ public function getVisible()
+ {
+
+ return $this->visible;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getVersionCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->version_created_at;
+ } else {
+ return $this->version_created_at !== null ? $this->version_created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\CategoryVersion The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CategoryVersionTableMap::ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [parent] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\CategoryVersion The current object (for fluent API support)
+ */
+ public function setParent($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->parent !== $v) {
+ $this->parent = $v;
+ $this->modifiedColumns[] = CategoryVersionTableMap::PARENT;
+ }
+
+
+ return $this;
+ } // setParent()
+
+ /**
+ * Set the value of [link] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CategoryVersion The current object (for fluent API support)
+ */
+ public function setLink($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->link !== $v) {
+ $this->link = $v;
+ $this->modifiedColumns[] = CategoryVersionTableMap::LINK;
+ }
+
+
+ return $this;
+ } // setLink()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\CategoryVersion The current object (for fluent API support)
+ */
+ public function setVisible($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->visible !== $v) {
+ $this->visible = $v;
+ $this->modifiedColumns[] = CategoryVersionTableMap::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\CategoryVersion The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = CategoryVersionTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\CategoryVersion The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = CategoryVersionTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\CategoryVersion The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = CategoryVersionTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\CategoryVersion The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = CategoryVersionTableMap::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\CategoryVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ if ($dt !== $this->version_created_at) {
+ $this->version_created_at = $dt;
+ $this->modifiedColumns[] = CategoryVersionTableMap::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CategoryVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = CategoryVersionTableMap::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->version !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CategoryVersionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CategoryVersionTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->parent = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryVersionTableMap::translateFieldName('Link', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->link = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryVersionTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->visible = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryVersionTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CategoryVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CategoryVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CategoryVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CategoryVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version_created_by = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 10; // 10 = CategoryVersionTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\CategoryVersion object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCategory !== null && $this->id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CategoryVersionTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCategoryVersionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCategory = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CategoryVersion::setDeleted()
+ * @see CategoryVersion::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryVersionTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCategoryVersionQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryVersionTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CategoryVersionTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CategoryVersionTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CategoryVersionTableMap::PARENT)) {
+ $modifiedColumns[':p' . $index++] = 'PARENT';
+ }
+ if ($this->isColumnModified(CategoryVersionTableMap::LINK)) {
+ $modifiedColumns[':p' . $index++] = 'LINK';
+ }
+ if ($this->isColumnModified(CategoryVersionTableMap::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = 'VISIBLE';
+ }
+ if ($this->isColumnModified(CategoryVersionTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(CategoryVersionTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CategoryVersionTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+ if ($this->isColumnModified(CategoryVersionTableMap::VERSION)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION';
+ }
+ if ($this->isColumnModified(CategoryVersionTableMap::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT';
+ }
+ if ($this->isColumnModified(CategoryVersionTableMap::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO category_version (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'PARENT':
+ $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT);
+ break;
+ case 'LINK':
+ $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR);
+ break;
+ case 'VISIBLE':
+ $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case 'VERSION_CREATED_AT':
+ $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION_CREATED_BY':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CategoryVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getParent();
+ break;
+ case 2:
+ return $this->getLink();
+ break;
+ case 3:
+ return $this->getVisible();
+ break;
+ case 4:
+ return $this->getPosition();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ case 7:
+ return $this->getVersion();
+ break;
+ case 8:
+ return $this->getVersionCreatedAt();
+ break;
+ case 9:
+ return $this->getVersionCreatedBy();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CategoryVersion'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CategoryVersion'][serialize($this->getPrimaryKey())] = true;
+ $keys = CategoryVersionTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getParent(),
+ $keys[2] => $this->getLink(),
+ $keys[3] => $this->getVisible(),
+ $keys[4] => $this->getPosition(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ $keys[7] => $this->getVersion(),
+ $keys[8] => $this->getVersionCreatedAt(),
+ $keys[9] => $this->getVersionCreatedBy(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CategoryVersionTableMap::translateFieldName($name, $type, TableMap::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->setParent($value);
+ break;
+ case 2:
+ $this->setLink($value);
+ break;
+ case 3:
+ $this->setVisible($value);
+ break;
+ case 4:
+ $this->setPosition($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ case 7:
+ $this->setVersion($value);
+ break;
+ case 8:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 9:
+ $this->setVersionCreatedBy($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CategoryVersionTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]);
+ }
+
+ /**
+ * 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(CategoryVersionTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CategoryVersionTableMap::ID)) $criteria->add(CategoryVersionTableMap::ID, $this->id);
+ if ($this->isColumnModified(CategoryVersionTableMap::PARENT)) $criteria->add(CategoryVersionTableMap::PARENT, $this->parent);
+ if ($this->isColumnModified(CategoryVersionTableMap::LINK)) $criteria->add(CategoryVersionTableMap::LINK, $this->link);
+ if ($this->isColumnModified(CategoryVersionTableMap::VISIBLE)) $criteria->add(CategoryVersionTableMap::VISIBLE, $this->visible);
+ if ($this->isColumnModified(CategoryVersionTableMap::POSITION)) $criteria->add(CategoryVersionTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(CategoryVersionTableMap::CREATED_AT)) $criteria->add(CategoryVersionTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CategoryVersionTableMap::UPDATED_AT)) $criteria->add(CategoryVersionTableMap::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(CategoryVersionTableMap::VERSION)) $criteria->add(CategoryVersionTableMap::VERSION, $this->version);
+ if ($this->isColumnModified(CategoryVersionTableMap::VERSION_CREATED_AT)) $criteria->add(CategoryVersionTableMap::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(CategoryVersionTableMap::VERSION_CREATED_BY)) $criteria->add(CategoryVersionTableMap::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(CategoryVersionTableMap::DATABASE_NAME);
+ $criteria->add(CategoryVersionTableMap::ID, $this->id);
+ $criteria->add(CategoryVersionTableMap::VERSION, $this->version);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getVersion();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setVersion($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getVersion());
+ }
+
+ /**
+ * 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 \Thelia\Model\CategoryVersion (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setParent($this->getParent());
+ $copyObj->setLink($this->getLink());
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\CategoryVersion 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCategory object.
+ *
+ * @param ChildCategory $v
+ * @return \Thelia\Model\CategoryVersion The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCategory(ChildCategory $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCategory object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCategoryVersion($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCategory object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCategory The associated ChildCategory object.
+ * @throws PropelException
+ */
+ public function getCategory(ConnectionInterface $con = null)
+ {
+ if ($this->aCategory === null && ($this->id !== null)) {
+ $this->aCategory = ChildCategoryQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCategory->addCategoryVersions($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->parent = null;
+ $this->link = null;
+ $this->visible = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCategory = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CategoryVersionTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/CategoryVersionQuery.php b/core/lib/Thelia/Model/Base/CategoryVersionQuery.php
new file mode 100644
index 000000000..3eac5e8cd
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CategoryVersionQuery.php
@@ -0,0 +1,829 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $version] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCategoryVersion|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CategoryVersionTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CategoryVersionTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCategoryVersion A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, PARENT, LINK, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM category_version WHERE ID = :p0 AND VERSION = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildCategoryVersion();
+ $obj->hydrate($row);
+ CategoryVersionTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCategoryVersion|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(CategoryVersionTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(CategoryVersionTableMap::VERSION, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(CategoryVersionTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(CategoryVersionTableMap::VERSION, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the parent column
+ *
+ * Example usage:
+ *
+ * $query->filterByParent(1234); // WHERE parent = 1234
+ * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34)
+ * $query->filterByParent(array('min' => 12)); // WHERE parent > 12
+ *
+ *
+ * @param mixed $parent The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByParent($parent = null, $comparison = null)
+ {
+ if (is_array($parent)) {
+ $useMinMax = false;
+ if (isset($parent['min'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::PARENT, $parent['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($parent['max'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::PARENT, $parent['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionTableMap::PARENT, $parent, $comparison);
+ }
+
+ /**
+ * Filter the query on the link column
+ *
+ * Example usage:
+ *
+ * $query->filterByLink('fooValue'); // WHERE link = 'fooValue'
+ * $query->filterByLink('%fooValue%'); // WHERE link LIKE '%fooValue%'
+ *
+ *
+ * @param string $link The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByLink($link = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($link)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $link)) {
+ $link = str_replace('*', '%', $link);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionTableMap::LINK, $link, $comparison);
+ }
+
+ /**
+ * Filter the query on the visible column
+ *
+ * Example usage:
+ *
+ * $query->filterByVisible(1234); // WHERE visible = 1234
+ * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
+ * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
+ *
+ *
+ * @param mixed $visible The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByVisible($visible = null, $comparison = null)
+ {
+ if (is_array($visible)) {
+ $useMinMax = false;
+ if (isset($visible['min'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionTableMap::VISIBLE, $visible, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionTableMap::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(CategoryVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CategoryVersionTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Category object
+ *
+ * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function filterByCategory($category, $comparison = null)
+ {
+ if ($category instanceof \Thelia\Model\Category) {
+ return $this
+ ->addUsingAlias(CategoryVersionTableMap::ID, $category->getId(), $comparison);
+ } elseif ($category instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CategoryVersionTableMap::ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Category relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Category');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Category');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Category relation Category object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCategoryVersion $categoryVersion Object to remove from the list of results
+ *
+ * @return ChildCategoryVersionQuery The current query, for fluid interface
+ */
+ public function prune($categoryVersion = null)
+ {
+ if ($categoryVersion) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(CategoryVersionTableMap::ID), $categoryVersion->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(CategoryVersionTableMap::VERSION), $categoryVersion->getVersion(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the category_version table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryVersionTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CategoryVersionTableMap::clearInstancePool();
+ CategoryVersionTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCategoryVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCategoryVersion object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryVersionTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CategoryVersionTableMap::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->beginTransaction();
+
+
+ CategoryVersionTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CategoryVersionTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // CategoryVersionQuery
diff --git a/core/lib/Thelia/Model/Base/Combination.php b/core/lib/Thelia/Model/Base/Combination.php
new file mode 100644
index 000000000..e7cd93da7
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Combination.php
@@ -0,0 +1,1923 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Combination instance. If
+ * obj is an instance of Combination, delegates to
+ * equals(Combination). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Combination The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Combination The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [ref] column value.
+ *
+ * @return string
+ */
+ public function getRef()
+ {
+
+ return $this->ref;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Combination The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CombinationTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Combination The current object (for fluent API support)
+ */
+ public function setRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->ref !== $v) {
+ $this->ref = $v;
+ $this->modifiedColumns[] = CombinationTableMap::REF;
+ }
+
+
+ return $this;
+ } // setRef()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Combination The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = CombinationTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Combination The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = CombinationTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CombinationTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CombinationTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->ref = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CombinationTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CombinationTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = CombinationTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Combination object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CombinationTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCombinationQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collAttributeCombinations = null;
+
+ $this->collStocks = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Combination::setDeleted()
+ * @see Combination::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCombinationQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CombinationTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CombinationTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CombinationTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CombinationTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->attributeCombinationsScheduledForDeletion !== null) {
+ if (!$this->attributeCombinationsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\AttributeCombinationQuery::create()
+ ->filterByPrimaryKeys($this->attributeCombinationsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->attributeCombinationsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAttributeCombinations !== null) {
+ foreach ($this->collAttributeCombinations as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->stocksScheduledForDeletion !== null) {
+ if (!$this->stocksScheduledForDeletion->isEmpty()) {
+ foreach ($this->stocksScheduledForDeletion as $stock) {
+ // need to save related object because we set the relation to null
+ $stock->save($con);
+ }
+ $this->stocksScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collStocks !== null) {
+ foreach ($this->collStocks as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CombinationTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CombinationTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CombinationTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CombinationTableMap::REF)) {
+ $modifiedColumns[':p' . $index++] = 'REF';
+ }
+ if ($this->isColumnModified(CombinationTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CombinationTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO combination (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'REF':
+ $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getRef();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Combination'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Combination'][$this->getPrimaryKey()] = true;
+ $keys = CombinationTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getRef(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collAttributeCombinations) {
+ $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collStocks) {
+ $result['Stocks'] = $this->collStocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CombinationTableMap::translateFieldName($name, $type, TableMap::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->setRef($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CombinationTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * 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(CombinationTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CombinationTableMap::ID)) $criteria->add(CombinationTableMap::ID, $this->id);
+ if ($this->isColumnModified(CombinationTableMap::REF)) $criteria->add(CombinationTableMap::REF, $this->ref);
+ if ($this->isColumnModified(CombinationTableMap::CREATED_AT)) $criteria->add(CombinationTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CombinationTableMap::UPDATED_AT)) $criteria->add(CombinationTableMap::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(CombinationTableMap::DATABASE_NAME);
+ $criteria->add(CombinationTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Combination (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setRef($this->getRef());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getAttributeCombinations() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAttributeCombination($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getStocks() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addStock($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Combination 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('AttributeCombination' == $relationName) {
+ return $this->initAttributeCombinations();
+ }
+ if ('Stock' == $relationName) {
+ return $this->initStocks();
+ }
+ }
+
+ /**
+ * Clears out the collAttributeCombinations collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAttributeCombinations()
+ */
+ public function clearAttributeCombinations()
+ {
+ $this->collAttributeCombinations = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collAttributeCombinations collection loaded partially.
+ */
+ public function resetPartialAttributeCombinations($v = true)
+ {
+ $this->collAttributeCombinationsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAttributeCombinations collection.
+ *
+ * By default this just sets the collAttributeCombinations collection to an empty array (like clearcollAttributeCombinations());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAttributeCombinations($overrideExisting = true)
+ {
+ if (null !== $this->collAttributeCombinations && !$overrideExisting) {
+ return;
+ }
+ $this->collAttributeCombinations = new ObjectCollection();
+ $this->collAttributeCombinations->setModel('\Thelia\Model\AttributeCombination');
+ }
+
+ /**
+ * Gets an array of ChildAttributeCombination objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCombination is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects
+ * @throws PropelException
+ */
+ public function getAttributeCombinations($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeCombinationsPartial && !$this->isNew();
+ if (null === $this->collAttributeCombinations || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCombinations) {
+ // return empty collection
+ $this->initAttributeCombinations();
+ } else {
+ $collAttributeCombinations = ChildAttributeCombinationQuery::create(null, $criteria)
+ ->filterByCombination($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collAttributeCombinationsPartial && count($collAttributeCombinations)) {
+ $this->initAttributeCombinations(false);
+
+ foreach ($collAttributeCombinations as $obj) {
+ if (false == $this->collAttributeCombinations->contains($obj)) {
+ $this->collAttributeCombinations->append($obj);
+ }
+ }
+
+ $this->collAttributeCombinationsPartial = true;
+ }
+
+ $collAttributeCombinations->getInternalIterator()->rewind();
+
+ return $collAttributeCombinations;
+ }
+
+ if ($partial && $this->collAttributeCombinations) {
+ foreach ($this->collAttributeCombinations as $obj) {
+ if ($obj->isNew()) {
+ $collAttributeCombinations[] = $obj;
+ }
+ }
+ }
+
+ $this->collAttributeCombinations = $collAttributeCombinations;
+ $this->collAttributeCombinationsPartial = false;
+ }
+ }
+
+ return $this->collAttributeCombinations;
+ }
+
+ /**
+ * Sets a collection of AttributeCombination objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $attributeCombinations A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCombination The current object (for fluent API support)
+ */
+ public function setAttributeCombinations(Collection $attributeCombinations, ConnectionInterface $con = null)
+ {
+ $attributeCombinationsToDelete = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->attributeCombinationsScheduledForDeletion = clone $attributeCombinationsToDelete;
+
+ foreach ($attributeCombinationsToDelete as $attributeCombinationRemoved) {
+ $attributeCombinationRemoved->setCombination(null);
+ }
+
+ $this->collAttributeCombinations = null;
+ foreach ($attributeCombinations as $attributeCombination) {
+ $this->addAttributeCombination($attributeCombination);
+ }
+
+ $this->collAttributeCombinations = $attributeCombinations;
+ $this->collAttributeCombinationsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related AttributeCombination objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related AttributeCombination objects.
+ * @throws PropelException
+ */
+ public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAttributeCombinationsPartial && !$this->isNew();
+ if (null === $this->collAttributeCombinations || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAttributeCombinations) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getAttributeCombinations());
+ }
+
+ $query = ChildAttributeCombinationQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCombination($this)
+ ->count($con);
+ }
+
+ return count($this->collAttributeCombinations);
+ }
+
+ /**
+ * Method called to associate a ChildAttributeCombination object to this object
+ * through the ChildAttributeCombination foreign key attribute.
+ *
+ * @param ChildAttributeCombination $l ChildAttributeCombination
+ * @return \Thelia\Model\Combination The current object (for fluent API support)
+ */
+ public function addAttributeCombination(ChildAttributeCombination $l)
+ {
+ if ($this->collAttributeCombinations === null) {
+ $this->initAttributeCombinations();
+ $this->collAttributeCombinationsPartial = true;
+ }
+
+ if (!in_array($l, $this->collAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddAttributeCombination($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AttributeCombination $attributeCombination The attributeCombination object to add.
+ */
+ protected function doAddAttributeCombination($attributeCombination)
+ {
+ $this->collAttributeCombinations[]= $attributeCombination;
+ $attributeCombination->setCombination($this);
+ }
+
+ /**
+ * @param AttributeCombination $attributeCombination The attributeCombination object to remove.
+ * @return ChildCombination The current object (for fluent API support)
+ */
+ public function removeAttributeCombination($attributeCombination)
+ {
+ if ($this->getAttributeCombinations()->contains($attributeCombination)) {
+ $this->collAttributeCombinations->remove($this->collAttributeCombinations->search($attributeCombination));
+ if (null === $this->attributeCombinationsScheduledForDeletion) {
+ $this->attributeCombinationsScheduledForDeletion = clone $this->collAttributeCombinations;
+ $this->attributeCombinationsScheduledForDeletion->clear();
+ }
+ $this->attributeCombinationsScheduledForDeletion[]= clone $attributeCombination;
+ $attributeCombination->setCombination(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Combination is new, it will return
+ * an empty collection; or if this Combination has previously
+ * been saved, it will retrieve related AttributeCombinations 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 Combination.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects
+ */
+ public function getAttributeCombinationsJoinAttribute($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildAttributeCombinationQuery::create(null, $criteria);
+ $query->joinWith('Attribute', $joinBehavior);
+
+ return $this->getAttributeCombinations($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Combination is new, it will return
+ * an empty collection; or if this Combination has previously
+ * been saved, it will retrieve related AttributeCombinations 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 Combination.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects
+ */
+ public function getAttributeCombinationsJoinAttributeAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildAttributeCombinationQuery::create(null, $criteria);
+ $query->joinWith('AttributeAv', $joinBehavior);
+
+ return $this->getAttributeCombinations($query, $con);
+ }
+
+ /**
+ * Clears out the collStocks collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addStocks()
+ */
+ public function clearStocks()
+ {
+ $this->collStocks = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collStocks collection loaded partially.
+ */
+ public function resetPartialStocks($v = true)
+ {
+ $this->collStocksPartial = $v;
+ }
+
+ /**
+ * Initializes the collStocks collection.
+ *
+ * By default this just sets the collStocks collection to an empty array (like clearcollStocks());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initStocks($overrideExisting = true)
+ {
+ if (null !== $this->collStocks && !$overrideExisting) {
+ return;
+ }
+ $this->collStocks = new ObjectCollection();
+ $this->collStocks->setModel('\Thelia\Model\Stock');
+ }
+
+ /**
+ * Gets an array of ChildStock objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCombination is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildStock[] List of ChildStock objects
+ * @throws PropelException
+ */
+ public function getStocks($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collStocksPartial && !$this->isNew();
+ if (null === $this->collStocks || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collStocks) {
+ // return empty collection
+ $this->initStocks();
+ } else {
+ $collStocks = ChildStockQuery::create(null, $criteria)
+ ->filterByCombination($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collStocksPartial && count($collStocks)) {
+ $this->initStocks(false);
+
+ foreach ($collStocks as $obj) {
+ if (false == $this->collStocks->contains($obj)) {
+ $this->collStocks->append($obj);
+ }
+ }
+
+ $this->collStocksPartial = true;
+ }
+
+ $collStocks->getInternalIterator()->rewind();
+
+ return $collStocks;
+ }
+
+ if ($partial && $this->collStocks) {
+ foreach ($this->collStocks as $obj) {
+ if ($obj->isNew()) {
+ $collStocks[] = $obj;
+ }
+ }
+ }
+
+ $this->collStocks = $collStocks;
+ $this->collStocksPartial = false;
+ }
+ }
+
+ return $this->collStocks;
+ }
+
+ /**
+ * Sets a collection of Stock objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $stocks A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCombination The current object (for fluent API support)
+ */
+ public function setStocks(Collection $stocks, ConnectionInterface $con = null)
+ {
+ $stocksToDelete = $this->getStocks(new Criteria(), $con)->diff($stocks);
+
+
+ $this->stocksScheduledForDeletion = $stocksToDelete;
+
+ foreach ($stocksToDelete as $stockRemoved) {
+ $stockRemoved->setCombination(null);
+ }
+
+ $this->collStocks = null;
+ foreach ($stocks as $stock) {
+ $this->addStock($stock);
+ }
+
+ $this->collStocks = $stocks;
+ $this->collStocksPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Stock objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Stock objects.
+ * @throws PropelException
+ */
+ public function countStocks(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collStocksPartial && !$this->isNew();
+ if (null === $this->collStocks || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collStocks) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getStocks());
+ }
+
+ $query = ChildStockQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCombination($this)
+ ->count($con);
+ }
+
+ return count($this->collStocks);
+ }
+
+ /**
+ * Method called to associate a ChildStock object to this object
+ * through the ChildStock foreign key attribute.
+ *
+ * @param ChildStock $l ChildStock
+ * @return \Thelia\Model\Combination The current object (for fluent API support)
+ */
+ public function addStock(ChildStock $l)
+ {
+ if ($this->collStocks === null) {
+ $this->initStocks();
+ $this->collStocksPartial = true;
+ }
+
+ if (!in_array($l, $this->collStocks->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddStock($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Stock $stock The stock object to add.
+ */
+ protected function doAddStock($stock)
+ {
+ $this->collStocks[]= $stock;
+ $stock->setCombination($this);
+ }
+
+ /**
+ * @param Stock $stock The stock object to remove.
+ * @return ChildCombination The current object (for fluent API support)
+ */
+ public function removeStock($stock)
+ {
+ if ($this->getStocks()->contains($stock)) {
+ $this->collStocks->remove($this->collStocks->search($stock));
+ if (null === $this->stocksScheduledForDeletion) {
+ $this->stocksScheduledForDeletion = clone $this->collStocks;
+ $this->stocksScheduledForDeletion->clear();
+ }
+ $this->stocksScheduledForDeletion[]= $stock;
+ $stock->setCombination(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Combination is new, it will return
+ * an empty collection; or if this Combination has previously
+ * been saved, it will retrieve related Stocks 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 Combination.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildStock[] List of ChildStock objects
+ */
+ public function getStocksJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildStockQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getStocks($query, $con);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->ref = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collAttributeCombinations) {
+ foreach ($this->collAttributeCombinations as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collStocks) {
+ foreach ($this->collStocks as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collAttributeCombinations instanceof Collection) {
+ $this->collAttributeCombinations->clearIterator();
+ }
+ $this->collAttributeCombinations = null;
+ if ($this->collStocks instanceof Collection) {
+ $this->collStocks->clearIterator();
+ }
+ $this->collStocks = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CombinationTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCombination The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = CombinationTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/CombinationQuery.php b/core/lib/Thelia/Model/Base/CombinationQuery.php
new file mode 100644
index 000000000..7424f03f6
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CombinationQuery.php
@@ -0,0 +1,694 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCombination|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CombinationTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CombinationTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCombination A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, REF, CREATED_AT, UPDATED_AT FROM combination WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildCombination();
+ $obj->hydrate($row);
+ CombinationTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCombination|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CombinationTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CombinationTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CombinationTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CombinationTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CombinationTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
+ * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $ref The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function filterByRef($ref = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($ref)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $ref)) {
+ $ref = str_replace('*', '%', $ref);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CombinationTableMap::REF, $ref, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CombinationTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CombinationTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CombinationTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CombinationTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CombinationTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CombinationTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\AttributeCombination object
+ *
+ * @param \Thelia\Model\AttributeCombination|ObjectCollection $attributeCombination the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function filterByAttributeCombination($attributeCombination, $comparison = null)
+ {
+ if ($attributeCombination instanceof \Thelia\Model\AttributeCombination) {
+ return $this
+ ->addUsingAlias(CombinationTableMap::ID, $attributeCombination->getCombinationId(), $comparison);
+ } elseif ($attributeCombination instanceof ObjectCollection) {
+ return $this
+ ->useAttributeCombinationQuery()
+ ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAttributeCombination() only accepts arguments of type \Thelia\Model\AttributeCombination or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AttributeCombination relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function joinAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AttributeCombination');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AttributeCombination');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AttributeCombination relation AttributeCombination object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AttributeCombinationQuery A secondary query class using the current class as primary query
+ */
+ public function useAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAttributeCombination($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AttributeCombination', '\Thelia\Model\AttributeCombinationQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Stock object
+ *
+ * @param \Thelia\Model\Stock|ObjectCollection $stock the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function filterByStock($stock, $comparison = null)
+ {
+ if ($stock instanceof \Thelia\Model\Stock) {
+ return $this
+ ->addUsingAlias(CombinationTableMap::ID, $stock->getCombinationId(), $comparison);
+ } elseif ($stock instanceof ObjectCollection) {
+ return $this
+ ->useStockQuery()
+ ->filterByPrimaryKeys($stock->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByStock() only accepts arguments of type \Thelia\Model\Stock or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Stock relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function joinStock($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Stock');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Stock');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Stock relation Stock object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\StockQuery A secondary query class using the current class as primary query
+ */
+ public function useStockQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinStock($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCombination $combination Object to remove from the list of results
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function prune($combination = null)
+ {
+ if ($combination) {
+ $this->addUsingAlias(CombinationTableMap::ID, $combination->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the combination table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CombinationTableMap::clearInstancePool();
+ CombinationTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCombination or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCombination object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CombinationTableMap::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->beginTransaction();
+
+
+ CombinationTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CombinationTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CombinationTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CombinationTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CombinationTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CombinationTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CombinationTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCombinationQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CombinationTableMap::CREATED_AT);
+ }
+
+} // CombinationQuery
diff --git a/core/lib/Thelia/Model/Base/Config.php b/core/lib/Thelia/Model/Base/Config.php
new file mode 100644
index 000000000..140cdb82d
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Config.php
@@ -0,0 +1,1991 @@
+secured = 1;
+ $this->hidden = 1;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\Config object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Config instance. If
+ * obj is an instance of Config, delegates to
+ * equals(Config). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Config The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Config The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [name] column value.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+
+ return $this->name;
+ }
+
+ /**
+ * Get the [value] column value.
+ *
+ * @return string
+ */
+ public function getValue()
+ {
+
+ return $this->value;
+ }
+
+ /**
+ * Get the [secured] column value.
+ *
+ * @return int
+ */
+ public function getSecured()
+ {
+
+ return $this->secured;
+ }
+
+ /**
+ * Get the [hidden] column value.
+ *
+ * @return int
+ */
+ public function getHidden()
+ {
+
+ return $this->hidden;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Config The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ConfigTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [name] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Config The current object (for fluent API support)
+ */
+ public function setName($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->name !== $v) {
+ $this->name = $v;
+ $this->modifiedColumns[] = ConfigTableMap::NAME;
+ }
+
+
+ return $this;
+ } // setName()
+
+ /**
+ * Set the value of [value] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Config The current object (for fluent API support)
+ */
+ public function setValue($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->value !== $v) {
+ $this->value = $v;
+ $this->modifiedColumns[] = ConfigTableMap::VALUE;
+ }
+
+
+ return $this;
+ } // setValue()
+
+ /**
+ * Set the value of [secured] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Config The current object (for fluent API support)
+ */
+ public function setSecured($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->secured !== $v) {
+ $this->secured = $v;
+ $this->modifiedColumns[] = ConfigTableMap::SECURED;
+ }
+
+
+ return $this;
+ } // setSecured()
+
+ /**
+ * Set the value of [hidden] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Config The current object (for fluent API support)
+ */
+ public function setHidden($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->hidden !== $v) {
+ $this->hidden = $v;
+ $this->modifiedColumns[] = ConfigTableMap::HIDDEN;
+ }
+
+
+ return $this;
+ } // setHidden()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Config The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = ConfigTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Config The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = ConfigTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->secured !== 1) {
+ return false;
+ }
+
+ if ($this->hidden !== 1) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ConfigTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ConfigTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->name = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ConfigTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->value = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ConfigTableMap::translateFieldName('Secured', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->secured = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ConfigTableMap::translateFieldName('Hidden', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->hidden = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ConfigTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ConfigTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = ConfigTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Config object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ConfigTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildConfigQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collConfigI18ns = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Config::setDeleted()
+ * @see Config::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildConfigQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(ConfigTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(ConfigTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(ConfigTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ConfigTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->configI18nsScheduledForDeletion !== null) {
+ if (!$this->configI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ConfigI18nQuery::create()
+ ->filterByPrimaryKeys($this->configI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->configI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collConfigI18ns !== null) {
+ foreach ($this->collConfigI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ConfigTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ConfigTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ConfigTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ConfigTableMap::NAME)) {
+ $modifiedColumns[':p' . $index++] = 'NAME';
+ }
+ if ($this->isColumnModified(ConfigTableMap::VALUE)) {
+ $modifiedColumns[':p' . $index++] = 'VALUE';
+ }
+ if ($this->isColumnModified(ConfigTableMap::SECURED)) {
+ $modifiedColumns[':p' . $index++] = 'SECURED';
+ }
+ if ($this->isColumnModified(ConfigTableMap::HIDDEN)) {
+ $modifiedColumns[':p' . $index++] = 'HIDDEN';
+ }
+ if ($this->isColumnModified(ConfigTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(ConfigTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO config (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'NAME':
+ $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
+ break;
+ case 'VALUE':
+ $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
+ break;
+ case 'SECURED':
+ $stmt->bindValue($identifier, $this->secured, PDO::PARAM_INT);
+ break;
+ case 'HIDDEN':
+ $stmt->bindValue($identifier, $this->hidden, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ConfigTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getName();
+ break;
+ case 2:
+ return $this->getValue();
+ break;
+ case 3:
+ return $this->getSecured();
+ break;
+ case 4:
+ return $this->getHidden();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Config'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Config'][$this->getPrimaryKey()] = true;
+ $keys = ConfigTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getName(),
+ $keys[2] => $this->getValue(),
+ $keys[3] => $this->getSecured(),
+ $keys[4] => $this->getHidden(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collConfigI18ns) {
+ $result['ConfigI18ns'] = $this->collConfigI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ConfigTableMap::translateFieldName($name, $type, TableMap::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->setName($value);
+ break;
+ case 2:
+ $this->setValue($value);
+ break;
+ case 3:
+ $this->setSecured($value);
+ break;
+ case 4:
+ $this->setHidden($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ConfigTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setValue($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setSecured($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setHidden($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * 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(ConfigTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ConfigTableMap::ID)) $criteria->add(ConfigTableMap::ID, $this->id);
+ if ($this->isColumnModified(ConfigTableMap::NAME)) $criteria->add(ConfigTableMap::NAME, $this->name);
+ if ($this->isColumnModified(ConfigTableMap::VALUE)) $criteria->add(ConfigTableMap::VALUE, $this->value);
+ if ($this->isColumnModified(ConfigTableMap::SECURED)) $criteria->add(ConfigTableMap::SECURED, $this->secured);
+ if ($this->isColumnModified(ConfigTableMap::HIDDEN)) $criteria->add(ConfigTableMap::HIDDEN, $this->hidden);
+ if ($this->isColumnModified(ConfigTableMap::CREATED_AT)) $criteria->add(ConfigTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ConfigTableMap::UPDATED_AT)) $criteria->add(ConfigTableMap::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(ConfigTableMap::DATABASE_NAME);
+ $criteria->add(ConfigTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Config (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setName($this->getName());
+ $copyObj->setValue($this->getValue());
+ $copyObj->setSecured($this->getSecured());
+ $copyObj->setHidden($this->getHidden());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getConfigI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addConfigI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Config 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('ConfigI18n' == $relationName) {
+ return $this->initConfigI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collConfigI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addConfigI18ns()
+ */
+ public function clearConfigI18ns()
+ {
+ $this->collConfigI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collConfigI18ns collection loaded partially.
+ */
+ public function resetPartialConfigI18ns($v = true)
+ {
+ $this->collConfigI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collConfigI18ns collection.
+ *
+ * By default this just sets the collConfigI18ns collection to an empty array (like clearcollConfigI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initConfigI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collConfigI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collConfigI18ns = new ObjectCollection();
+ $this->collConfigI18ns->setModel('\Thelia\Model\ConfigI18n');
+ }
+
+ /**
+ * Gets an array of ChildConfigI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildConfig is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildConfigI18n[] List of ChildConfigI18n objects
+ * @throws PropelException
+ */
+ public function getConfigI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collConfigI18nsPartial && !$this->isNew();
+ if (null === $this->collConfigI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collConfigI18ns) {
+ // return empty collection
+ $this->initConfigI18ns();
+ } else {
+ $collConfigI18ns = ChildConfigI18nQuery::create(null, $criteria)
+ ->filterByConfig($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collConfigI18nsPartial && count($collConfigI18ns)) {
+ $this->initConfigI18ns(false);
+
+ foreach ($collConfigI18ns as $obj) {
+ if (false == $this->collConfigI18ns->contains($obj)) {
+ $this->collConfigI18ns->append($obj);
+ }
+ }
+
+ $this->collConfigI18nsPartial = true;
+ }
+
+ $collConfigI18ns->getInternalIterator()->rewind();
+
+ return $collConfigI18ns;
+ }
+
+ if ($partial && $this->collConfigI18ns) {
+ foreach ($this->collConfigI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collConfigI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collConfigI18ns = $collConfigI18ns;
+ $this->collConfigI18nsPartial = false;
+ }
+ }
+
+ return $this->collConfigI18ns;
+ }
+
+ /**
+ * Sets a collection of ConfigI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $configI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildConfig The current object (for fluent API support)
+ */
+ public function setConfigI18ns(Collection $configI18ns, ConnectionInterface $con = null)
+ {
+ $configI18nsToDelete = $this->getConfigI18ns(new Criteria(), $con)->diff($configI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->configI18nsScheduledForDeletion = clone $configI18nsToDelete;
+
+ foreach ($configI18nsToDelete as $configI18nRemoved) {
+ $configI18nRemoved->setConfig(null);
+ }
+
+ $this->collConfigI18ns = null;
+ foreach ($configI18ns as $configI18n) {
+ $this->addConfigI18n($configI18n);
+ }
+
+ $this->collConfigI18ns = $configI18ns;
+ $this->collConfigI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ConfigI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ConfigI18n objects.
+ * @throws PropelException
+ */
+ public function countConfigI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collConfigI18nsPartial && !$this->isNew();
+ if (null === $this->collConfigI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collConfigI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getConfigI18ns());
+ }
+
+ $query = ChildConfigI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByConfig($this)
+ ->count($con);
+ }
+
+ return count($this->collConfigI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildConfigI18n object to this object
+ * through the ChildConfigI18n foreign key attribute.
+ *
+ * @param ChildConfigI18n $l ChildConfigI18n
+ * @return \Thelia\Model\Config The current object (for fluent API support)
+ */
+ public function addConfigI18n(ChildConfigI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collConfigI18ns === null) {
+ $this->initConfigI18ns();
+ $this->collConfigI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collConfigI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddConfigI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ConfigI18n $configI18n The configI18n object to add.
+ */
+ protected function doAddConfigI18n($configI18n)
+ {
+ $this->collConfigI18ns[]= $configI18n;
+ $configI18n->setConfig($this);
+ }
+
+ /**
+ * @param ConfigI18n $configI18n The configI18n object to remove.
+ * @return ChildConfig The current object (for fluent API support)
+ */
+ public function removeConfigI18n($configI18n)
+ {
+ if ($this->getConfigI18ns()->contains($configI18n)) {
+ $this->collConfigI18ns->remove($this->collConfigI18ns->search($configI18n));
+ if (null === $this->configI18nsScheduledForDeletion) {
+ $this->configI18nsScheduledForDeletion = clone $this->collConfigI18ns;
+ $this->configI18nsScheduledForDeletion->clear();
+ }
+ $this->configI18nsScheduledForDeletion[]= clone $configI18n;
+ $configI18n->setConfig(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->name = null;
+ $this->value = null;
+ $this->secured = null;
+ $this->hidden = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collConfigI18ns) {
+ foreach ($this->collConfigI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collConfigI18ns instanceof Collection) {
+ $this->collConfigI18ns->clearIterator();
+ }
+ $this->collConfigI18ns = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ConfigTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildConfig The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = ConfigTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildConfig The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildConfigI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collConfigI18ns) {
+ foreach ($this->collConfigI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildConfigI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildConfigI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addConfigI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildConfig The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildConfigI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collConfigI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collConfigI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildConfigI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ConfigI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ConfigI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ConfigI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ConfigI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ConfigI18n.php b/core/lib/Thelia/Model/Base/ConfigI18n.php
new file mode 100644
index 000000000..e73e27514
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ConfigI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\ConfigI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another ConfigI18n instance. If
+ * obj is an instance of ConfigI18n, delegates to
+ * equals(ConfigI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return ConfigI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return ConfigI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ConfigI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ConfigI18nTableMap::ID;
+ }
+
+ if ($this->aConfig !== null && $this->aConfig->getId() !== $v) {
+ $this->aConfig = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ConfigI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = ConfigI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ConfigI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = ConfigI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ConfigI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = ConfigI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ConfigI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = ConfigI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ConfigI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = ConfigI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ConfigI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ConfigI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ConfigI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ConfigI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ConfigI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ConfigI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = ConfigI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\ConfigI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aConfig !== null && $this->id !== $this->aConfig->getId()) {
+ $this->aConfig = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ConfigI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildConfigI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aConfig = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see ConfigI18n::setDeleted()
+ * @see ConfigI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ConfigI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildConfigI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ConfigI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ConfigI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aConfig !== null) {
+ if ($this->aConfig->isModified() || $this->aConfig->isNew()) {
+ $affectedRows += $this->aConfig->save($con);
+ }
+ $this->setConfig($this->aConfig);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ConfigI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ConfigI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(ConfigI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(ConfigI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(ConfigI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(ConfigI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO config_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ConfigI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ConfigI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ConfigI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = ConfigI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aConfig) {
+ $result['Config'] = $this->aConfig->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ConfigI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ConfigI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(ConfigI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ConfigI18nTableMap::ID)) $criteria->add(ConfigI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(ConfigI18nTableMap::LOCALE)) $criteria->add(ConfigI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(ConfigI18nTableMap::TITLE)) $criteria->add(ConfigI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(ConfigI18nTableMap::DESCRIPTION)) $criteria->add(ConfigI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(ConfigI18nTableMap::CHAPO)) $criteria->add(ConfigI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(ConfigI18nTableMap::POSTSCRIPTUM)) $criteria->add(ConfigI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(ConfigI18nTableMap::DATABASE_NAME);
+ $criteria->add(ConfigI18nTableMap::ID, $this->id);
+ $criteria->add(ConfigI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\ConfigI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\ConfigI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildConfig object.
+ *
+ * @param ChildConfig $v
+ * @return \Thelia\Model\ConfigI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setConfig(ChildConfig $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aConfig = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildConfig object, it will not be re-added.
+ if ($v !== null) {
+ $v->addConfigI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildConfig object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildConfig The associated ChildConfig object.
+ * @throws PropelException
+ */
+ public function getConfig(ConnectionInterface $con = null)
+ {
+ if ($this->aConfig === null && ($this->id !== null)) {
+ $this->aConfig = ChildConfigQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aConfig->addConfigI18ns($this);
+ */
+ }
+
+ return $this->aConfig;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aConfig = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ConfigI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ConfigI18nQuery.php b/core/lib/Thelia/Model/Base/ConfigI18nQuery.php
new file mode 100644
index 000000000..bc231b05c
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ConfigI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildConfigI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ConfigI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ConfigI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildConfigI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM config_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildConfigI18n();
+ $obj->hydrate($row);
+ ConfigI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildConfigI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildConfigI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(ConfigI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(ConfigI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildConfigI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(ConfigI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(ConfigI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByConfig()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ConfigI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ConfigI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Config object
+ *
+ * @param \Thelia\Model\Config|ObjectCollection $config The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigI18nQuery The current query, for fluid interface
+ */
+ public function filterByConfig($config, $comparison = null)
+ {
+ if ($config instanceof \Thelia\Model\Config) {
+ return $this
+ ->addUsingAlias(ConfigI18nTableMap::ID, $config->getId(), $comparison);
+ } elseif ($config instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ConfigI18nTableMap::ID, $config->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByConfig() only accepts arguments of type \Thelia\Model\Config or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Config relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildConfigI18nQuery The current query, for fluid interface
+ */
+ public function joinConfig($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Config');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Config');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Config relation Config object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ConfigQuery A secondary query class using the current class as primary query
+ */
+ public function useConfigQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinConfig($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Config', '\Thelia\Model\ConfigQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildConfigI18n $configI18n Object to remove from the list of results
+ *
+ * @return ChildConfigI18nQuery The current query, for fluid interface
+ */
+ public function prune($configI18n = null)
+ {
+ if ($configI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(ConfigI18nTableMap::ID), $configI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(ConfigI18nTableMap::LOCALE), $configI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the config_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ConfigI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ConfigI18nTableMap::clearInstancePool();
+ ConfigI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildConfigI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildConfigI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ConfigI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ConfigI18nTableMap::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->beginTransaction();
+
+
+ ConfigI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ConfigI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // ConfigI18nQuery
diff --git a/core/lib/Thelia/Model/Base/ConfigQuery.php b/core/lib/Thelia/Model/Base/ConfigQuery.php
new file mode 100644
index 000000000..b2ddc3409
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ConfigQuery.php
@@ -0,0 +1,798 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildConfig|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ConfigTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ConfigTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildConfig A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, NAME, VALUE, SECURED, HIDDEN, CREATED_AT, UPDATED_AT FROM config WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildConfig();
+ $obj->hydrate($row);
+ ConfigTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildConfig|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ConfigTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ConfigTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ConfigTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ConfigTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the name column
+ *
+ * Example usage:
+ *
+ * $query->filterByName('fooValue'); // WHERE name = 'fooValue'
+ * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
+ *
+ *
+ * @param string $name The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function filterByName($name = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($name)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $name)) {
+ $name = str_replace('*', '%', $name);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigTableMap::NAME, $name, $comparison);
+ }
+
+ /**
+ * Filter the query on the value column
+ *
+ * Example usage:
+ *
+ * $query->filterByValue('fooValue'); // WHERE value = 'fooValue'
+ * $query->filterByValue('%fooValue%'); // WHERE value LIKE '%fooValue%'
+ *
+ *
+ * @param string $value The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function filterByValue($value = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($value)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $value)) {
+ $value = str_replace('*', '%', $value);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigTableMap::VALUE, $value, $comparison);
+ }
+
+ /**
+ * Filter the query on the secured column
+ *
+ * Example usage:
+ *
+ * $query->filterBySecured(1234); // WHERE secured = 1234
+ * $query->filterBySecured(array(12, 34)); // WHERE secured IN (12, 34)
+ * $query->filterBySecured(array('min' => 12)); // WHERE secured > 12
+ *
+ *
+ * @param mixed $secured The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function filterBySecured($secured = null, $comparison = null)
+ {
+ if (is_array($secured)) {
+ $useMinMax = false;
+ if (isset($secured['min'])) {
+ $this->addUsingAlias(ConfigTableMap::SECURED, $secured['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($secured['max'])) {
+ $this->addUsingAlias(ConfigTableMap::SECURED, $secured['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigTableMap::SECURED, $secured, $comparison);
+ }
+
+ /**
+ * Filter the query on the hidden column
+ *
+ * Example usage:
+ *
+ * $query->filterByHidden(1234); // WHERE hidden = 1234
+ * $query->filterByHidden(array(12, 34)); // WHERE hidden IN (12, 34)
+ * $query->filterByHidden(array('min' => 12)); // WHERE hidden > 12
+ *
+ *
+ * @param mixed $hidden The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function filterByHidden($hidden = null, $comparison = null)
+ {
+ if (is_array($hidden)) {
+ $useMinMax = false;
+ if (isset($hidden['min'])) {
+ $this->addUsingAlias(ConfigTableMap::HIDDEN, $hidden['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($hidden['max'])) {
+ $this->addUsingAlias(ConfigTableMap::HIDDEN, $hidden['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigTableMap::HIDDEN, $hidden, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ConfigTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ConfigTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ConfigTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ConfigTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ConfigTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ConfigI18n object
+ *
+ * @param \Thelia\Model\ConfigI18n|ObjectCollection $configI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function filterByConfigI18n($configI18n, $comparison = null)
+ {
+ if ($configI18n instanceof \Thelia\Model\ConfigI18n) {
+ return $this
+ ->addUsingAlias(ConfigTableMap::ID, $configI18n->getId(), $comparison);
+ } elseif ($configI18n instanceof ObjectCollection) {
+ return $this
+ ->useConfigI18nQuery()
+ ->filterByPrimaryKeys($configI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByConfigI18n() only accepts arguments of type \Thelia\Model\ConfigI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ConfigI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function joinConfigI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ConfigI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ConfigI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ConfigI18n relation ConfigI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ConfigI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useConfigI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinConfigI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ConfigI18n', '\Thelia\Model\ConfigI18nQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildConfig $config Object to remove from the list of results
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function prune($config = null)
+ {
+ if ($config) {
+ $this->addUsingAlias(ConfigTableMap::ID, $config->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the config table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ConfigTableMap::clearInstancePool();
+ ConfigTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildConfig or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildConfig object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ConfigTableMap::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->beginTransaction();
+
+
+ ConfigTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ConfigTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ConfigTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ConfigTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ConfigTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ConfigTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ConfigTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ConfigTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'ConfigI18n';
+
+ return $this
+ ->joinConfigI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildConfigQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('ConfigI18n');
+ $this->with['ConfigI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildConfigI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ConfigI18n', '\Thelia\Model\ConfigI18nQuery');
+ }
+
+} // ConfigQuery
diff --git a/core/lib/Thelia/Model/Base/Content.php b/core/lib/Thelia/Model/Base/Content.php
new file mode 100644
index 000000000..eec31f072
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Content.php
@@ -0,0 +1,4529 @@
+version = 0;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\Content object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Content instance. If
+ * obj is an instance of Content, delegates to
+ * equals(Content). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Content The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Content The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [visible] column value.
+ *
+ * @return int
+ */
+ public function getVisible()
+ {
+
+ return $this->visible;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getVersionCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->version_created_at;
+ } else {
+ return $this->version_created_at !== null ? $this->version_created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ContentTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function setVisible($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->visible !== $v) {
+ $this->visible = $v;
+ $this->modifiedColumns[] = ContentTableMap::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = ContentTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = ContentTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = ContentTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = ContentTableMap::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ if ($dt !== $this->version_created_at) {
+ $this->version_created_at = $dt;
+ $this->modifiedColumns[] = ContentTableMap::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = ContentTableMap::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->version !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->visible = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ContentTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ContentTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ContentTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version_created_by = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = ContentTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Content object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ContentTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildContentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collContentAssocs = null;
+
+ $this->collImages = null;
+
+ $this->collDocuments = null;
+
+ $this->collRewritings = null;
+
+ $this->collContentFolders = null;
+
+ $this->collContentI18ns = null;
+
+ $this->collContentVersions = null;
+
+ $this->collFolders = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Content::setDeleted()
+ * @see Content::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildContentQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ // versionable behavior
+ if ($this->isVersioningNecessary()) {
+ $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
+ if (!$this->isColumnModified(ContentTableMap::VERSION_CREATED_AT)) {
+ $this->setVersionCreatedAt(time());
+ }
+ $createVersion = true; // for postSave hook
+ }
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(ContentTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(ContentTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(ContentTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ // versionable behavior
+ if (isset($createVersion)) {
+ $this->addVersion($con);
+ }
+ ContentTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->foldersScheduledForDeletion !== null) {
+ if (!$this->foldersScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->foldersScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($pk, $remotePk);
+ }
+
+ ContentFolderQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->foldersScheduledForDeletion = null;
+ }
+
+ foreach ($this->getFolders() as $folder) {
+ if ($folder->isModified()) {
+ $folder->save($con);
+ }
+ }
+ } elseif ($this->collFolders) {
+ foreach ($this->collFolders as $folder) {
+ if ($folder->isModified()) {
+ $folder->save($con);
+ }
+ }
+ }
+
+ if ($this->contentAssocsScheduledForDeletion !== null) {
+ if (!$this->contentAssocsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ContentAssocQuery::create()
+ ->filterByPrimaryKeys($this->contentAssocsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->contentAssocsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collContentAssocs !== null) {
+ foreach ($this->collContentAssocs as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->imagesScheduledForDeletion !== null) {
+ if (!$this->imagesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ImageQuery::create()
+ ->filterByPrimaryKeys($this->imagesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->imagesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collImages !== null) {
+ foreach ($this->collImages as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->documentsScheduledForDeletion !== null) {
+ if (!$this->documentsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\DocumentQuery::create()
+ ->filterByPrimaryKeys($this->documentsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->documentsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collDocuments !== null) {
+ foreach ($this->collDocuments as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->rewritingsScheduledForDeletion !== null) {
+ if (!$this->rewritingsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\RewritingQuery::create()
+ ->filterByPrimaryKeys($this->rewritingsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->rewritingsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collRewritings !== null) {
+ foreach ($this->collRewritings as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->contentFoldersScheduledForDeletion !== null) {
+ if (!$this->contentFoldersScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ContentFolderQuery::create()
+ ->filterByPrimaryKeys($this->contentFoldersScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->contentFoldersScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collContentFolders !== null) {
+ foreach ($this->collContentFolders as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->contentI18nsScheduledForDeletion !== null) {
+ if (!$this->contentI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ContentI18nQuery::create()
+ ->filterByPrimaryKeys($this->contentI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->contentI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collContentI18ns !== null) {
+ foreach ($this->collContentI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->contentVersionsScheduledForDeletion !== null) {
+ if (!$this->contentVersionsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ContentVersionQuery::create()
+ ->filterByPrimaryKeys($this->contentVersionsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->contentVersionsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collContentVersions !== null) {
+ foreach ($this->collContentVersions as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ContentTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ContentTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ContentTableMap::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = 'VISIBLE';
+ }
+ if ($this->isColumnModified(ContentTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(ContentTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(ContentTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+ if ($this->isColumnModified(ContentTableMap::VERSION)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION';
+ }
+ if ($this->isColumnModified(ContentTableMap::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT';
+ }
+ if ($this->isColumnModified(ContentTableMap::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO content (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'VISIBLE':
+ $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case 'VERSION_CREATED_AT':
+ $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION_CREATED_BY':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ContentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getVisible();
+ break;
+ case 2:
+ return $this->getPosition();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ return $this->getUpdatedAt();
+ break;
+ case 5:
+ return $this->getVersion();
+ break;
+ case 6:
+ return $this->getVersionCreatedAt();
+ break;
+ case 7:
+ return $this->getVersionCreatedBy();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Content'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Content'][$this->getPrimaryKey()] = true;
+ $keys = ContentTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getVisible(),
+ $keys[2] => $this->getPosition(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ $keys[5] => $this->getVersion(),
+ $keys[6] => $this->getVersionCreatedAt(),
+ $keys[7] => $this->getVersionCreatedBy(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collContentAssocs) {
+ $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collImages) {
+ $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collDocuments) {
+ $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collRewritings) {
+ $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collContentFolders) {
+ $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collContentI18ns) {
+ $result['ContentI18ns'] = $this->collContentI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collContentVersions) {
+ $result['ContentVersions'] = $this->collContentVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ContentTableMap::translateFieldName($name, $type, TableMap::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->setVisible($value);
+ break;
+ case 2:
+ $this->setPosition($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $this->setUpdatedAt($value);
+ break;
+ case 5:
+ $this->setVersion($value);
+ break;
+ case 6:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 7:
+ $this->setVersionCreatedBy($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ContentTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setVisible($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setVersion($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setVersionCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersionCreatedBy($arr[$keys[7]]);
+ }
+
+ /**
+ * 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(ContentTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ContentTableMap::ID)) $criteria->add(ContentTableMap::ID, $this->id);
+ if ($this->isColumnModified(ContentTableMap::VISIBLE)) $criteria->add(ContentTableMap::VISIBLE, $this->visible);
+ if ($this->isColumnModified(ContentTableMap::POSITION)) $criteria->add(ContentTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(ContentTableMap::CREATED_AT)) $criteria->add(ContentTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ContentTableMap::UPDATED_AT)) $criteria->add(ContentTableMap::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(ContentTableMap::VERSION)) $criteria->add(ContentTableMap::VERSION, $this->version);
+ if ($this->isColumnModified(ContentTableMap::VERSION_CREATED_AT)) $criteria->add(ContentTableMap::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(ContentTableMap::VERSION_CREATED_BY)) $criteria->add(ContentTableMap::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(ContentTableMap::DATABASE_NAME);
+ $criteria->add(ContentTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Content (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+
+ 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->getContentAssocs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addContentAssoc($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getImages() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addImage($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getDocuments() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addDocument($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getRewritings() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addRewriting($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getContentFolders() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addContentFolder($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getContentI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addContentI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getContentVersions() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addContentVersion($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Content 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('ContentAssoc' == $relationName) {
+ return $this->initContentAssocs();
+ }
+ if ('Image' == $relationName) {
+ return $this->initImages();
+ }
+ if ('Document' == $relationName) {
+ return $this->initDocuments();
+ }
+ if ('Rewriting' == $relationName) {
+ return $this->initRewritings();
+ }
+ if ('ContentFolder' == $relationName) {
+ return $this->initContentFolders();
+ }
+ if ('ContentI18n' == $relationName) {
+ return $this->initContentI18ns();
+ }
+ if ('ContentVersion' == $relationName) {
+ return $this->initContentVersions();
+ }
+ }
+
+ /**
+ * Clears out the collContentAssocs collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addContentAssocs()
+ */
+ public function clearContentAssocs()
+ {
+ $this->collContentAssocs = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collContentAssocs collection loaded partially.
+ */
+ public function resetPartialContentAssocs($v = true)
+ {
+ $this->collContentAssocsPartial = $v;
+ }
+
+ /**
+ * Initializes the collContentAssocs collection.
+ *
+ * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initContentAssocs($overrideExisting = true)
+ {
+ if (null !== $this->collContentAssocs && !$overrideExisting) {
+ return;
+ }
+ $this->collContentAssocs = new ObjectCollection();
+ $this->collContentAssocs->setModel('\Thelia\Model\ContentAssoc');
+ }
+
+ /**
+ * Gets an array of ChildContentAssoc objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildContent is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects
+ * @throws PropelException
+ */
+ public function getContentAssocs($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collContentAssocsPartial && !$this->isNew();
+ if (null === $this->collContentAssocs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentAssocs) {
+ // return empty collection
+ $this->initContentAssocs();
+ } else {
+ $collContentAssocs = ChildContentAssocQuery::create(null, $criteria)
+ ->filterByContent($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) {
+ $this->initContentAssocs(false);
+
+ foreach ($collContentAssocs as $obj) {
+ if (false == $this->collContentAssocs->contains($obj)) {
+ $this->collContentAssocs->append($obj);
+ }
+ }
+
+ $this->collContentAssocsPartial = true;
+ }
+
+ $collContentAssocs->getInternalIterator()->rewind();
+
+ return $collContentAssocs;
+ }
+
+ if ($partial && $this->collContentAssocs) {
+ foreach ($this->collContentAssocs as $obj) {
+ if ($obj->isNew()) {
+ $collContentAssocs[] = $obj;
+ }
+ }
+ }
+
+ $this->collContentAssocs = $collContentAssocs;
+ $this->collContentAssocsPartial = false;
+ }
+ }
+
+ return $this->collContentAssocs;
+ }
+
+ /**
+ * Sets a collection of ContentAssoc objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $contentAssocs A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function setContentAssocs(Collection $contentAssocs, ConnectionInterface $con = null)
+ {
+ $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs);
+
+
+ $this->contentAssocsScheduledForDeletion = $contentAssocsToDelete;
+
+ foreach ($contentAssocsToDelete as $contentAssocRemoved) {
+ $contentAssocRemoved->setContent(null);
+ }
+
+ $this->collContentAssocs = null;
+ foreach ($contentAssocs as $contentAssoc) {
+ $this->addContentAssoc($contentAssoc);
+ }
+
+ $this->collContentAssocs = $contentAssocs;
+ $this->collContentAssocsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ContentAssoc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ContentAssoc objects.
+ * @throws PropelException
+ */
+ public function countContentAssocs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collContentAssocsPartial && !$this->isNew();
+ if (null === $this->collContentAssocs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentAssocs) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getContentAssocs());
+ }
+
+ $query = ChildContentAssocQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByContent($this)
+ ->count($con);
+ }
+
+ return count($this->collContentAssocs);
+ }
+
+ /**
+ * Method called to associate a ChildContentAssoc object to this object
+ * through the ChildContentAssoc foreign key attribute.
+ *
+ * @param ChildContentAssoc $l ChildContentAssoc
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function addContentAssoc(ChildContentAssoc $l)
+ {
+ if ($this->collContentAssocs === null) {
+ $this->initContentAssocs();
+ $this->collContentAssocsPartial = true;
+ }
+
+ if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddContentAssoc($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ContentAssoc $contentAssoc The contentAssoc object to add.
+ */
+ protected function doAddContentAssoc($contentAssoc)
+ {
+ $this->collContentAssocs[]= $contentAssoc;
+ $contentAssoc->setContent($this);
+ }
+
+ /**
+ * @param ContentAssoc $contentAssoc The contentAssoc object to remove.
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function removeContentAssoc($contentAssoc)
+ {
+ if ($this->getContentAssocs()->contains($contentAssoc)) {
+ $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc));
+ if (null === $this->contentAssocsScheduledForDeletion) {
+ $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs;
+ $this->contentAssocsScheduledForDeletion->clear();
+ }
+ $this->contentAssocsScheduledForDeletion[]= $contentAssoc;
+ $contentAssoc->setContent(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related ContentAssocs 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 Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects
+ */
+ public function getContentAssocsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildContentAssocQuery::create(null, $criteria);
+ $query->joinWith('Category', $joinBehavior);
+
+ return $this->getContentAssocs($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related ContentAssocs 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 Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects
+ */
+ public function getContentAssocsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildContentAssocQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getContentAssocs($query, $con);
+ }
+
+ /**
+ * Clears out the collImages collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addImages()
+ */
+ public function clearImages()
+ {
+ $this->collImages = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collImages collection loaded partially.
+ */
+ public function resetPartialImages($v = true)
+ {
+ $this->collImagesPartial = $v;
+ }
+
+ /**
+ * Initializes the collImages collection.
+ *
+ * By default this just sets the collImages collection to an empty array (like clearcollImages());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initImages($overrideExisting = true)
+ {
+ if (null !== $this->collImages && !$overrideExisting) {
+ return;
+ }
+ $this->collImages = new ObjectCollection();
+ $this->collImages->setModel('\Thelia\Model\Image');
+ }
+
+ /**
+ * Gets an array of ChildImage objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildContent is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildImage[] List of ChildImage objects
+ * @throws PropelException
+ */
+ public function getImages($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collImagesPartial && !$this->isNew();
+ if (null === $this->collImages || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collImages) {
+ // return empty collection
+ $this->initImages();
+ } else {
+ $collImages = ChildImageQuery::create(null, $criteria)
+ ->filterByContent($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collImagesPartial && count($collImages)) {
+ $this->initImages(false);
+
+ foreach ($collImages as $obj) {
+ if (false == $this->collImages->contains($obj)) {
+ $this->collImages->append($obj);
+ }
+ }
+
+ $this->collImagesPartial = true;
+ }
+
+ $collImages->getInternalIterator()->rewind();
+
+ return $collImages;
+ }
+
+ if ($partial && $this->collImages) {
+ foreach ($this->collImages as $obj) {
+ if ($obj->isNew()) {
+ $collImages[] = $obj;
+ }
+ }
+ }
+
+ $this->collImages = $collImages;
+ $this->collImagesPartial = false;
+ }
+ }
+
+ return $this->collImages;
+ }
+
+ /**
+ * Sets a collection of Image objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $images A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function setImages(Collection $images, ConnectionInterface $con = null)
+ {
+ $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images);
+
+
+ $this->imagesScheduledForDeletion = $imagesToDelete;
+
+ foreach ($imagesToDelete as $imageRemoved) {
+ $imageRemoved->setContent(null);
+ }
+
+ $this->collImages = null;
+ foreach ($images as $image) {
+ $this->addImage($image);
+ }
+
+ $this->collImages = $images;
+ $this->collImagesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Image objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Image objects.
+ * @throws PropelException
+ */
+ public function countImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collImagesPartial && !$this->isNew();
+ if (null === $this->collImages || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collImages) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getImages());
+ }
+
+ $query = ChildImageQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByContent($this)
+ ->count($con);
+ }
+
+ return count($this->collImages);
+ }
+
+ /**
+ * Method called to associate a ChildImage object to this object
+ * through the ChildImage foreign key attribute.
+ *
+ * @param ChildImage $l ChildImage
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function addImage(ChildImage $l)
+ {
+ if ($this->collImages === null) {
+ $this->initImages();
+ $this->collImagesPartial = true;
+ }
+
+ if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddImage($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Image $image The image object to add.
+ */
+ protected function doAddImage($image)
+ {
+ $this->collImages[]= $image;
+ $image->setContent($this);
+ }
+
+ /**
+ * @param Image $image The image object to remove.
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function removeImage($image)
+ {
+ if ($this->getImages()->contains($image)) {
+ $this->collImages->remove($this->collImages->search($image));
+ if (null === $this->imagesScheduledForDeletion) {
+ $this->imagesScheduledForDeletion = clone $this->collImages;
+ $this->imagesScheduledForDeletion->clear();
+ }
+ $this->imagesScheduledForDeletion[]= $image;
+ $image->setContent(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related Images 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 Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildImage[] List of ChildImage objects
+ */
+ public function getImagesJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildImageQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getImages($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related Images 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 Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildImage[] List of ChildImage objects
+ */
+ public function getImagesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildImageQuery::create(null, $criteria);
+ $query->joinWith('Category', $joinBehavior);
+
+ return $this->getImages($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related Images 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 Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildImage[] List of ChildImage objects
+ */
+ public function getImagesJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildImageQuery::create(null, $criteria);
+ $query->joinWith('Folder', $joinBehavior);
+
+ return $this->getImages($query, $con);
+ }
+
+ /**
+ * Clears out the collDocuments collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addDocuments()
+ */
+ public function clearDocuments()
+ {
+ $this->collDocuments = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collDocuments collection loaded partially.
+ */
+ public function resetPartialDocuments($v = true)
+ {
+ $this->collDocumentsPartial = $v;
+ }
+
+ /**
+ * Initializes the collDocuments collection.
+ *
+ * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initDocuments($overrideExisting = true)
+ {
+ if (null !== $this->collDocuments && !$overrideExisting) {
+ return;
+ }
+ $this->collDocuments = new ObjectCollection();
+ $this->collDocuments->setModel('\Thelia\Model\Document');
+ }
+
+ /**
+ * Gets an array of ChildDocument objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildContent is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ * @throws PropelException
+ */
+ public function getDocuments($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collDocumentsPartial && !$this->isNew();
+ if (null === $this->collDocuments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocuments) {
+ // return empty collection
+ $this->initDocuments();
+ } else {
+ $collDocuments = ChildDocumentQuery::create(null, $criteria)
+ ->filterByContent($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collDocumentsPartial && count($collDocuments)) {
+ $this->initDocuments(false);
+
+ foreach ($collDocuments as $obj) {
+ if (false == $this->collDocuments->contains($obj)) {
+ $this->collDocuments->append($obj);
+ }
+ }
+
+ $this->collDocumentsPartial = true;
+ }
+
+ $collDocuments->getInternalIterator()->rewind();
+
+ return $collDocuments;
+ }
+
+ if ($partial && $this->collDocuments) {
+ foreach ($this->collDocuments as $obj) {
+ if ($obj->isNew()) {
+ $collDocuments[] = $obj;
+ }
+ }
+ }
+
+ $this->collDocuments = $collDocuments;
+ $this->collDocumentsPartial = false;
+ }
+ }
+
+ return $this->collDocuments;
+ }
+
+ /**
+ * Sets a collection of Document objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $documents A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function setDocuments(Collection $documents, ConnectionInterface $con = null)
+ {
+ $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents);
+
+
+ $this->documentsScheduledForDeletion = $documentsToDelete;
+
+ foreach ($documentsToDelete as $documentRemoved) {
+ $documentRemoved->setContent(null);
+ }
+
+ $this->collDocuments = null;
+ foreach ($documents as $document) {
+ $this->addDocument($document);
+ }
+
+ $this->collDocuments = $documents;
+ $this->collDocumentsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Document objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Document objects.
+ * @throws PropelException
+ */
+ public function countDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collDocumentsPartial && !$this->isNew();
+ if (null === $this->collDocuments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocuments) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getDocuments());
+ }
+
+ $query = ChildDocumentQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByContent($this)
+ ->count($con);
+ }
+
+ return count($this->collDocuments);
+ }
+
+ /**
+ * Method called to associate a ChildDocument object to this object
+ * through the ChildDocument foreign key attribute.
+ *
+ * @param ChildDocument $l ChildDocument
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function addDocument(ChildDocument $l)
+ {
+ if ($this->collDocuments === null) {
+ $this->initDocuments();
+ $this->collDocumentsPartial = true;
+ }
+
+ if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddDocument($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Document $document The document object to add.
+ */
+ protected function doAddDocument($document)
+ {
+ $this->collDocuments[]= $document;
+ $document->setContent($this);
+ }
+
+ /**
+ * @param Document $document The document object to remove.
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function removeDocument($document)
+ {
+ if ($this->getDocuments()->contains($document)) {
+ $this->collDocuments->remove($this->collDocuments->search($document));
+ if (null === $this->documentsScheduledForDeletion) {
+ $this->documentsScheduledForDeletion = clone $this->collDocuments;
+ $this->documentsScheduledForDeletion->clear();
+ }
+ $this->documentsScheduledForDeletion[]= $document;
+ $document->setContent(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related Documents 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 Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ */
+ public function getDocumentsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildDocumentQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related Documents 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 Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ */
+ public function getDocumentsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildDocumentQuery::create(null, $criteria);
+ $query->joinWith('Category', $joinBehavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related Documents 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 Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ */
+ public function getDocumentsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildDocumentQuery::create(null, $criteria);
+ $query->joinWith('Folder', $joinBehavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+ /**
+ * Clears out the collRewritings collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addRewritings()
+ */
+ public function clearRewritings()
+ {
+ $this->collRewritings = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collRewritings collection loaded partially.
+ */
+ public function resetPartialRewritings($v = true)
+ {
+ $this->collRewritingsPartial = $v;
+ }
+
+ /**
+ * Initializes the collRewritings collection.
+ *
+ * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initRewritings($overrideExisting = true)
+ {
+ if (null !== $this->collRewritings && !$overrideExisting) {
+ return;
+ }
+ $this->collRewritings = new ObjectCollection();
+ $this->collRewritings->setModel('\Thelia\Model\Rewriting');
+ }
+
+ /**
+ * Gets an array of ChildRewriting objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildContent is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ * @throws PropelException
+ */
+ public function getRewritings($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ // return empty collection
+ $this->initRewritings();
+ } else {
+ $collRewritings = ChildRewritingQuery::create(null, $criteria)
+ ->filterByContent($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collRewritingsPartial && count($collRewritings)) {
+ $this->initRewritings(false);
+
+ foreach ($collRewritings as $obj) {
+ if (false == $this->collRewritings->contains($obj)) {
+ $this->collRewritings->append($obj);
+ }
+ }
+
+ $this->collRewritingsPartial = true;
+ }
+
+ $collRewritings->getInternalIterator()->rewind();
+
+ return $collRewritings;
+ }
+
+ if ($partial && $this->collRewritings) {
+ foreach ($this->collRewritings as $obj) {
+ if ($obj->isNew()) {
+ $collRewritings[] = $obj;
+ }
+ }
+ }
+
+ $this->collRewritings = $collRewritings;
+ $this->collRewritingsPartial = false;
+ }
+ }
+
+ return $this->collRewritings;
+ }
+
+ /**
+ * Sets a collection of Rewriting objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $rewritings A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function setRewritings(Collection $rewritings, ConnectionInterface $con = null)
+ {
+ $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings);
+
+
+ $this->rewritingsScheduledForDeletion = $rewritingsToDelete;
+
+ foreach ($rewritingsToDelete as $rewritingRemoved) {
+ $rewritingRemoved->setContent(null);
+ }
+
+ $this->collRewritings = null;
+ foreach ($rewritings as $rewriting) {
+ $this->addRewriting($rewriting);
+ }
+
+ $this->collRewritings = $rewritings;
+ $this->collRewritingsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Rewriting objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Rewriting objects.
+ * @throws PropelException
+ */
+ public function countRewritings(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getRewritings());
+ }
+
+ $query = ChildRewritingQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByContent($this)
+ ->count($con);
+ }
+
+ return count($this->collRewritings);
+ }
+
+ /**
+ * Method called to associate a ChildRewriting object to this object
+ * through the ChildRewriting foreign key attribute.
+ *
+ * @param ChildRewriting $l ChildRewriting
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function addRewriting(ChildRewriting $l)
+ {
+ if ($this->collRewritings === null) {
+ $this->initRewritings();
+ $this->collRewritingsPartial = true;
+ }
+
+ if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddRewriting($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Rewriting $rewriting The rewriting object to add.
+ */
+ protected function doAddRewriting($rewriting)
+ {
+ $this->collRewritings[]= $rewriting;
+ $rewriting->setContent($this);
+ }
+
+ /**
+ * @param Rewriting $rewriting The rewriting object to remove.
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function removeRewriting($rewriting)
+ {
+ if ($this->getRewritings()->contains($rewriting)) {
+ $this->collRewritings->remove($this->collRewritings->search($rewriting));
+ if (null === $this->rewritingsScheduledForDeletion) {
+ $this->rewritingsScheduledForDeletion = clone $this->collRewritings;
+ $this->rewritingsScheduledForDeletion->clear();
+ }
+ $this->rewritingsScheduledForDeletion[]= $rewriting;
+ $rewriting->setContent(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related Rewritings 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 Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ */
+ public function getRewritingsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildRewritingQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getRewritings($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related Rewritings 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 Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ */
+ public function getRewritingsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildRewritingQuery::create(null, $criteria);
+ $query->joinWith('Category', $joinBehavior);
+
+ return $this->getRewritings($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related Rewritings 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 Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ */
+ public function getRewritingsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildRewritingQuery::create(null, $criteria);
+ $query->joinWith('Folder', $joinBehavior);
+
+ return $this->getRewritings($query, $con);
+ }
+
+ /**
+ * Clears out the collContentFolders collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addContentFolders()
+ */
+ public function clearContentFolders()
+ {
+ $this->collContentFolders = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collContentFolders collection loaded partially.
+ */
+ public function resetPartialContentFolders($v = true)
+ {
+ $this->collContentFoldersPartial = $v;
+ }
+
+ /**
+ * Initializes the collContentFolders collection.
+ *
+ * By default this just sets the collContentFolders collection to an empty array (like clearcollContentFolders());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initContentFolders($overrideExisting = true)
+ {
+ if (null !== $this->collContentFolders && !$overrideExisting) {
+ return;
+ }
+ $this->collContentFolders = new ObjectCollection();
+ $this->collContentFolders->setModel('\Thelia\Model\ContentFolder');
+ }
+
+ /**
+ * Gets an array of ChildContentFolder objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildContent is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildContentFolder[] List of ChildContentFolder objects
+ * @throws PropelException
+ */
+ public function getContentFolders($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collContentFoldersPartial && !$this->isNew();
+ if (null === $this->collContentFolders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentFolders) {
+ // return empty collection
+ $this->initContentFolders();
+ } else {
+ $collContentFolders = ChildContentFolderQuery::create(null, $criteria)
+ ->filterByContent($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collContentFoldersPartial && count($collContentFolders)) {
+ $this->initContentFolders(false);
+
+ foreach ($collContentFolders as $obj) {
+ if (false == $this->collContentFolders->contains($obj)) {
+ $this->collContentFolders->append($obj);
+ }
+ }
+
+ $this->collContentFoldersPartial = true;
+ }
+
+ $collContentFolders->getInternalIterator()->rewind();
+
+ return $collContentFolders;
+ }
+
+ if ($partial && $this->collContentFolders) {
+ foreach ($this->collContentFolders as $obj) {
+ if ($obj->isNew()) {
+ $collContentFolders[] = $obj;
+ }
+ }
+ }
+
+ $this->collContentFolders = $collContentFolders;
+ $this->collContentFoldersPartial = false;
+ }
+ }
+
+ return $this->collContentFolders;
+ }
+
+ /**
+ * Sets a collection of ContentFolder objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $contentFolders A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function setContentFolders(Collection $contentFolders, ConnectionInterface $con = null)
+ {
+ $contentFoldersToDelete = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->contentFoldersScheduledForDeletion = clone $contentFoldersToDelete;
+
+ foreach ($contentFoldersToDelete as $contentFolderRemoved) {
+ $contentFolderRemoved->setContent(null);
+ }
+
+ $this->collContentFolders = null;
+ foreach ($contentFolders as $contentFolder) {
+ $this->addContentFolder($contentFolder);
+ }
+
+ $this->collContentFolders = $contentFolders;
+ $this->collContentFoldersPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ContentFolder objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ContentFolder objects.
+ * @throws PropelException
+ */
+ public function countContentFolders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collContentFoldersPartial && !$this->isNew();
+ if (null === $this->collContentFolders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentFolders) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getContentFolders());
+ }
+
+ $query = ChildContentFolderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByContent($this)
+ ->count($con);
+ }
+
+ return count($this->collContentFolders);
+ }
+
+ /**
+ * Method called to associate a ChildContentFolder object to this object
+ * through the ChildContentFolder foreign key attribute.
+ *
+ * @param ChildContentFolder $l ChildContentFolder
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function addContentFolder(ChildContentFolder $l)
+ {
+ if ($this->collContentFolders === null) {
+ $this->initContentFolders();
+ $this->collContentFoldersPartial = true;
+ }
+
+ if (!in_array($l, $this->collContentFolders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddContentFolder($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ContentFolder $contentFolder The contentFolder object to add.
+ */
+ protected function doAddContentFolder($contentFolder)
+ {
+ $this->collContentFolders[]= $contentFolder;
+ $contentFolder->setContent($this);
+ }
+
+ /**
+ * @param ContentFolder $contentFolder The contentFolder object to remove.
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function removeContentFolder($contentFolder)
+ {
+ if ($this->getContentFolders()->contains($contentFolder)) {
+ $this->collContentFolders->remove($this->collContentFolders->search($contentFolder));
+ if (null === $this->contentFoldersScheduledForDeletion) {
+ $this->contentFoldersScheduledForDeletion = clone $this->collContentFolders;
+ $this->contentFoldersScheduledForDeletion->clear();
+ }
+ $this->contentFoldersScheduledForDeletion[]= clone $contentFolder;
+ $contentFolder->setContent(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Content is new, it will return
+ * an empty collection; or if this Content has previously
+ * been saved, it will retrieve related ContentFolders 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 Content.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildContentFolder[] List of ChildContentFolder objects
+ */
+ public function getContentFoldersJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildContentFolderQuery::create(null, $criteria);
+ $query->joinWith('Folder', $joinBehavior);
+
+ return $this->getContentFolders($query, $con);
+ }
+
+ /**
+ * Clears out the collContentI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addContentI18ns()
+ */
+ public function clearContentI18ns()
+ {
+ $this->collContentI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collContentI18ns collection loaded partially.
+ */
+ public function resetPartialContentI18ns($v = true)
+ {
+ $this->collContentI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collContentI18ns collection.
+ *
+ * By default this just sets the collContentI18ns collection to an empty array (like clearcollContentI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initContentI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collContentI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collContentI18ns = new ObjectCollection();
+ $this->collContentI18ns->setModel('\Thelia\Model\ContentI18n');
+ }
+
+ /**
+ * Gets an array of ChildContentI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildContent is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildContentI18n[] List of ChildContentI18n objects
+ * @throws PropelException
+ */
+ public function getContentI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collContentI18nsPartial && !$this->isNew();
+ if (null === $this->collContentI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentI18ns) {
+ // return empty collection
+ $this->initContentI18ns();
+ } else {
+ $collContentI18ns = ChildContentI18nQuery::create(null, $criteria)
+ ->filterByContent($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collContentI18nsPartial && count($collContentI18ns)) {
+ $this->initContentI18ns(false);
+
+ foreach ($collContentI18ns as $obj) {
+ if (false == $this->collContentI18ns->contains($obj)) {
+ $this->collContentI18ns->append($obj);
+ }
+ }
+
+ $this->collContentI18nsPartial = true;
+ }
+
+ $collContentI18ns->getInternalIterator()->rewind();
+
+ return $collContentI18ns;
+ }
+
+ if ($partial && $this->collContentI18ns) {
+ foreach ($this->collContentI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collContentI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collContentI18ns = $collContentI18ns;
+ $this->collContentI18nsPartial = false;
+ }
+ }
+
+ return $this->collContentI18ns;
+ }
+
+ /**
+ * Sets a collection of ContentI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $contentI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function setContentI18ns(Collection $contentI18ns, ConnectionInterface $con = null)
+ {
+ $contentI18nsToDelete = $this->getContentI18ns(new Criteria(), $con)->diff($contentI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->contentI18nsScheduledForDeletion = clone $contentI18nsToDelete;
+
+ foreach ($contentI18nsToDelete as $contentI18nRemoved) {
+ $contentI18nRemoved->setContent(null);
+ }
+
+ $this->collContentI18ns = null;
+ foreach ($contentI18ns as $contentI18n) {
+ $this->addContentI18n($contentI18n);
+ }
+
+ $this->collContentI18ns = $contentI18ns;
+ $this->collContentI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ContentI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ContentI18n objects.
+ * @throws PropelException
+ */
+ public function countContentI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collContentI18nsPartial && !$this->isNew();
+ if (null === $this->collContentI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getContentI18ns());
+ }
+
+ $query = ChildContentI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByContent($this)
+ ->count($con);
+ }
+
+ return count($this->collContentI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildContentI18n object to this object
+ * through the ChildContentI18n foreign key attribute.
+ *
+ * @param ChildContentI18n $l ChildContentI18n
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function addContentI18n(ChildContentI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collContentI18ns === null) {
+ $this->initContentI18ns();
+ $this->collContentI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collContentI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddContentI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ContentI18n $contentI18n The contentI18n object to add.
+ */
+ protected function doAddContentI18n($contentI18n)
+ {
+ $this->collContentI18ns[]= $contentI18n;
+ $contentI18n->setContent($this);
+ }
+
+ /**
+ * @param ContentI18n $contentI18n The contentI18n object to remove.
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function removeContentI18n($contentI18n)
+ {
+ if ($this->getContentI18ns()->contains($contentI18n)) {
+ $this->collContentI18ns->remove($this->collContentI18ns->search($contentI18n));
+ if (null === $this->contentI18nsScheduledForDeletion) {
+ $this->contentI18nsScheduledForDeletion = clone $this->collContentI18ns;
+ $this->contentI18nsScheduledForDeletion->clear();
+ }
+ $this->contentI18nsScheduledForDeletion[]= clone $contentI18n;
+ $contentI18n->setContent(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collContentVersions collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addContentVersions()
+ */
+ public function clearContentVersions()
+ {
+ $this->collContentVersions = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collContentVersions collection loaded partially.
+ */
+ public function resetPartialContentVersions($v = true)
+ {
+ $this->collContentVersionsPartial = $v;
+ }
+
+ /**
+ * Initializes the collContentVersions collection.
+ *
+ * By default this just sets the collContentVersions collection to an empty array (like clearcollContentVersions());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initContentVersions($overrideExisting = true)
+ {
+ if (null !== $this->collContentVersions && !$overrideExisting) {
+ return;
+ }
+ $this->collContentVersions = new ObjectCollection();
+ $this->collContentVersions->setModel('\Thelia\Model\ContentVersion');
+ }
+
+ /**
+ * Gets an array of ChildContentVersion objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildContent is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildContentVersion[] List of ChildContentVersion objects
+ * @throws PropelException
+ */
+ public function getContentVersions($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collContentVersionsPartial && !$this->isNew();
+ if (null === $this->collContentVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentVersions) {
+ // return empty collection
+ $this->initContentVersions();
+ } else {
+ $collContentVersions = ChildContentVersionQuery::create(null, $criteria)
+ ->filterByContent($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collContentVersionsPartial && count($collContentVersions)) {
+ $this->initContentVersions(false);
+
+ foreach ($collContentVersions as $obj) {
+ if (false == $this->collContentVersions->contains($obj)) {
+ $this->collContentVersions->append($obj);
+ }
+ }
+
+ $this->collContentVersionsPartial = true;
+ }
+
+ $collContentVersions->getInternalIterator()->rewind();
+
+ return $collContentVersions;
+ }
+
+ if ($partial && $this->collContentVersions) {
+ foreach ($this->collContentVersions as $obj) {
+ if ($obj->isNew()) {
+ $collContentVersions[] = $obj;
+ }
+ }
+ }
+
+ $this->collContentVersions = $collContentVersions;
+ $this->collContentVersionsPartial = false;
+ }
+ }
+
+ return $this->collContentVersions;
+ }
+
+ /**
+ * Sets a collection of ContentVersion objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $contentVersions A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function setContentVersions(Collection $contentVersions, ConnectionInterface $con = null)
+ {
+ $contentVersionsToDelete = $this->getContentVersions(new Criteria(), $con)->diff($contentVersions);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->contentVersionsScheduledForDeletion = clone $contentVersionsToDelete;
+
+ foreach ($contentVersionsToDelete as $contentVersionRemoved) {
+ $contentVersionRemoved->setContent(null);
+ }
+
+ $this->collContentVersions = null;
+ foreach ($contentVersions as $contentVersion) {
+ $this->addContentVersion($contentVersion);
+ }
+
+ $this->collContentVersions = $contentVersions;
+ $this->collContentVersionsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ContentVersion objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ContentVersion objects.
+ * @throws PropelException
+ */
+ public function countContentVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collContentVersionsPartial && !$this->isNew();
+ if (null === $this->collContentVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentVersions) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getContentVersions());
+ }
+
+ $query = ChildContentVersionQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByContent($this)
+ ->count($con);
+ }
+
+ return count($this->collContentVersions);
+ }
+
+ /**
+ * Method called to associate a ChildContentVersion object to this object
+ * through the ChildContentVersion foreign key attribute.
+ *
+ * @param ChildContentVersion $l ChildContentVersion
+ * @return \Thelia\Model\Content The current object (for fluent API support)
+ */
+ public function addContentVersion(ChildContentVersion $l)
+ {
+ if ($this->collContentVersions === null) {
+ $this->initContentVersions();
+ $this->collContentVersionsPartial = true;
+ }
+
+ if (!in_array($l, $this->collContentVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddContentVersion($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ContentVersion $contentVersion The contentVersion object to add.
+ */
+ protected function doAddContentVersion($contentVersion)
+ {
+ $this->collContentVersions[]= $contentVersion;
+ $contentVersion->setContent($this);
+ }
+
+ /**
+ * @param ContentVersion $contentVersion The contentVersion object to remove.
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function removeContentVersion($contentVersion)
+ {
+ if ($this->getContentVersions()->contains($contentVersion)) {
+ $this->collContentVersions->remove($this->collContentVersions->search($contentVersion));
+ if (null === $this->contentVersionsScheduledForDeletion) {
+ $this->contentVersionsScheduledForDeletion = clone $this->collContentVersions;
+ $this->contentVersionsScheduledForDeletion->clear();
+ }
+ $this->contentVersionsScheduledForDeletion[]= clone $contentVersion;
+ $contentVersion->setContent(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collFolders collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addFolders()
+ */
+ public function clearFolders()
+ {
+ $this->collFolders = null; // important to set this to NULL since that means it is uninitialized
+ $this->collFoldersPartial = null;
+ }
+
+ /**
+ * Initializes the collFolders collection.
+ *
+ * By default this just sets the collFolders collection to an empty collection (like clearFolders());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initFolders()
+ {
+ $this->collFolders = new ObjectCollection();
+ $this->collFolders->setModel('\Thelia\Model\Folder');
+ }
+
+ /**
+ * Gets a collection of ChildFolder objects related by a many-to-many relationship
+ * to the current object by way of the content_folder cross-reference table.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildContent is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return ObjectCollection|ChildFolder[] List of ChildFolder objects
+ */
+ public function getFolders($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collFolders || null !== $criteria) {
+ if ($this->isNew() && null === $this->collFolders) {
+ // return empty collection
+ $this->initFolders();
+ } else {
+ $collFolders = ChildFolderQuery::create(null, $criteria)
+ ->filterByContent($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collFolders;
+ }
+ $this->collFolders = $collFolders;
+ }
+ }
+
+ return $this->collFolders;
+ }
+
+ /**
+ * Sets a collection of Folder objects related by a many-to-many relationship
+ * to the current object by way of the content_folder cross-reference table.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $folders A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function setFolders(Collection $folders, ConnectionInterface $con = null)
+ {
+ $this->clearFolders();
+ $currentFolders = $this->getFolders();
+
+ $this->foldersScheduledForDeletion = $currentFolders->diff($folders);
+
+ foreach ($folders as $folder) {
+ if (!$currentFolders->contains($folder)) {
+ $this->doAddFolder($folder);
+ }
+ }
+
+ $this->collFolders = $folders;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildFolder objects related by a many-to-many relationship
+ * to the current object by way of the content_folder cross-reference table.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param boolean $distinct Set to true to force count distinct
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return int the number of related ChildFolder objects
+ */
+ public function countFolders($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collFolders || null !== $criteria) {
+ if ($this->isNew() && null === $this->collFolders) {
+ return 0;
+ } else {
+ $query = ChildFolderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByContent($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collFolders);
+ }
+ }
+
+ /**
+ * Associate a ChildFolder object to this object
+ * through the content_folder cross reference table.
+ *
+ * @param ChildFolder $folder The ChildContentFolder object to relate
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function addFolder(ChildFolder $folder)
+ {
+ if ($this->collFolders === null) {
+ $this->initFolders();
+ }
+
+ if (!$this->collFolders->contains($folder)) { // only add it if the **same** object is not already associated
+ $this->doAddFolder($folder);
+ $this->collFolders[] = $folder;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Folder $folder The folder object to add.
+ */
+ protected function doAddFolder($folder)
+ {
+ $contentFolder = new ChildContentFolder();
+ $contentFolder->setFolder($folder);
+ $this->addContentFolder($contentFolder);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$folder->getContents()->contains($this)) {
+ $foreignCollection = $folder->getContents();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildFolder object to this object
+ * through the content_folder cross reference table.
+ *
+ * @param ChildFolder $folder The ChildContentFolder object to relate
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function removeFolder(ChildFolder $folder)
+ {
+ if ($this->getFolders()->contains($folder)) {
+ $this->collFolders->remove($this->collFolders->search($folder));
+
+ if (null === $this->foldersScheduledForDeletion) {
+ $this->foldersScheduledForDeletion = clone $this->collFolders;
+ $this->foldersScheduledForDeletion->clear();
+ }
+
+ $this->foldersScheduledForDeletion[] = $folder;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->visible = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collContentAssocs) {
+ foreach ($this->collContentAssocs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collImages) {
+ foreach ($this->collImages as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collDocuments) {
+ foreach ($this->collDocuments as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collRewritings) {
+ foreach ($this->collRewritings as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collContentFolders) {
+ foreach ($this->collContentFolders as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collContentI18ns) {
+ foreach ($this->collContentI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collContentVersions) {
+ foreach ($this->collContentVersions as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collFolders) {
+ foreach ($this->collFolders as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collContentAssocs instanceof Collection) {
+ $this->collContentAssocs->clearIterator();
+ }
+ $this->collContentAssocs = null;
+ if ($this->collImages instanceof Collection) {
+ $this->collImages->clearIterator();
+ }
+ $this->collImages = null;
+ if ($this->collDocuments instanceof Collection) {
+ $this->collDocuments->clearIterator();
+ }
+ $this->collDocuments = null;
+ if ($this->collRewritings instanceof Collection) {
+ $this->collRewritings->clearIterator();
+ }
+ $this->collRewritings = null;
+ if ($this->collContentFolders instanceof Collection) {
+ $this->collContentFolders->clearIterator();
+ }
+ $this->collContentFolders = null;
+ if ($this->collContentI18ns instanceof Collection) {
+ $this->collContentI18ns->clearIterator();
+ }
+ $this->collContentI18ns = null;
+ if ($this->collContentVersions instanceof Collection) {
+ $this->collContentVersions->clearIterator();
+ }
+ $this->collContentVersions = null;
+ if ($this->collFolders instanceof Collection) {
+ $this->collFolders->clearIterator();
+ }
+ $this->collFolders = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ContentTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = ContentTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildContentI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collContentI18ns) {
+ foreach ($this->collContentI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildContentI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildContentI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addContentI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildContentI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collContentI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collContentI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildContentI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ContentI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ContentI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ContentI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ContentI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ // versionable behavior
+
+ /**
+ * Enforce a new Version of this object upon next save.
+ *
+ * @return \Thelia\Model\Content
+ */
+ public function enforceVersioning()
+ {
+ $this->enforceVersion = true;
+
+ return $this;
+ }
+
+ /**
+ * Checks whether the current state must be recorded as a version
+ *
+ * @return boolean
+ */
+ public function isVersioningNecessary($con = null)
+ {
+ if ($this->alreadyInSave) {
+ return false;
+ }
+
+ if ($this->enforceVersion) {
+ return true;
+ }
+
+ if (ChildContentQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Creates a version of the current object and saves it.
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ChildContentVersion A version object
+ */
+ public function addVersion($con = null)
+ {
+ $this->enforceVersion = false;
+
+ $version = new ChildContentVersion();
+ $version->setId($this->getId());
+ $version->setVisible($this->getVisible());
+ $version->setPosition($this->getPosition());
+ $version->setCreatedAt($this->getCreatedAt());
+ $version->setUpdatedAt($this->getUpdatedAt());
+ $version->setVersion($this->getVersion());
+ $version->setVersionCreatedAt($this->getVersionCreatedAt());
+ $version->setVersionCreatedBy($this->getVersionCreatedBy());
+ $version->setContent($this);
+ $version->save($con);
+
+ return $version;
+ }
+
+ /**
+ * Sets the properties of the current object to the value they had at a specific version
+ *
+ * @param integer $versionNumber The version number to read
+ * @param ConnectionInterface $con The connection to use
+ *
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function toVersion($versionNumber, $con = null)
+ {
+ $version = $this->getOneVersion($versionNumber, $con);
+ if (!$version) {
+ throw new PropelException(sprintf('No ChildContent object found with version %d', $version));
+ }
+ $this->populateFromVersion($version, $con);
+
+ return $this;
+ }
+
+ /**
+ * Sets the properties of the current object to the value they had at a specific version
+ *
+ * @param ChildContentVersion $version The version object to use
+ * @param ConnectionInterface $con the connection to use
+ * @param array $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects.
+ *
+ * @return ChildContent The current object (for fluent API support)
+ */
+ public function populateFromVersion($version, $con = null, &$loadedObjects = array())
+ {
+ $loadedObjects['ChildContent'][$version->getId()][$version->getVersion()] = $this;
+ $this->setId($version->getId());
+ $this->setVisible($version->getVisible());
+ $this->setPosition($version->getPosition());
+ $this->setCreatedAt($version->getCreatedAt());
+ $this->setUpdatedAt($version->getUpdatedAt());
+ $this->setVersion($version->getVersion());
+ $this->setVersionCreatedAt($version->getVersionCreatedAt());
+ $this->setVersionCreatedBy($version->getVersionCreatedBy());
+
+ return $this;
+ }
+
+ /**
+ * Gets the latest persisted version number for the current object
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return integer
+ */
+ public function getLastVersionNumber($con = null)
+ {
+ $v = ChildContentVersionQuery::create()
+ ->filterByContent($this)
+ ->orderByVersion('desc')
+ ->findOne($con);
+ if (!$v) {
+ return 0;
+ }
+
+ return $v->getVersion();
+ }
+
+ /**
+ * Checks whether the current object is the latest one
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return Boolean
+ */
+ public function isLastVersion($con = null)
+ {
+ return $this->getLastVersionNumber($con) == $this->getVersion();
+ }
+
+ /**
+ * Retrieves a version object for this entity and a version number
+ *
+ * @param integer $versionNumber The version number to read
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ChildContentVersion A version object
+ */
+ public function getOneVersion($versionNumber, $con = null)
+ {
+ return ChildContentVersionQuery::create()
+ ->filterByContent($this)
+ ->filterByVersion($versionNumber)
+ ->findOne($con);
+ }
+
+ /**
+ * Gets all the versions of this object, in incremental order
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ObjectCollection A list of ChildContentVersion objects
+ */
+ public function getAllVersions($con = null)
+ {
+ $criteria = new Criteria();
+ $criteria->addAscendingOrderByColumn(ContentVersionTableMap::VERSION);
+
+ return $this->getContentVersions($criteria, $con);
+ }
+
+ /**
+ * Compares the current object with another of its version.
+ *
+ * print_r($book->compareVersion(1));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $versionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param ConnectionInterface $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->toArray();
+ $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Compares two versions of the current object.
+ *
+ * print_r($book->compareVersions(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $fromVersionNumber
+ * @param integer $toVersionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param ConnectionInterface $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
+ $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Computes the diff between two versions.
+ *
+ * print_r($book->computeDiff(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param array $fromVersion An array representing the original version.
+ * @param array $toVersion An array representing the destination version.
+ * @param string $keys Main key used for the result diff (versions|columns).
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
+ {
+ $fromVersionNumber = $fromVersion['Version'];
+ $toVersionNumber = $toVersion['Version'];
+ $ignoredColumns = array_merge(array(
+ 'Version',
+ 'VersionCreatedAt',
+ 'VersionCreatedBy',
+ ), $ignoredColumns);
+ $diff = array();
+ foreach ($fromVersion as $key => $value) {
+ if (in_array($key, $ignoredColumns)) {
+ continue;
+ }
+ if ($toVersion[$key] != $value) {
+ switch ($keys) {
+ case 'versions':
+ $diff[$fromVersionNumber][$key] = $value;
+ $diff[$toVersionNumber][$key] = $toVersion[$key];
+ break;
+ default:
+ $diff[$key] = array(
+ $fromVersionNumber => $value,
+ $toVersionNumber => $toVersion[$key],
+ );
+ break;
+ }
+ }
+ }
+
+ return $diff;
+ }
+ /**
+ * retrieve the last $number versions.
+ *
+ * @param Integer $number the number of record to return.
+ * @return PropelCollection|array \Thelia\Model\ContentVersion[] List of \Thelia\Model\ContentVersion objects
+ */
+ public function getLastVersions($number = 10, $criteria = null, $con = null)
+ {
+ $criteria = ChildContentVersionQuery::create(null, $criteria);
+ $criteria->addDescendingOrderByColumn(ContentVersionTableMap::VERSION);
+ $criteria->limit($number);
+
+ return $this->getContentVersions($criteria, $con);
+ }
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ContentAssoc.php b/core/lib/Thelia/Model/Base/ContentAssoc.php
new file mode 100644
index 000000000..eaa1cb9b7
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ContentAssoc.php
@@ -0,0 +1,1688 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another ContentAssoc instance. If
+ * obj is an instance of ContentAssoc, delegates to
+ * equals(ContentAssoc). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return ContentAssoc The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return ContentAssoc The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+
+ return $this->category_id;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [content_id] column value.
+ *
+ * @return int
+ */
+ public function getContentId()
+ {
+
+ return $this->content_id;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ContentAssoc The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ContentAssocTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ContentAssoc The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = ContentAssocTableMap::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ContentAssoc The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = ContentAssocTableMap::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [content_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ContentAssoc The current object (for fluent API support)
+ */
+ public function setContentId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->content_id !== $v) {
+ $this->content_id = $v;
+ $this->modifiedColumns[] = ContentAssocTableMap::CONTENT_ID;
+ }
+
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
+
+ return $this;
+ } // setContentId()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ContentAssoc The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = ContentAssocTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\ContentAssoc The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = ContentAssocTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\ContentAssoc The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = ContentAssocTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentAssocTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentAssocTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->category_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentAssocTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->product_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentAssocTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->content_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentAssocTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ContentAssocTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ContentAssocTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = ContentAssocTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\ContentAssoc object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) {
+ $this->aContent = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ContentAssocTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildContentAssocQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCategory = null;
+ $this->aProduct = null;
+ $this->aContent = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see ContentAssoc::setDeleted()
+ * @see ContentAssoc::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildContentAssocQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(ContentAssocTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(ContentAssocTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(ContentAssocTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ContentAssocTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
+ if ($this->aContent !== null) {
+ if ($this->aContent->isModified() || $this->aContent->isNew()) {
+ $affectedRows += $this->aContent->save($con);
+ }
+ $this->setContent($this->aContent);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ContentAssocTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentAssocTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ContentAssocTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ContentAssocTableMap::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CATEGORY_ID';
+ }
+ if ($this->isColumnModified(ContentAssocTableMap::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'PRODUCT_ID';
+ }
+ if ($this->isColumnModified(ContentAssocTableMap::CONTENT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CONTENT_ID';
+ }
+ if ($this->isColumnModified(ContentAssocTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(ContentAssocTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(ContentAssocTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO content_assoc (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'CATEGORY_ID':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ case 'PRODUCT_ID':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case 'CONTENT_ID':
+ $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ContentAssocTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getCategoryId();
+ break;
+ case 2:
+ return $this->getProductId();
+ break;
+ case 3:
+ return $this->getContentId();
+ break;
+ case 4:
+ return $this->getPosition();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ContentAssoc'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ContentAssoc'][$this->getPrimaryKey()] = true;
+ $keys = ContentAssocTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCategoryId(),
+ $keys[2] => $this->getProductId(),
+ $keys[3] => $this->getContentId(),
+ $keys[4] => $this->getPosition(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ContentAssocTableMap::translateFieldName($name, $type, TableMap::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->setCategoryId($value);
+ break;
+ case 2:
+ $this->setProductId($value);
+ break;
+ case 3:
+ $this->setContentId($value);
+ break;
+ case 4:
+ $this->setPosition($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ContentAssocTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setProductId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setContentId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * 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(ContentAssocTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ContentAssocTableMap::ID)) $criteria->add(ContentAssocTableMap::ID, $this->id);
+ if ($this->isColumnModified(ContentAssocTableMap::CATEGORY_ID)) $criteria->add(ContentAssocTableMap::CATEGORY_ID, $this->category_id);
+ if ($this->isColumnModified(ContentAssocTableMap::PRODUCT_ID)) $criteria->add(ContentAssocTableMap::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(ContentAssocTableMap::CONTENT_ID)) $criteria->add(ContentAssocTableMap::CONTENT_ID, $this->content_id);
+ if ($this->isColumnModified(ContentAssocTableMap::POSITION)) $criteria->add(ContentAssocTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(ContentAssocTableMap::CREATED_AT)) $criteria->add(ContentAssocTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ContentAssocTableMap::UPDATED_AT)) $criteria->add(ContentAssocTableMap::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(ContentAssocTableMap::DATABASE_NAME);
+ $criteria->add(ContentAssocTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\ContentAssoc (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCategoryId($this->getCategoryId());
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setContentId($this->getContentId());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\ContentAssoc 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCategory object.
+ *
+ * @param ChildCategory $v
+ * @return \Thelia\Model\ContentAssoc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCategory(ChildCategory $v = null)
+ {
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
+ }
+
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCategory object, it will not be re-added.
+ if ($v !== null) {
+ $v->addContentAssoc($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCategory object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCategory The associated ChildCategory object.
+ * @throws PropelException
+ */
+ public function getCategory(ConnectionInterface $con = null)
+ {
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCategory->addContentAssocs($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Declares an association between this object and a ChildProduct object.
+ *
+ * @param ChildProduct $v
+ * @return \Thelia\Model\ContentAssoc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(ChildProduct $v = null)
+ {
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
+ }
+
+ $this->aProduct = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildProduct object, it will not be re-added.
+ if ($v !== null) {
+ $v->addContentAssoc($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildProduct object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildProduct The associated ChildProduct object.
+ * @throws PropelException
+ */
+ public function getProduct(ConnectionInterface $con = null)
+ {
+ if ($this->aProduct === null && ($this->product_id !== null)) {
+ $this->aProduct = ChildProductQuery::create()->findPk($this->product_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aProduct->addContentAssocs($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
+ /**
+ * Declares an association between this object and a ChildContent object.
+ *
+ * @param ChildContent $v
+ * @return \Thelia\Model\ContentAssoc The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setContent(ChildContent $v = null)
+ {
+ if ($v === null) {
+ $this->setContentId(NULL);
+ } else {
+ $this->setContentId($v->getId());
+ }
+
+ $this->aContent = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildContent object, it will not be re-added.
+ if ($v !== null) {
+ $v->addContentAssoc($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildContent object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildContent The associated ChildContent object.
+ * @throws PropelException
+ */
+ public function getContent(ConnectionInterface $con = null)
+ {
+ if ($this->aContent === null && ($this->content_id !== null)) {
+ $this->aContent = ChildContentQuery::create()->findPk($this->content_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aContent->addContentAssocs($this);
+ */
+ }
+
+ return $this->aContent;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->category_id = null;
+ $this->product_id = null;
+ $this->content_id = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCategory = null;
+ $this->aProduct = null;
+ $this->aContent = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ContentAssocTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildContentAssoc The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = ContentAssocTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ContentAssocQuery.php b/core/lib/Thelia/Model/Base/ContentAssocQuery.php
new file mode 100644
index 000000000..630af8065
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ContentAssocQuery.php
@@ -0,0 +1,930 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildContentAssoc|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ContentAssocTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ContentAssocTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildContentAssoc A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CATEGORY_ID, PRODUCT_ID, CONTENT_ID, POSITION, CREATED_AT, UPDATED_AT FROM content_assoc WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildContentAssoc();
+ $obj->hydrate($row);
+ ContentAssocTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildContentAssoc|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ContentAssocTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ContentAssocTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ContentAssocTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ContentAssocTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentAssocTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId)) {
+ $useMinMax = false;
+ if (isset($categoryId['min'])) {
+ $this->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($categoryId['max'])) {
+ $this->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $categoryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the content_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByContentId(1234); // WHERE content_id = 1234
+ * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34)
+ * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
+ *
+ *
+ * @see filterByContent()
+ *
+ * @param mixed $contentId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByContentId($contentId = null, $comparison = null)
+ {
+ if (is_array($contentId)) {
+ $useMinMax = false;
+ if (isset($contentId['min'])) {
+ $this->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($contentId['max'])) {
+ $this->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $contentId, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(ContentAssocTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(ContentAssocTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentAssocTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ContentAssocTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ContentAssocTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentAssocTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ContentAssocTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ContentAssocTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentAssocTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Category object
+ *
+ * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByCategory($category, $comparison = null)
+ {
+ if ($category instanceof \Thelia\Model\Category) {
+ return $this
+ ->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Category relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Category');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Category');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Category relation Category object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Product object
+ *
+ * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByProduct($product, $comparison = null)
+ {
+ if ($product instanceof \Thelia\Model\Product) {
+ return $this
+ ->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Product relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Product');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Product');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Product relation Product object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
+ */
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Content object
+ *
+ * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function filterByContent($content, $comparison = null)
+ {
+ if ($content instanceof \Thelia\Model\Content) {
+ return $this
+ ->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $content->getId(), $comparison);
+ } elseif ($content instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Content relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Content');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Content');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Content relation Content object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query
+ */
+ public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinContent($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildContentAssoc $contentAssoc Object to remove from the list of results
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function prune($contentAssoc = null)
+ {
+ if ($contentAssoc) {
+ $this->addUsingAlias(ContentAssocTableMap::ID, $contentAssoc->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the content_assoc table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ContentAssocTableMap::clearInstancePool();
+ ContentAssocTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildContentAssoc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildContentAssoc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentAssocTableMap::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->beginTransaction();
+
+
+ ContentAssocTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ContentAssocTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ContentAssocTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ContentAssocTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ContentAssocTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ContentAssocTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ContentAssocTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildContentAssocQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ContentAssocTableMap::CREATED_AT);
+ }
+
+} // ContentAssocQuery
diff --git a/core/lib/Thelia/Model/Base/ContentFolder.php b/core/lib/Thelia/Model/Base/ContentFolder.php
new file mode 100644
index 000000000..52f5fa88a
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ContentFolder.php
@@ -0,0 +1,1433 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another ContentFolder instance. If
+ * obj is an instance of ContentFolder, delegates to
+ * equals(ContentFolder). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return ContentFolder The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return ContentFolder The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [content_id] column value.
+ *
+ * @return int
+ */
+ public function getContentId()
+ {
+
+ return $this->content_id;
+ }
+
+ /**
+ * Get the [folder_id] column value.
+ *
+ * @return int
+ */
+ public function getFolderId()
+ {
+
+ return $this->folder_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [content_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ContentFolder The current object (for fluent API support)
+ */
+ public function setContentId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->content_id !== $v) {
+ $this->content_id = $v;
+ $this->modifiedColumns[] = ContentFolderTableMap::CONTENT_ID;
+ }
+
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
+
+ return $this;
+ } // setContentId()
+
+ /**
+ * Set the value of [folder_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ContentFolder The current object (for fluent API support)
+ */
+ public function setFolderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->folder_id !== $v) {
+ $this->folder_id = $v;
+ $this->modifiedColumns[] = ContentFolderTableMap::FOLDER_ID;
+ }
+
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
+
+ return $this;
+ } // setFolderId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\ContentFolder The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = ContentFolderTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\ContentFolder The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = ContentFolderTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentFolderTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->content_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentFolderTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->folder_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentFolderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentFolderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = ContentFolderTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\ContentFolder object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) {
+ $this->aContent = null;
+ }
+ if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) {
+ $this->aFolder = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ContentFolderTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildContentFolderQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aContent = null;
+ $this->aFolder = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see ContentFolder::setDeleted()
+ * @see ContentFolder::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentFolderTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildContentFolderQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentFolderTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(ContentFolderTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(ContentFolderTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(ContentFolderTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ContentFolderTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aContent !== null) {
+ if ($this->aContent->isModified() || $this->aContent->isNew()) {
+ $affectedRows += $this->aContent->save($con);
+ }
+ $this->setContent($this->aContent);
+ }
+
+ if ($this->aFolder !== null) {
+ if ($this->aFolder->isModified() || $this->aFolder->isNew()) {
+ $affectedRows += $this->aFolder->save($con);
+ }
+ $this->setFolder($this->aFolder);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ContentFolderTableMap::CONTENT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CONTENT_ID';
+ }
+ if ($this->isColumnModified(ContentFolderTableMap::FOLDER_ID)) {
+ $modifiedColumns[':p' . $index++] = 'FOLDER_ID';
+ }
+ if ($this->isColumnModified(ContentFolderTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(ContentFolderTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO content_folder (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'CONTENT_ID':
+ $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT);
+ break;
+ case 'FOLDER_ID':
+ $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ContentFolderTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getContentId();
+ break;
+ case 1:
+ return $this->getFolderId();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ContentFolder'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ContentFolder'][serialize($this->getPrimaryKey())] = true;
+ $keys = ContentFolderTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getContentId(),
+ $keys[1] => $this->getFolderId(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ContentFolderTableMap::translateFieldName($name, $type, TableMap::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->setContentId($value);
+ break;
+ case 1:
+ $this->setFolderId($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ContentFolderTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setContentId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setFolderId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * 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(ContentFolderTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ContentFolderTableMap::CONTENT_ID)) $criteria->add(ContentFolderTableMap::CONTENT_ID, $this->content_id);
+ if ($this->isColumnModified(ContentFolderTableMap::FOLDER_ID)) $criteria->add(ContentFolderTableMap::FOLDER_ID, $this->folder_id);
+ if ($this->isColumnModified(ContentFolderTableMap::CREATED_AT)) $criteria->add(ContentFolderTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ContentFolderTableMap::UPDATED_AT)) $criteria->add(ContentFolderTableMap::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(ContentFolderTableMap::DATABASE_NAME);
+ $criteria->add(ContentFolderTableMap::CONTENT_ID, $this->content_id);
+ $criteria->add(ContentFolderTableMap::FOLDER_ID, $this->folder_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getContentId();
+ $pks[1] = $this->getFolderId();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setContentId($keys[0]);
+ $this->setFolderId($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getContentId()) && (null === $this->getFolderId());
+ }
+
+ /**
+ * 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 \Thelia\Model\ContentFolder (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setContentId($this->getContentId());
+ $copyObj->setFolderId($this->getFolderId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\ContentFolder 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildContent object.
+ *
+ * @param ChildContent $v
+ * @return \Thelia\Model\ContentFolder The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setContent(ChildContent $v = null)
+ {
+ if ($v === null) {
+ $this->setContentId(NULL);
+ } else {
+ $this->setContentId($v->getId());
+ }
+
+ $this->aContent = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildContent object, it will not be re-added.
+ if ($v !== null) {
+ $v->addContentFolder($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildContent object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildContent The associated ChildContent object.
+ * @throws PropelException
+ */
+ public function getContent(ConnectionInterface $con = null)
+ {
+ if ($this->aContent === null && ($this->content_id !== null)) {
+ $this->aContent = ChildContentQuery::create()->findPk($this->content_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aContent->addContentFolders($this);
+ */
+ }
+
+ return $this->aContent;
+ }
+
+ /**
+ * Declares an association between this object and a ChildFolder object.
+ *
+ * @param ChildFolder $v
+ * @return \Thelia\Model\ContentFolder The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFolder(ChildFolder $v = null)
+ {
+ if ($v === null) {
+ $this->setFolderId(NULL);
+ } else {
+ $this->setFolderId($v->getId());
+ }
+
+ $this->aFolder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildFolder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addContentFolder($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildFolder object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildFolder The associated ChildFolder object.
+ * @throws PropelException
+ */
+ public function getFolder(ConnectionInterface $con = null)
+ {
+ if ($this->aFolder === null && ($this->folder_id !== null)) {
+ $this->aFolder = ChildFolderQuery::create()->findPk($this->folder_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aFolder->addContentFolders($this);
+ */
+ }
+
+ return $this->aFolder;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->content_id = null;
+ $this->folder_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aContent = null;
+ $this->aFolder = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ContentFolderTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildContentFolder The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = ContentFolderTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ContentFolderQuery.php b/core/lib/Thelia/Model/Base/ContentFolderQuery.php
new file mode 100644
index 000000000..208ba80cf
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ContentFolderQuery.php
@@ -0,0 +1,728 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$content_id, $folder_id] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildContentFolder|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ContentFolderTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ContentFolderTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildContentFolder A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT CONTENT_ID, FOLDER_ID, CREATED_AT, UPDATED_AT FROM content_folder WHERE CONTENT_ID = :p0 AND FOLDER_ID = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildContentFolder();
+ $obj->hydrate($row);
+ ContentFolderTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildContentFolder|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(ContentFolderTableMap::CONTENT_ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(ContentFolderTableMap::FOLDER_ID, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(ContentFolderTableMap::CONTENT_ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(ContentFolderTableMap::FOLDER_ID, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the content_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByContentId(1234); // WHERE content_id = 1234
+ * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34)
+ * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
+ *
+ *
+ * @see filterByContent()
+ *
+ * @param mixed $contentId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function filterByContentId($contentId = null, $comparison = null)
+ {
+ if (is_array($contentId)) {
+ $useMinMax = false;
+ if (isset($contentId['min'])) {
+ $this->addUsingAlias(ContentFolderTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($contentId['max'])) {
+ $this->addUsingAlias(ContentFolderTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentFolderTableMap::CONTENT_ID, $contentId, $comparison);
+ }
+
+ /**
+ * Filter the query on the folder_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFolderId(1234); // WHERE folder_id = 1234
+ * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34)
+ * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12
+ *
+ *
+ * @see filterByFolder()
+ *
+ * @param mixed $folderId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function filterByFolderId($folderId = null, $comparison = null)
+ {
+ if (is_array($folderId)) {
+ $useMinMax = false;
+ if (isset($folderId['min'])) {
+ $this->addUsingAlias(ContentFolderTableMap::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($folderId['max'])) {
+ $this->addUsingAlias(ContentFolderTableMap::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentFolderTableMap::FOLDER_ID, $folderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ContentFolderTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ContentFolderTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentFolderTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ContentFolderTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ContentFolderTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentFolderTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Content object
+ *
+ * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function filterByContent($content, $comparison = null)
+ {
+ if ($content instanceof \Thelia\Model\Content) {
+ return $this
+ ->addUsingAlias(ContentFolderTableMap::CONTENT_ID, $content->getId(), $comparison);
+ } elseif ($content instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ContentFolderTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Content relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Content');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Content');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Content relation Content object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query
+ */
+ public function useContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinContent($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Folder object
+ *
+ * @param \Thelia\Model\Folder|ObjectCollection $folder The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function filterByFolder($folder, $comparison = null)
+ {
+ if ($folder instanceof \Thelia\Model\Folder) {
+ return $this
+ ->addUsingAlias(ContentFolderTableMap::FOLDER_ID, $folder->getId(), $comparison);
+ } elseif ($folder instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ContentFolderTableMap::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Folder relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function joinFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Folder');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Folder');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Folder relation Folder object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query
+ */
+ public function useFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFolder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildContentFolder $contentFolder Object to remove from the list of results
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function prune($contentFolder = null)
+ {
+ if ($contentFolder) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(ContentFolderTableMap::CONTENT_ID), $contentFolder->getContentId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(ContentFolderTableMap::FOLDER_ID), $contentFolder->getFolderId(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the content_folder table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentFolderTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ContentFolderTableMap::clearInstancePool();
+ ContentFolderTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildContentFolder or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildContentFolder object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentFolderTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentFolderTableMap::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->beginTransaction();
+
+
+ ContentFolderTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ContentFolderTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ContentFolderTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ContentFolderTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ContentFolderTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ContentFolderTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ContentFolderTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildContentFolderQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ContentFolderTableMap::CREATED_AT);
+ }
+
+} // ContentFolderQuery
diff --git a/core/lib/Thelia/Model/Base/ContentI18n.php b/core/lib/Thelia/Model/Base/ContentI18n.php
new file mode 100644
index 000000000..14ff02b39
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ContentI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\ContentI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another ContentI18n instance. If
+ * obj is an instance of ContentI18n, delegates to
+ * equals(ContentI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return ContentI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return ContentI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ContentI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ContentI18nTableMap::ID;
+ }
+
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ContentI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = ContentI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ContentI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = ContentI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ContentI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = ContentI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ContentI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = ContentI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ContentI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = ContentI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ContentI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = ContentI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\ContentI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aContent !== null && $this->id !== $this->aContent->getId()) {
+ $this->aContent = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ContentI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildContentI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aContent = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see ContentI18n::setDeleted()
+ * @see ContentI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildContentI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ContentI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aContent !== null) {
+ if ($this->aContent->isModified() || $this->aContent->isNew()) {
+ $affectedRows += $this->aContent->save($con);
+ }
+ $this->setContent($this->aContent);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ContentI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ContentI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(ContentI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(ContentI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(ContentI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(ContentI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO content_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ContentI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ContentI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ContentI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = ContentI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ContentI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ContentI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(ContentI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ContentI18nTableMap::ID)) $criteria->add(ContentI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(ContentI18nTableMap::LOCALE)) $criteria->add(ContentI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(ContentI18nTableMap::TITLE)) $criteria->add(ContentI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(ContentI18nTableMap::DESCRIPTION)) $criteria->add(ContentI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(ContentI18nTableMap::CHAPO)) $criteria->add(ContentI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(ContentI18nTableMap::POSTSCRIPTUM)) $criteria->add(ContentI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(ContentI18nTableMap::DATABASE_NAME);
+ $criteria->add(ContentI18nTableMap::ID, $this->id);
+ $criteria->add(ContentI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\ContentI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\ContentI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildContent object.
+ *
+ * @param ChildContent $v
+ * @return \Thelia\Model\ContentI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setContent(ChildContent $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aContent = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildContent object, it will not be re-added.
+ if ($v !== null) {
+ $v->addContentI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildContent object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildContent The associated ChildContent object.
+ * @throws PropelException
+ */
+ public function getContent(ConnectionInterface $con = null)
+ {
+ if ($this->aContent === null && ($this->id !== null)) {
+ $this->aContent = ChildContentQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aContent->addContentI18ns($this);
+ */
+ }
+
+ return $this->aContent;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aContent = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ContentI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ContentI18nQuery.php b/core/lib/Thelia/Model/Base/ContentI18nQuery.php
new file mode 100644
index 000000000..cfd638318
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ContentI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildContentI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ContentI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ContentI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildContentI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM content_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildContentI18n();
+ $obj->hydrate($row);
+ ContentI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildContentI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildContentI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(ContentI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(ContentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildContentI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(ContentI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(ContentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByContent()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ContentI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ContentI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ContentI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ContentI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ContentI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ContentI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ContentI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Content object
+ *
+ * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentI18nQuery The current query, for fluid interface
+ */
+ public function filterByContent($content, $comparison = null)
+ {
+ if ($content instanceof \Thelia\Model\Content) {
+ return $this
+ ->addUsingAlias(ContentI18nTableMap::ID, $content->getId(), $comparison);
+ } elseif ($content instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ContentI18nTableMap::ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Content relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildContentI18nQuery The current query, for fluid interface
+ */
+ public function joinContent($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Content');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Content');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Content relation Content object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query
+ */
+ public function useContentQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinContent($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildContentI18n $contentI18n Object to remove from the list of results
+ *
+ * @return ChildContentI18nQuery The current query, for fluid interface
+ */
+ public function prune($contentI18n = null)
+ {
+ if ($contentI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(ContentI18nTableMap::ID), $contentI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(ContentI18nTableMap::LOCALE), $contentI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the content_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ContentI18nTableMap::clearInstancePool();
+ ContentI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildContentI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildContentI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentI18nTableMap::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->beginTransaction();
+
+
+ ContentI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ContentI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // ContentI18nQuery
diff --git a/core/lib/Thelia/Model/Base/ContentQuery.php b/core/lib/Thelia/Model/Base/ContentQuery.php
new file mode 100644
index 000000000..2c4b9da04
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ContentQuery.php
@@ -0,0 +1,1371 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildContent|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ContentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ContentTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildContent A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM content WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildContent();
+ $obj->hydrate($row);
+ ContentTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildContent|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ContentTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ContentTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ContentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ContentTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the visible column
+ *
+ * Example usage:
+ *
+ * $query->filterByVisible(1234); // WHERE visible = 1234
+ * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
+ * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
+ *
+ *
+ * @param mixed $visible The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByVisible($visible = null, $comparison = null)
+ {
+ if (is_array($visible)) {
+ $useMinMax = false;
+ if (isset($visible['min'])) {
+ $this->addUsingAlias(ContentTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(ContentTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentTableMap::VISIBLE, $visible, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(ContentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(ContentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ContentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ContentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ContentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ContentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(ContentTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(ContentTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentTableMap::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(ContentTableMap::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(ContentTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ContentTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ContentAssoc object
+ *
+ * @param \Thelia\Model\ContentAssoc|ObjectCollection $contentAssoc the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByContentAssoc($contentAssoc, $comparison = null)
+ {
+ if ($contentAssoc instanceof \Thelia\Model\ContentAssoc) {
+ return $this
+ ->addUsingAlias(ContentTableMap::ID, $contentAssoc->getContentId(), $comparison);
+ } elseif ($contentAssoc instanceof ObjectCollection) {
+ return $this
+ ->useContentAssocQuery()
+ ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByContentAssoc() only accepts arguments of type \Thelia\Model\ContentAssoc or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ContentAssoc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ContentAssoc');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ContentAssoc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ContentAssoc relation ContentAssoc object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query
+ */
+ public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinContentAssoc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Image object
+ *
+ * @param \Thelia\Model\Image|ObjectCollection $image the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByImage($image, $comparison = null)
+ {
+ if ($image instanceof \Thelia\Model\Image) {
+ return $this
+ ->addUsingAlias(ContentTableMap::ID, $image->getContentId(), $comparison);
+ } elseif ($image instanceof ObjectCollection) {
+ return $this
+ ->useImageQuery()
+ ->filterByPrimaryKeys($image->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Image relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Image');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Image');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Image relation Image object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
+ */
+ public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinImage($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Document object
+ *
+ * @param \Thelia\Model\Document|ObjectCollection $document the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByDocument($document, $comparison = null)
+ {
+ if ($document instanceof \Thelia\Model\Document) {
+ return $this
+ ->addUsingAlias(ContentTableMap::ID, $document->getContentId(), $comparison);
+ } elseif ($document instanceof ObjectCollection) {
+ return $this
+ ->useDocumentQuery()
+ ->filterByPrimaryKeys($document->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Document relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Document');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Document');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Document relation Document object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query
+ */
+ public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinDocument($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Rewriting object
+ *
+ * @param \Thelia\Model\Rewriting|ObjectCollection $rewriting the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByRewriting($rewriting, $comparison = null)
+ {
+ if ($rewriting instanceof \Thelia\Model\Rewriting) {
+ return $this
+ ->addUsingAlias(ContentTableMap::ID, $rewriting->getContentId(), $comparison);
+ } elseif ($rewriting instanceof ObjectCollection) {
+ return $this
+ ->useRewritingQuery()
+ ->filterByPrimaryKeys($rewriting->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByRewriting() only accepts arguments of type \Thelia\Model\Rewriting or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Rewriting relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Rewriting');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Rewriting');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Rewriting relation Rewriting object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query
+ */
+ public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinRewriting($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ContentFolder object
+ *
+ * @param \Thelia\Model\ContentFolder|ObjectCollection $contentFolder the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByContentFolder($contentFolder, $comparison = null)
+ {
+ if ($contentFolder instanceof \Thelia\Model\ContentFolder) {
+ return $this
+ ->addUsingAlias(ContentTableMap::ID, $contentFolder->getContentId(), $comparison);
+ } elseif ($contentFolder instanceof ObjectCollection) {
+ return $this
+ ->useContentFolderQuery()
+ ->filterByPrimaryKeys($contentFolder->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByContentFolder() only accepts arguments of type \Thelia\Model\ContentFolder or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ContentFolder relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function joinContentFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ContentFolder');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ContentFolder');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ContentFolder relation ContentFolder object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentFolderQuery A secondary query class using the current class as primary query
+ */
+ public function useContentFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinContentFolder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentFolder', '\Thelia\Model\ContentFolderQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ContentI18n object
+ *
+ * @param \Thelia\Model\ContentI18n|ObjectCollection $contentI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByContentI18n($contentI18n, $comparison = null)
+ {
+ if ($contentI18n instanceof \Thelia\Model\ContentI18n) {
+ return $this
+ ->addUsingAlias(ContentTableMap::ID, $contentI18n->getId(), $comparison);
+ } elseif ($contentI18n instanceof ObjectCollection) {
+ return $this
+ ->useContentI18nQuery()
+ ->filterByPrimaryKeys($contentI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByContentI18n() only accepts arguments of type \Thelia\Model\ContentI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ContentI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function joinContentI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ContentI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ContentI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ContentI18n relation ContentI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useContentI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinContentI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentI18n', '\Thelia\Model\ContentI18nQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ContentVersion object
+ *
+ * @param \Thelia\Model\ContentVersion|ObjectCollection $contentVersion the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByContentVersion($contentVersion, $comparison = null)
+ {
+ if ($contentVersion instanceof \Thelia\Model\ContentVersion) {
+ return $this
+ ->addUsingAlias(ContentTableMap::ID, $contentVersion->getId(), $comparison);
+ } elseif ($contentVersion instanceof ObjectCollection) {
+ return $this
+ ->useContentVersionQuery()
+ ->filterByPrimaryKeys($contentVersion->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByContentVersion() only accepts arguments of type \Thelia\Model\ContentVersion or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ContentVersion relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function joinContentVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ContentVersion');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ContentVersion');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ContentVersion relation ContentVersion object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentVersionQuery A secondary query class using the current class as primary query
+ */
+ public function useContentVersionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinContentVersion($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentVersion', '\Thelia\Model\ContentVersionQuery');
+ }
+
+ /**
+ * Filter the query by a related Folder object
+ * using the content_folder table as cross reference
+ *
+ * @param Folder $folder the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function filterByFolder($folder, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useContentFolderQuery()
+ ->filterByFolder($folder, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildContent $content Object to remove from the list of results
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function prune($content = null)
+ {
+ if ($content) {
+ $this->addUsingAlias(ContentTableMap::ID, $content->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the content table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ContentTableMap::clearInstancePool();
+ ContentTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildContent or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildContent object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentTableMap::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->beginTransaction();
+
+
+ ContentTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ContentTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ContentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ContentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ContentTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ContentTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ContentTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ContentTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'ContentI18n';
+
+ return $this
+ ->joinContentI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildContentQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('ContentI18n');
+ $this->with['ContentI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildContentI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentI18n', '\Thelia\Model\ContentI18nQuery');
+ }
+
+ // versionable behavior
+
+ /**
+ * Checks whether versioning is enabled
+ *
+ * @return boolean
+ */
+ static public function isVersioningEnabled()
+ {
+ return self::$isVersioningEnabled;
+ }
+
+ /**
+ * Enables versioning
+ */
+ static public function enableVersioning()
+ {
+ self::$isVersioningEnabled = true;
+ }
+
+ /**
+ * Disables versioning
+ */
+ static public function disableVersioning()
+ {
+ self::$isVersioningEnabled = false;
+ }
+
+} // ContentQuery
diff --git a/core/lib/Thelia/Model/Base/ContentVersion.php b/core/lib/Thelia/Model/Base/ContentVersion.php
new file mode 100644
index 000000000..ca9189608
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ContentVersion.php
@@ -0,0 +1,1593 @@
+version = 0;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\ContentVersion object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another ContentVersion instance. If
+ * obj is an instance of ContentVersion, delegates to
+ * equals(ContentVersion). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return ContentVersion The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return ContentVersion The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [visible] column value.
+ *
+ * @return int
+ */
+ public function getVisible()
+ {
+
+ return $this->visible;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getVersionCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->version_created_at;
+ } else {
+ return $this->version_created_at !== null ? $this->version_created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ContentVersion The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ContentVersionTableMap::ID;
+ }
+
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ContentVersion The current object (for fluent API support)
+ */
+ public function setVisible($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->visible !== $v) {
+ $this->visible = $v;
+ $this->modifiedColumns[] = ContentVersionTableMap::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ContentVersion The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = ContentVersionTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\ContentVersion The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = ContentVersionTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\ContentVersion The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = ContentVersionTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ContentVersion The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = ContentVersionTableMap::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\ContentVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ if ($dt !== $this->version_created_at) {
+ $this->version_created_at = $dt;
+ $this->modifiedColumns[] = ContentVersionTableMap::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ContentVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = ContentVersionTableMap::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->version !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentVersionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentVersionTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->visible = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentVersionTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ContentVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ContentVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ContentVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version_created_by = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = ContentVersionTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\ContentVersion object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aContent !== null && $this->id !== $this->aContent->getId()) {
+ $this->aContent = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ContentVersionTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildContentVersionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aContent = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see ContentVersion::setDeleted()
+ * @see ContentVersion::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentVersionTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildContentVersionQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentVersionTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ContentVersionTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aContent !== null) {
+ if ($this->aContent->isModified() || $this->aContent->isNew()) {
+ $affectedRows += $this->aContent->save($con);
+ }
+ $this->setContent($this->aContent);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ContentVersionTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ContentVersionTableMap::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = 'VISIBLE';
+ }
+ if ($this->isColumnModified(ContentVersionTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(ContentVersionTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(ContentVersionTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+ if ($this->isColumnModified(ContentVersionTableMap::VERSION)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION';
+ }
+ if ($this->isColumnModified(ContentVersionTableMap::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT';
+ }
+ if ($this->isColumnModified(ContentVersionTableMap::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO content_version (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'VISIBLE':
+ $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case 'VERSION_CREATED_AT':
+ $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION_CREATED_BY':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ContentVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getVisible();
+ break;
+ case 2:
+ return $this->getPosition();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ return $this->getUpdatedAt();
+ break;
+ case 5:
+ return $this->getVersion();
+ break;
+ case 6:
+ return $this->getVersionCreatedAt();
+ break;
+ case 7:
+ return $this->getVersionCreatedBy();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ContentVersion'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ContentVersion'][serialize($this->getPrimaryKey())] = true;
+ $keys = ContentVersionTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getVisible(),
+ $keys[2] => $this->getPosition(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ $keys[5] => $this->getVersion(),
+ $keys[6] => $this->getVersionCreatedAt(),
+ $keys[7] => $this->getVersionCreatedBy(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ContentVersionTableMap::translateFieldName($name, $type, TableMap::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->setVisible($value);
+ break;
+ case 2:
+ $this->setPosition($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $this->setUpdatedAt($value);
+ break;
+ case 5:
+ $this->setVersion($value);
+ break;
+ case 6:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 7:
+ $this->setVersionCreatedBy($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ContentVersionTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setVisible($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setVersion($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setVersionCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersionCreatedBy($arr[$keys[7]]);
+ }
+
+ /**
+ * 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(ContentVersionTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ContentVersionTableMap::ID)) $criteria->add(ContentVersionTableMap::ID, $this->id);
+ if ($this->isColumnModified(ContentVersionTableMap::VISIBLE)) $criteria->add(ContentVersionTableMap::VISIBLE, $this->visible);
+ if ($this->isColumnModified(ContentVersionTableMap::POSITION)) $criteria->add(ContentVersionTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(ContentVersionTableMap::CREATED_AT)) $criteria->add(ContentVersionTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ContentVersionTableMap::UPDATED_AT)) $criteria->add(ContentVersionTableMap::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(ContentVersionTableMap::VERSION)) $criteria->add(ContentVersionTableMap::VERSION, $this->version);
+ if ($this->isColumnModified(ContentVersionTableMap::VERSION_CREATED_AT)) $criteria->add(ContentVersionTableMap::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(ContentVersionTableMap::VERSION_CREATED_BY)) $criteria->add(ContentVersionTableMap::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(ContentVersionTableMap::DATABASE_NAME);
+ $criteria->add(ContentVersionTableMap::ID, $this->id);
+ $criteria->add(ContentVersionTableMap::VERSION, $this->version);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getVersion();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setVersion($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getVersion());
+ }
+
+ /**
+ * 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 \Thelia\Model\ContentVersion (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\ContentVersion 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildContent object.
+ *
+ * @param ChildContent $v
+ * @return \Thelia\Model\ContentVersion The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setContent(ChildContent $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aContent = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildContent object, it will not be re-added.
+ if ($v !== null) {
+ $v->addContentVersion($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildContent object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildContent The associated ChildContent object.
+ * @throws PropelException
+ */
+ public function getContent(ConnectionInterface $con = null)
+ {
+ if ($this->aContent === null && ($this->id !== null)) {
+ $this->aContent = ChildContentQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aContent->addContentVersions($this);
+ */
+ }
+
+ return $this->aContent;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->visible = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aContent = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ContentVersionTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ContentVersionQuery.php b/core/lib/Thelia/Model/Base/ContentVersionQuery.php
new file mode 100644
index 000000000..ae737d96e
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ContentVersionQuery.php
@@ -0,0 +1,751 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $version] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildContentVersion|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ContentVersionTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ContentVersionTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildContentVersion A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM content_version WHERE ID = :p0 AND VERSION = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildContentVersion();
+ $obj->hydrate($row);
+ ContentVersionTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildContentVersion|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildContentVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(ContentVersionTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(ContentVersionTableMap::VERSION, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildContentVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(ContentVersionTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(ContentVersionTableMap::VERSION, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByContent()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentVersionQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ContentVersionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ContentVersionTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentVersionTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the visible column
+ *
+ * Example usage:
+ *
+ * $query->filterByVisible(1234); // WHERE visible = 1234
+ * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
+ * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
+ *
+ *
+ * @param mixed $visible The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentVersionQuery The current query, for fluid interface
+ */
+ public function filterByVisible($visible = null, $comparison = null)
+ {
+ if (is_array($visible)) {
+ $useMinMax = false;
+ if (isset($visible['min'])) {
+ $this->addUsingAlias(ContentVersionTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(ContentVersionTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentVersionTableMap::VISIBLE, $visible, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentVersionQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(ContentVersionTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(ContentVersionTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentVersionTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentVersionQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ContentVersionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ContentVersionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentVersionTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentVersionQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ContentVersionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ContentVersionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentVersionTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(ContentVersionTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(ContentVersionTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentVersionTableMap::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(ContentVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(ContentVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ContentVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ContentVersionTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Content object
+ *
+ * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildContentVersionQuery The current query, for fluid interface
+ */
+ public function filterByContent($content, $comparison = null)
+ {
+ if ($content instanceof \Thelia\Model\Content) {
+ return $this
+ ->addUsingAlias(ContentVersionTableMap::ID, $content->getId(), $comparison);
+ } elseif ($content instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ContentVersionTableMap::ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Content relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildContentVersionQuery The current query, for fluid interface
+ */
+ public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Content');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Content');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Content relation Content object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query
+ */
+ public function useContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinContent($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildContentVersion $contentVersion Object to remove from the list of results
+ *
+ * @return ChildContentVersionQuery The current query, for fluid interface
+ */
+ public function prune($contentVersion = null)
+ {
+ if ($contentVersion) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(ContentVersionTableMap::ID), $contentVersion->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(ContentVersionTableMap::VERSION), $contentVersion->getVersion(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the content_version table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentVersionTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ContentVersionTableMap::clearInstancePool();
+ ContentVersionTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildContentVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildContentVersion object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentVersionTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ContentVersionTableMap::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->beginTransaction();
+
+
+ ContentVersionTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ContentVersionTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // ContentVersionQuery
diff --git a/core/lib/Thelia/Model/Base/Country.php b/core/lib/Thelia/Model/Base/Country.php
new file mode 100644
index 000000000..c59c3585e
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Country.php
@@ -0,0 +1,2359 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Country instance. If
+ * obj is an instance of Country, delegates to
+ * equals(Country). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Country The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Country The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [area_id] column value.
+ *
+ * @return int
+ */
+ public function getAreaId()
+ {
+
+ return $this->area_id;
+ }
+
+ /**
+ * Get the [isocode] column value.
+ *
+ * @return string
+ */
+ public function getIsocode()
+ {
+
+ return $this->isocode;
+ }
+
+ /**
+ * Get the [isoalpha2] column value.
+ *
+ * @return string
+ */
+ public function getIsoalpha2()
+ {
+
+ return $this->isoalpha2;
+ }
+
+ /**
+ * Get the [isoalpha3] column value.
+ *
+ * @return string
+ */
+ public function getIsoalpha3()
+ {
+
+ return $this->isoalpha3;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Country The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CountryTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [area_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Country The current object (for fluent API support)
+ */
+ public function setAreaId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->area_id !== $v) {
+ $this->area_id = $v;
+ $this->modifiedColumns[] = CountryTableMap::AREA_ID;
+ }
+
+ if ($this->aArea !== null && $this->aArea->getId() !== $v) {
+ $this->aArea = null;
+ }
+
+
+ return $this;
+ } // setAreaId()
+
+ /**
+ * Set the value of [isocode] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Country The current object (for fluent API support)
+ */
+ public function setIsocode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->isocode !== $v) {
+ $this->isocode = $v;
+ $this->modifiedColumns[] = CountryTableMap::ISOCODE;
+ }
+
+
+ return $this;
+ } // setIsocode()
+
+ /**
+ * Set the value of [isoalpha2] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Country The current object (for fluent API support)
+ */
+ public function setIsoalpha2($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->isoalpha2 !== $v) {
+ $this->isoalpha2 = $v;
+ $this->modifiedColumns[] = CountryTableMap::ISOALPHA2;
+ }
+
+
+ return $this;
+ } // setIsoalpha2()
+
+ /**
+ * Set the value of [isoalpha3] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Country The current object (for fluent API support)
+ */
+ public function setIsoalpha3($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->isoalpha3 !== $v) {
+ $this->isoalpha3 = $v;
+ $this->modifiedColumns[] = CountryTableMap::ISOALPHA3;
+ }
+
+
+ return $this;
+ } // setIsoalpha3()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Country The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = CountryTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Country The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = CountryTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CountryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CountryTableMap::translateFieldName('AreaId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->area_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CountryTableMap::translateFieldName('Isocode', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->isocode = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CountryTableMap::translateFieldName('Isoalpha2', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->isoalpha2 = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CountryTableMap::translateFieldName('Isoalpha3', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->isoalpha3 = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CountryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CountryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = CountryTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Country object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aArea !== null && $this->area_id !== $this->aArea->getId()) {
+ $this->aArea = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CountryTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCountryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aArea = null;
+ $this->collTaxRuleCountries = null;
+
+ $this->collCountryI18ns = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Country::setDeleted()
+ * @see Country::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CountryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCountryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CountryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CountryTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CountryTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CountryTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CountryTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aArea !== null) {
+ if ($this->aArea->isModified() || $this->aArea->isNew()) {
+ $affectedRows += $this->aArea->save($con);
+ }
+ $this->setArea($this->aArea);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->taxRuleCountriesScheduledForDeletion !== null) {
+ if (!$this->taxRuleCountriesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\TaxRuleCountryQuery::create()
+ ->filterByPrimaryKeys($this->taxRuleCountriesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->taxRuleCountriesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collTaxRuleCountries !== null) {
+ foreach ($this->collTaxRuleCountries as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->countryI18nsScheduledForDeletion !== null) {
+ if (!$this->countryI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\CountryI18nQuery::create()
+ ->filterByPrimaryKeys($this->countryI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->countryI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCountryI18ns !== null) {
+ foreach ($this->collCountryI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CountryTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CountryTableMap::AREA_ID)) {
+ $modifiedColumns[':p' . $index++] = 'AREA_ID';
+ }
+ if ($this->isColumnModified(CountryTableMap::ISOCODE)) {
+ $modifiedColumns[':p' . $index++] = 'ISOCODE';
+ }
+ if ($this->isColumnModified(CountryTableMap::ISOALPHA2)) {
+ $modifiedColumns[':p' . $index++] = 'ISOALPHA2';
+ }
+ if ($this->isColumnModified(CountryTableMap::ISOALPHA3)) {
+ $modifiedColumns[':p' . $index++] = 'ISOALPHA3';
+ }
+ if ($this->isColumnModified(CountryTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CountryTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO country (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'AREA_ID':
+ $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT);
+ break;
+ case 'ISOCODE':
+ $stmt->bindValue($identifier, $this->isocode, PDO::PARAM_STR);
+ break;
+ case 'ISOALPHA2':
+ $stmt->bindValue($identifier, $this->isoalpha2, PDO::PARAM_STR);
+ break;
+ case 'ISOALPHA3':
+ $stmt->bindValue($identifier, $this->isoalpha3, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CountryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getAreaId();
+ break;
+ case 2:
+ return $this->getIsocode();
+ break;
+ case 3:
+ return $this->getIsoalpha2();
+ break;
+ case 4:
+ return $this->getIsoalpha3();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Country'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Country'][$this->getPrimaryKey()] = true;
+ $keys = CountryTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getAreaId(),
+ $keys[2] => $this->getIsocode(),
+ $keys[3] => $this->getIsoalpha2(),
+ $keys[4] => $this->getIsoalpha3(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aArea) {
+ $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collTaxRuleCountries) {
+ $result['TaxRuleCountries'] = $this->collTaxRuleCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCountryI18ns) {
+ $result['CountryI18ns'] = $this->collCountryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CountryTableMap::translateFieldName($name, $type, TableMap::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->setAreaId($value);
+ break;
+ case 2:
+ $this->setIsocode($value);
+ break;
+ case 3:
+ $this->setIsoalpha2($value);
+ break;
+ case 4:
+ $this->setIsoalpha3($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CountryTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setAreaId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setIsocode($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setIsoalpha2($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setIsoalpha3($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * 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(CountryTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CountryTableMap::ID)) $criteria->add(CountryTableMap::ID, $this->id);
+ if ($this->isColumnModified(CountryTableMap::AREA_ID)) $criteria->add(CountryTableMap::AREA_ID, $this->area_id);
+ if ($this->isColumnModified(CountryTableMap::ISOCODE)) $criteria->add(CountryTableMap::ISOCODE, $this->isocode);
+ if ($this->isColumnModified(CountryTableMap::ISOALPHA2)) $criteria->add(CountryTableMap::ISOALPHA2, $this->isoalpha2);
+ if ($this->isColumnModified(CountryTableMap::ISOALPHA3)) $criteria->add(CountryTableMap::ISOALPHA3, $this->isoalpha3);
+ if ($this->isColumnModified(CountryTableMap::CREATED_AT)) $criteria->add(CountryTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CountryTableMap::UPDATED_AT)) $criteria->add(CountryTableMap::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(CountryTableMap::DATABASE_NAME);
+ $criteria->add(CountryTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Country (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setAreaId($this->getAreaId());
+ $copyObj->setIsocode($this->getIsocode());
+ $copyObj->setIsoalpha2($this->getIsoalpha2());
+ $copyObj->setIsoalpha3($this->getIsoalpha3());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getTaxRuleCountries() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addTaxRuleCountry($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getCountryI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCountryI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\Country 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildArea object.
+ *
+ * @param ChildArea $v
+ * @return \Thelia\Model\Country The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setArea(ChildArea $v = null)
+ {
+ if ($v === null) {
+ $this->setAreaId(NULL);
+ } else {
+ $this->setAreaId($v->getId());
+ }
+
+ $this->aArea = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildArea object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCountry($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildArea object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildArea The associated ChildArea object.
+ * @throws PropelException
+ */
+ public function getArea(ConnectionInterface $con = null)
+ {
+ if ($this->aArea === null && ($this->area_id !== null)) {
+ $this->aArea = ChildAreaQuery::create()->findPk($this->area_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aArea->addCountries($this);
+ */
+ }
+
+ return $this->aArea;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('TaxRuleCountry' == $relationName) {
+ return $this->initTaxRuleCountries();
+ }
+ if ('CountryI18n' == $relationName) {
+ return $this->initCountryI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collTaxRuleCountries collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addTaxRuleCountries()
+ */
+ public function clearTaxRuleCountries()
+ {
+ $this->collTaxRuleCountries = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collTaxRuleCountries collection loaded partially.
+ */
+ public function resetPartialTaxRuleCountries($v = true)
+ {
+ $this->collTaxRuleCountriesPartial = $v;
+ }
+
+ /**
+ * Initializes the collTaxRuleCountries collection.
+ *
+ * By default this just sets the collTaxRuleCountries collection to an empty array (like clearcollTaxRuleCountries());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initTaxRuleCountries($overrideExisting = true)
+ {
+ if (null !== $this->collTaxRuleCountries && !$overrideExisting) {
+ return;
+ }
+ $this->collTaxRuleCountries = new ObjectCollection();
+ $this->collTaxRuleCountries->setModel('\Thelia\Model\TaxRuleCountry');
+ }
+
+ /**
+ * Gets an array of ChildTaxRuleCountry objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCountry is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects
+ * @throws PropelException
+ */
+ public function getTaxRuleCountries($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collTaxRuleCountriesPartial && !$this->isNew();
+ if (null === $this->collTaxRuleCountries || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleCountries) {
+ // return empty collection
+ $this->initTaxRuleCountries();
+ } else {
+ $collTaxRuleCountries = ChildTaxRuleCountryQuery::create(null, $criteria)
+ ->filterByCountry($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collTaxRuleCountriesPartial && count($collTaxRuleCountries)) {
+ $this->initTaxRuleCountries(false);
+
+ foreach ($collTaxRuleCountries as $obj) {
+ if (false == $this->collTaxRuleCountries->contains($obj)) {
+ $this->collTaxRuleCountries->append($obj);
+ }
+ }
+
+ $this->collTaxRuleCountriesPartial = true;
+ }
+
+ $collTaxRuleCountries->getInternalIterator()->rewind();
+
+ return $collTaxRuleCountries;
+ }
+
+ if ($partial && $this->collTaxRuleCountries) {
+ foreach ($this->collTaxRuleCountries as $obj) {
+ if ($obj->isNew()) {
+ $collTaxRuleCountries[] = $obj;
+ }
+ }
+ }
+
+ $this->collTaxRuleCountries = $collTaxRuleCountries;
+ $this->collTaxRuleCountriesPartial = false;
+ }
+ }
+
+ return $this->collTaxRuleCountries;
+ }
+
+ /**
+ * Sets a collection of TaxRuleCountry objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $taxRuleCountries A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCountry The current object (for fluent API support)
+ */
+ public function setTaxRuleCountries(Collection $taxRuleCountries, ConnectionInterface $con = null)
+ {
+ $taxRuleCountriesToDelete = $this->getTaxRuleCountries(new Criteria(), $con)->diff($taxRuleCountries);
+
+
+ $this->taxRuleCountriesScheduledForDeletion = $taxRuleCountriesToDelete;
+
+ foreach ($taxRuleCountriesToDelete as $taxRuleCountryRemoved) {
+ $taxRuleCountryRemoved->setCountry(null);
+ }
+
+ $this->collTaxRuleCountries = null;
+ foreach ($taxRuleCountries as $taxRuleCountry) {
+ $this->addTaxRuleCountry($taxRuleCountry);
+ }
+
+ $this->collTaxRuleCountries = $taxRuleCountries;
+ $this->collTaxRuleCountriesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related TaxRuleCountry objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related TaxRuleCountry objects.
+ * @throws PropelException
+ */
+ public function countTaxRuleCountries(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collTaxRuleCountriesPartial && !$this->isNew();
+ if (null === $this->collTaxRuleCountries || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleCountries) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getTaxRuleCountries());
+ }
+
+ $query = ChildTaxRuleCountryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCountry($this)
+ ->count($con);
+ }
+
+ return count($this->collTaxRuleCountries);
+ }
+
+ /**
+ * Method called to associate a ChildTaxRuleCountry object to this object
+ * through the ChildTaxRuleCountry foreign key attribute.
+ *
+ * @param ChildTaxRuleCountry $l ChildTaxRuleCountry
+ * @return \Thelia\Model\Country The current object (for fluent API support)
+ */
+ public function addTaxRuleCountry(ChildTaxRuleCountry $l)
+ {
+ if ($this->collTaxRuleCountries === null) {
+ $this->initTaxRuleCountries();
+ $this->collTaxRuleCountriesPartial = true;
+ }
+
+ if (!in_array($l, $this->collTaxRuleCountries->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddTaxRuleCountry($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add.
+ */
+ protected function doAddTaxRuleCountry($taxRuleCountry)
+ {
+ $this->collTaxRuleCountries[]= $taxRuleCountry;
+ $taxRuleCountry->setCountry($this);
+ }
+
+ /**
+ * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove.
+ * @return ChildCountry The current object (for fluent API support)
+ */
+ public function removeTaxRuleCountry($taxRuleCountry)
+ {
+ if ($this->getTaxRuleCountries()->contains($taxRuleCountry)) {
+ $this->collTaxRuleCountries->remove($this->collTaxRuleCountries->search($taxRuleCountry));
+ if (null === $this->taxRuleCountriesScheduledForDeletion) {
+ $this->taxRuleCountriesScheduledForDeletion = clone $this->collTaxRuleCountries;
+ $this->taxRuleCountriesScheduledForDeletion->clear();
+ }
+ $this->taxRuleCountriesScheduledForDeletion[]= $taxRuleCountry;
+ $taxRuleCountry->setCountry(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Country is new, it will return
+ * an empty collection; or if this Country has previously
+ * been saved, it will retrieve related TaxRuleCountries 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 Country.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects
+ */
+ public function getTaxRuleCountriesJoinTax($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildTaxRuleCountryQuery::create(null, $criteria);
+ $query->joinWith('Tax', $joinBehavior);
+
+ return $this->getTaxRuleCountries($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Country is new, it will return
+ * an empty collection; or if this Country has previously
+ * been saved, it will retrieve related TaxRuleCountries 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 Country.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects
+ */
+ public function getTaxRuleCountriesJoinTaxRule($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildTaxRuleCountryQuery::create(null, $criteria);
+ $query->joinWith('TaxRule', $joinBehavior);
+
+ return $this->getTaxRuleCountries($query, $con);
+ }
+
+ /**
+ * Clears out the collCountryI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCountryI18ns()
+ */
+ public function clearCountryI18ns()
+ {
+ $this->collCountryI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCountryI18ns collection loaded partially.
+ */
+ public function resetPartialCountryI18ns($v = true)
+ {
+ $this->collCountryI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collCountryI18ns collection.
+ *
+ * By default this just sets the collCountryI18ns collection to an empty array (like clearcollCountryI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCountryI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collCountryI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collCountryI18ns = new ObjectCollection();
+ $this->collCountryI18ns->setModel('\Thelia\Model\CountryI18n');
+ }
+
+ /**
+ * Gets an array of ChildCountryI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCountry is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCountryI18n[] List of ChildCountryI18n objects
+ * @throws PropelException
+ */
+ public function getCountryI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCountryI18nsPartial && !$this->isNew();
+ if (null === $this->collCountryI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCountryI18ns) {
+ // return empty collection
+ $this->initCountryI18ns();
+ } else {
+ $collCountryI18ns = ChildCountryI18nQuery::create(null, $criteria)
+ ->filterByCountry($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCountryI18nsPartial && count($collCountryI18ns)) {
+ $this->initCountryI18ns(false);
+
+ foreach ($collCountryI18ns as $obj) {
+ if (false == $this->collCountryI18ns->contains($obj)) {
+ $this->collCountryI18ns->append($obj);
+ }
+ }
+
+ $this->collCountryI18nsPartial = true;
+ }
+
+ $collCountryI18ns->getInternalIterator()->rewind();
+
+ return $collCountryI18ns;
+ }
+
+ if ($partial && $this->collCountryI18ns) {
+ foreach ($this->collCountryI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collCountryI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collCountryI18ns = $collCountryI18ns;
+ $this->collCountryI18nsPartial = false;
+ }
+ }
+
+ return $this->collCountryI18ns;
+ }
+
+ /**
+ * Sets a collection of CountryI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $countryI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCountry The current object (for fluent API support)
+ */
+ public function setCountryI18ns(Collection $countryI18ns, ConnectionInterface $con = null)
+ {
+ $countryI18nsToDelete = $this->getCountryI18ns(new Criteria(), $con)->diff($countryI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->countryI18nsScheduledForDeletion = clone $countryI18nsToDelete;
+
+ foreach ($countryI18nsToDelete as $countryI18nRemoved) {
+ $countryI18nRemoved->setCountry(null);
+ }
+
+ $this->collCountryI18ns = null;
+ foreach ($countryI18ns as $countryI18n) {
+ $this->addCountryI18n($countryI18n);
+ }
+
+ $this->collCountryI18ns = $countryI18ns;
+ $this->collCountryI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CountryI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CountryI18n objects.
+ * @throws PropelException
+ */
+ public function countCountryI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCountryI18nsPartial && !$this->isNew();
+ if (null === $this->collCountryI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCountryI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCountryI18ns());
+ }
+
+ $query = ChildCountryI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCountry($this)
+ ->count($con);
+ }
+
+ return count($this->collCountryI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildCountryI18n object to this object
+ * through the ChildCountryI18n foreign key attribute.
+ *
+ * @param ChildCountryI18n $l ChildCountryI18n
+ * @return \Thelia\Model\Country The current object (for fluent API support)
+ */
+ public function addCountryI18n(ChildCountryI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collCountryI18ns === null) {
+ $this->initCountryI18ns();
+ $this->collCountryI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collCountryI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCountryI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CountryI18n $countryI18n The countryI18n object to add.
+ */
+ protected function doAddCountryI18n($countryI18n)
+ {
+ $this->collCountryI18ns[]= $countryI18n;
+ $countryI18n->setCountry($this);
+ }
+
+ /**
+ * @param CountryI18n $countryI18n The countryI18n object to remove.
+ * @return ChildCountry The current object (for fluent API support)
+ */
+ public function removeCountryI18n($countryI18n)
+ {
+ if ($this->getCountryI18ns()->contains($countryI18n)) {
+ $this->collCountryI18ns->remove($this->collCountryI18ns->search($countryI18n));
+ if (null === $this->countryI18nsScheduledForDeletion) {
+ $this->countryI18nsScheduledForDeletion = clone $this->collCountryI18ns;
+ $this->countryI18nsScheduledForDeletion->clear();
+ }
+ $this->countryI18nsScheduledForDeletion[]= clone $countryI18n;
+ $countryI18n->setCountry(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->area_id = null;
+ $this->isocode = null;
+ $this->isoalpha2 = null;
+ $this->isoalpha3 = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collTaxRuleCountries) {
+ foreach ($this->collTaxRuleCountries as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCountryI18ns) {
+ foreach ($this->collCountryI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collTaxRuleCountries instanceof Collection) {
+ $this->collTaxRuleCountries->clearIterator();
+ }
+ $this->collTaxRuleCountries = null;
+ if ($this->collCountryI18ns instanceof Collection) {
+ $this->collCountryI18ns->clearIterator();
+ }
+ $this->collCountryI18ns = null;
+ $this->aArea = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CountryTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCountry The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = CountryTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildCountry The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCountryI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collCountryI18ns) {
+ foreach ($this->collCountryI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildCountryI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildCountryI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addCountryI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCountry The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildCountryI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collCountryI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collCountryI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCountryI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CountryI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CountryI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CountryI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CountryI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/CountryI18n.php b/core/lib/Thelia/Model/Base/CountryI18n.php
new file mode 100644
index 000000000..270a9d3f7
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CountryI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\CountryI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CountryI18n instance. If
+ * obj is an instance of CountryI18n, delegates to
+ * equals(CountryI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CountryI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CountryI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\CountryI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CountryI18nTableMap::ID;
+ }
+
+ if ($this->aCountry !== null && $this->aCountry->getId() !== $v) {
+ $this->aCountry = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CountryI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = CountryI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CountryI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = CountryI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CountryI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = CountryI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CountryI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = CountryI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CountryI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = CountryI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CountryI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CountryI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CountryI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CountryI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CountryI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CountryI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = CountryI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\CountryI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCountry !== null && $this->id !== $this->aCountry->getId()) {
+ $this->aCountry = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CountryI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCountryI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCountry = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CountryI18n::setDeleted()
+ * @see CountryI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CountryI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCountryI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CountryI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CountryI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCountry !== null) {
+ if ($this->aCountry->isModified() || $this->aCountry->isNew()) {
+ $affectedRows += $this->aCountry->save($con);
+ }
+ $this->setCountry($this->aCountry);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CountryI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CountryI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(CountryI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(CountryI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(CountryI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(CountryI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO country_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CountryI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CountryI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CountryI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = CountryI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCountry) {
+ $result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CountryI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CountryI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(CountryI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CountryI18nTableMap::ID)) $criteria->add(CountryI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(CountryI18nTableMap::LOCALE)) $criteria->add(CountryI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(CountryI18nTableMap::TITLE)) $criteria->add(CountryI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(CountryI18nTableMap::DESCRIPTION)) $criteria->add(CountryI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(CountryI18nTableMap::CHAPO)) $criteria->add(CountryI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(CountryI18nTableMap::POSTSCRIPTUM)) $criteria->add(CountryI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(CountryI18nTableMap::DATABASE_NAME);
+ $criteria->add(CountryI18nTableMap::ID, $this->id);
+ $criteria->add(CountryI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\CountryI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\CountryI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCountry object.
+ *
+ * @param ChildCountry $v
+ * @return \Thelia\Model\CountryI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCountry(ChildCountry $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aCountry = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCountry object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCountryI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCountry object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCountry The associated ChildCountry object.
+ * @throws PropelException
+ */
+ public function getCountry(ConnectionInterface $con = null)
+ {
+ if ($this->aCountry === null && ($this->id !== null)) {
+ $this->aCountry = ChildCountryQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCountry->addCountryI18ns($this);
+ */
+ }
+
+ return $this->aCountry;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCountry = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CountryI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/CountryI18nQuery.php b/core/lib/Thelia/Model/Base/CountryI18nQuery.php
new file mode 100644
index 000000000..924ed263a
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CountryI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCountryI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CountryI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CountryI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCountryI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM country_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildCountryI18n();
+ $obj->hydrate($row);
+ CountryI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCountryI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCountryI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(CountryI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(CountryI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCountryI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(CountryI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(CountryI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByCountry()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CountryI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CountryI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CountryI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Country object
+ *
+ * @param \Thelia\Model\Country|ObjectCollection $country The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryI18nQuery The current query, for fluid interface
+ */
+ public function filterByCountry($country, $comparison = null)
+ {
+ if ($country instanceof \Thelia\Model\Country) {
+ return $this
+ ->addUsingAlias(CountryI18nTableMap::ID, $country->getId(), $comparison);
+ } elseif ($country instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CountryI18nTableMap::ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCountry() only accepts arguments of type \Thelia\Model\Country or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Country relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCountryI18nQuery The current query, for fluid interface
+ */
+ public function joinCountry($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Country');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Country');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Country relation Country object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CountryQuery A secondary query class using the current class as primary query
+ */
+ public function useCountryQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinCountry($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCountryI18n $countryI18n Object to remove from the list of results
+ *
+ * @return ChildCountryI18nQuery The current query, for fluid interface
+ */
+ public function prune($countryI18n = null)
+ {
+ if ($countryI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(CountryI18nTableMap::ID), $countryI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(CountryI18nTableMap::LOCALE), $countryI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the country_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CountryI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CountryI18nTableMap::clearInstancePool();
+ CountryI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCountryI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCountryI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CountryI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CountryI18nTableMap::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->beginTransaction();
+
+
+ CountryI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CountryI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // CountryI18nQuery
diff --git a/core/lib/Thelia/Model/Base/CountryQuery.php b/core/lib/Thelia/Model/Base/CountryQuery.php
new file mode 100644
index 000000000..1b5c02209
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CountryQuery.php
@@ -0,0 +1,944 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCountry|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CountryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CountryTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCountry A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, AREA_ID, ISOCODE, ISOALPHA2, ISOALPHA3, CREATED_AT, UPDATED_AT FROM country WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildCountry();
+ $obj->hydrate($row);
+ CountryTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCountry|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CountryTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CountryTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CountryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CountryTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CountryTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the area_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAreaId(1234); // WHERE area_id = 1234
+ * $query->filterByAreaId(array(12, 34)); // WHERE area_id IN (12, 34)
+ * $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12
+ *
+ *
+ * @see filterByArea()
+ *
+ * @param mixed $areaId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function filterByAreaId($areaId = null, $comparison = null)
+ {
+ if (is_array($areaId)) {
+ $useMinMax = false;
+ if (isset($areaId['min'])) {
+ $this->addUsingAlias(CountryTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($areaId['max'])) {
+ $this->addUsingAlias(CountryTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CountryTableMap::AREA_ID, $areaId, $comparison);
+ }
+
+ /**
+ * Filter the query on the isocode column
+ *
+ * Example usage:
+ *
+ * $query->filterByIsocode('fooValue'); // WHERE isocode = 'fooValue'
+ * $query->filterByIsocode('%fooValue%'); // WHERE isocode LIKE '%fooValue%'
+ *
+ *
+ * @param string $isocode The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function filterByIsocode($isocode = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($isocode)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $isocode)) {
+ $isocode = str_replace('*', '%', $isocode);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryTableMap::ISOCODE, $isocode, $comparison);
+ }
+
+ /**
+ * Filter the query on the isoalpha2 column
+ *
+ * Example usage:
+ *
+ * $query->filterByIsoalpha2('fooValue'); // WHERE isoalpha2 = 'fooValue'
+ * $query->filterByIsoalpha2('%fooValue%'); // WHERE isoalpha2 LIKE '%fooValue%'
+ *
+ *
+ * @param string $isoalpha2 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function filterByIsoalpha2($isoalpha2 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($isoalpha2)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $isoalpha2)) {
+ $isoalpha2 = str_replace('*', '%', $isoalpha2);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryTableMap::ISOALPHA2, $isoalpha2, $comparison);
+ }
+
+ /**
+ * Filter the query on the isoalpha3 column
+ *
+ * Example usage:
+ *
+ * $query->filterByIsoalpha3('fooValue'); // WHERE isoalpha3 = 'fooValue'
+ * $query->filterByIsoalpha3('%fooValue%'); // WHERE isoalpha3 LIKE '%fooValue%'
+ *
+ *
+ * @param string $isoalpha3 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function filterByIsoalpha3($isoalpha3 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($isoalpha3)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $isoalpha3)) {
+ $isoalpha3 = str_replace('*', '%', $isoalpha3);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CountryTableMap::ISOALPHA3, $isoalpha3, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CountryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CountryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CountryTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CountryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CountryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CountryTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Area object
+ *
+ * @param \Thelia\Model\Area|ObjectCollection $area The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function filterByArea($area, $comparison = null)
+ {
+ if ($area instanceof \Thelia\Model\Area) {
+ return $this
+ ->addUsingAlias(CountryTableMap::AREA_ID, $area->getId(), $comparison);
+ } elseif ($area instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CountryTableMap::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByArea() only accepts arguments of type \Thelia\Model\Area or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Area relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function joinArea($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Area');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Area');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Area relation Area object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AreaQuery A secondary query class using the current class as primary query
+ */
+ public function useAreaQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinArea($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Area', '\Thelia\Model\AreaQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\TaxRuleCountry object
+ *
+ * @param \Thelia\Model\TaxRuleCountry|ObjectCollection $taxRuleCountry the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null)
+ {
+ if ($taxRuleCountry instanceof \Thelia\Model\TaxRuleCountry) {
+ return $this
+ ->addUsingAlias(CountryTableMap::ID, $taxRuleCountry->getCountryId(), $comparison);
+ } elseif ($taxRuleCountry instanceof ObjectCollection) {
+ return $this
+ ->useTaxRuleCountryQuery()
+ ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type \Thelia\Model\TaxRuleCountry or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxRuleCountry relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxRuleCountry');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'TaxRuleCountry');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxRuleCountry relation TaxRuleCountry object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinTaxRuleCountry($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxRuleCountry', '\Thelia\Model\TaxRuleCountryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\CountryI18n object
+ *
+ * @param \Thelia\Model\CountryI18n|ObjectCollection $countryI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function filterByCountryI18n($countryI18n, $comparison = null)
+ {
+ if ($countryI18n instanceof \Thelia\Model\CountryI18n) {
+ return $this
+ ->addUsingAlias(CountryTableMap::ID, $countryI18n->getId(), $comparison);
+ } elseif ($countryI18n instanceof ObjectCollection) {
+ return $this
+ ->useCountryI18nQuery()
+ ->filterByPrimaryKeys($countryI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCountryI18n() only accepts arguments of type \Thelia\Model\CountryI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CountryI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function joinCountryI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CountryI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'CountryI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CountryI18n relation CountryI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CountryI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useCountryI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinCountryI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CountryI18n', '\Thelia\Model\CountryI18nQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCountry $country Object to remove from the list of results
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function prune($country = null)
+ {
+ if ($country) {
+ $this->addUsingAlias(CountryTableMap::ID, $country->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the country table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CountryTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CountryTableMap::clearInstancePool();
+ CountryTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCountry or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCountry object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CountryTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CountryTableMap::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->beginTransaction();
+
+
+ CountryTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CountryTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CountryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CountryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CountryTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CountryTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CountryTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CountryTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'CountryI18n';
+
+ return $this
+ ->joinCountryI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCountryQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('CountryI18n');
+ $this->with['CountryI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCountryI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CountryI18n', '\Thelia\Model\CountryI18nQuery');
+ }
+
+} // CountryQuery
diff --git a/core/lib/Thelia/Model/Base/Coupon.php b/core/lib/Thelia/Model/Base/Coupon.php
new file mode 100644
index 000000000..2c3dae5c9
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Coupon.php
@@ -0,0 +1,1944 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Coupon instance. If
+ * obj is an instance of Coupon, delegates to
+ * equals(Coupon). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Coupon The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Coupon The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * Get the [action] column value.
+ *
+ * @return string
+ */
+ public function getAction()
+ {
+
+ return $this->action;
+ }
+
+ /**
+ * Get the [value] column value.
+ *
+ * @return double
+ */
+ public function getValue()
+ {
+
+ return $this->value;
+ }
+
+ /**
+ * Get the [used] column value.
+ *
+ * @return int
+ */
+ public function getUsed()
+ {
+
+ return $this->used;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [available_since] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getAvailableSince($format = NULL)
+ {
+ if ($format === null) {
+ return $this->available_since;
+ } else {
+ return $this->available_since !== null ? $this->available_since->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [date_limit] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getDateLimit($format = NULL)
+ {
+ if ($format === null) {
+ return $this->date_limit;
+ } else {
+ return $this->date_limit !== null ? $this->date_limit->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [activate] column value.
+ *
+ * @return int
+ */
+ public function getActivate()
+ {
+
+ return $this->activate;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Coupon The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CouponTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Coupon The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = CouponTableMap::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [action] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Coupon The current object (for fluent API support)
+ */
+ public function setAction($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->action !== $v) {
+ $this->action = $v;
+ $this->modifiedColumns[] = CouponTableMap::ACTION;
+ }
+
+
+ return $this;
+ } // setAction()
+
+ /**
+ * Set the value of [value] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\Coupon The current object (for fluent API support)
+ */
+ public function setValue($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->value !== $v) {
+ $this->value = $v;
+ $this->modifiedColumns[] = CouponTableMap::VALUE;
+ }
+
+
+ return $this;
+ } // setValue()
+
+ /**
+ * Set the value of [used] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Coupon The current object (for fluent API support)
+ */
+ public function setUsed($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->used !== $v) {
+ $this->used = $v;
+ $this->modifiedColumns[] = CouponTableMap::USED;
+ }
+
+
+ return $this;
+ } // setUsed()
+
+ /**
+ * Sets the value of [available_since] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Coupon The current object (for fluent API support)
+ */
+ public function setAvailableSince($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->available_since !== null || $dt !== null) {
+ if ($dt !== $this->available_since) {
+ $this->available_since = $dt;
+ $this->modifiedColumns[] = CouponTableMap::AVAILABLE_SINCE;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setAvailableSince()
+
+ /**
+ * Sets the value of [date_limit] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Coupon The current object (for fluent API support)
+ */
+ public function setDateLimit($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->date_limit !== null || $dt !== null) {
+ if ($dt !== $this->date_limit) {
+ $this->date_limit = $dt;
+ $this->modifiedColumns[] = CouponTableMap::DATE_LIMIT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setDateLimit()
+
+ /**
+ * Set the value of [activate] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Coupon The current object (for fluent API support)
+ */
+ public function setActivate($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->activate !== $v) {
+ $this->activate = $v;
+ $this->modifiedColumns[] = CouponTableMap::ACTIVATE;
+ }
+
+
+ return $this;
+ } // setActivate()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Coupon The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = CouponTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Coupon The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = CouponTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CouponTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CouponTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->code = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CouponTableMap::translateFieldName('Action', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->action = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->value = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponTableMap::translateFieldName('Used', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->used = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponTableMap::translateFieldName('AvailableSince', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->available_since = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponTableMap::translateFieldName('DateLimit', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->date_limit = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponTableMap::translateFieldName('Activate', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->activate = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 10; // 10 = CouponTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Coupon object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CouponTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCouponQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collCouponRules = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Coupon::setDeleted()
+ * @see Coupon::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCouponQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CouponTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CouponTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CouponTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CouponTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->couponRulesScheduledForDeletion !== null) {
+ if (!$this->couponRulesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\CouponRuleQuery::create()
+ ->filterByPrimaryKeys($this->couponRulesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->couponRulesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCouponRules !== null) {
+ foreach ($this->collCouponRules as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CouponTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CouponTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CouponTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CouponTableMap::CODE)) {
+ $modifiedColumns[':p' . $index++] = 'CODE';
+ }
+ if ($this->isColumnModified(CouponTableMap::ACTION)) {
+ $modifiedColumns[':p' . $index++] = 'ACTION';
+ }
+ if ($this->isColumnModified(CouponTableMap::VALUE)) {
+ $modifiedColumns[':p' . $index++] = 'VALUE';
+ }
+ if ($this->isColumnModified(CouponTableMap::USED)) {
+ $modifiedColumns[':p' . $index++] = 'USED';
+ }
+ if ($this->isColumnModified(CouponTableMap::AVAILABLE_SINCE)) {
+ $modifiedColumns[':p' . $index++] = 'AVAILABLE_SINCE';
+ }
+ if ($this->isColumnModified(CouponTableMap::DATE_LIMIT)) {
+ $modifiedColumns[':p' . $index++] = 'DATE_LIMIT';
+ }
+ if ($this->isColumnModified(CouponTableMap::ACTIVATE)) {
+ $modifiedColumns[':p' . $index++] = 'ACTIVATE';
+ }
+ if ($this->isColumnModified(CouponTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CouponTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO coupon (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'CODE':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case 'ACTION':
+ $stmt->bindValue($identifier, $this->action, PDO::PARAM_STR);
+ break;
+ case 'VALUE':
+ $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
+ break;
+ case 'USED':
+ $stmt->bindValue($identifier, $this->used, PDO::PARAM_INT);
+ break;
+ case 'AVAILABLE_SINCE':
+ $stmt->bindValue($identifier, $this->available_since ? $this->available_since->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'DATE_LIMIT':
+ $stmt->bindValue($identifier, $this->date_limit ? $this->date_limit->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'ACTIVATE':
+ $stmt->bindValue($identifier, $this->activate, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CouponTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getCode();
+ break;
+ case 2:
+ return $this->getAction();
+ break;
+ case 3:
+ return $this->getValue();
+ break;
+ case 4:
+ return $this->getUsed();
+ break;
+ case 5:
+ return $this->getAvailableSince();
+ break;
+ case 6:
+ return $this->getDateLimit();
+ break;
+ case 7:
+ return $this->getActivate();
+ break;
+ case 8:
+ return $this->getCreatedAt();
+ break;
+ case 9:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Coupon'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Coupon'][$this->getPrimaryKey()] = true;
+ $keys = CouponTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getAction(),
+ $keys[3] => $this->getValue(),
+ $keys[4] => $this->getUsed(),
+ $keys[5] => $this->getAvailableSince(),
+ $keys[6] => $this->getDateLimit(),
+ $keys[7] => $this->getActivate(),
+ $keys[8] => $this->getCreatedAt(),
+ $keys[9] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collCouponRules) {
+ $result['CouponRules'] = $this->collCouponRules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CouponTableMap::translateFieldName($name, $type, TableMap::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->setCode($value);
+ break;
+ case 2:
+ $this->setAction($value);
+ break;
+ case 3:
+ $this->setValue($value);
+ break;
+ case 4:
+ $this->setUsed($value);
+ break;
+ case 5:
+ $this->setAvailableSince($value);
+ break;
+ case 6:
+ $this->setDateLimit($value);
+ break;
+ case 7:
+ $this->setActivate($value);
+ break;
+ case 8:
+ $this->setCreatedAt($value);
+ break;
+ case 9:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CouponTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setAction($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setValue($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUsed($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setAvailableSince($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setDateLimit($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setActivate($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]);
+ }
+
+ /**
+ * 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(CouponTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CouponTableMap::ID)) $criteria->add(CouponTableMap::ID, $this->id);
+ if ($this->isColumnModified(CouponTableMap::CODE)) $criteria->add(CouponTableMap::CODE, $this->code);
+ if ($this->isColumnModified(CouponTableMap::ACTION)) $criteria->add(CouponTableMap::ACTION, $this->action);
+ if ($this->isColumnModified(CouponTableMap::VALUE)) $criteria->add(CouponTableMap::VALUE, $this->value);
+ if ($this->isColumnModified(CouponTableMap::USED)) $criteria->add(CouponTableMap::USED, $this->used);
+ if ($this->isColumnModified(CouponTableMap::AVAILABLE_SINCE)) $criteria->add(CouponTableMap::AVAILABLE_SINCE, $this->available_since);
+ if ($this->isColumnModified(CouponTableMap::DATE_LIMIT)) $criteria->add(CouponTableMap::DATE_LIMIT, $this->date_limit);
+ if ($this->isColumnModified(CouponTableMap::ACTIVATE)) $criteria->add(CouponTableMap::ACTIVATE, $this->activate);
+ if ($this->isColumnModified(CouponTableMap::CREATED_AT)) $criteria->add(CouponTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CouponTableMap::UPDATED_AT)) $criteria->add(CouponTableMap::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(CouponTableMap::DATABASE_NAME);
+ $criteria->add(CouponTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Coupon (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setAction($this->getAction());
+ $copyObj->setValue($this->getValue());
+ $copyObj->setUsed($this->getUsed());
+ $copyObj->setAvailableSince($this->getAvailableSince());
+ $copyObj->setDateLimit($this->getDateLimit());
+ $copyObj->setActivate($this->getActivate());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getCouponRules() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCouponRule($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Coupon 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('CouponRule' == $relationName) {
+ return $this->initCouponRules();
+ }
+ }
+
+ /**
+ * Clears out the collCouponRules collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCouponRules()
+ */
+ public function clearCouponRules()
+ {
+ $this->collCouponRules = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCouponRules collection loaded partially.
+ */
+ public function resetPartialCouponRules($v = true)
+ {
+ $this->collCouponRulesPartial = $v;
+ }
+
+ /**
+ * Initializes the collCouponRules collection.
+ *
+ * By default this just sets the collCouponRules collection to an empty array (like clearcollCouponRules());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCouponRules($overrideExisting = true)
+ {
+ if (null !== $this->collCouponRules && !$overrideExisting) {
+ return;
+ }
+ $this->collCouponRules = new ObjectCollection();
+ $this->collCouponRules->setModel('\Thelia\Model\CouponRule');
+ }
+
+ /**
+ * Gets an array of ChildCouponRule objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCoupon is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCouponRule[] List of ChildCouponRule objects
+ * @throws PropelException
+ */
+ public function getCouponRules($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCouponRulesPartial && !$this->isNew();
+ if (null === $this->collCouponRules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCouponRules) {
+ // return empty collection
+ $this->initCouponRules();
+ } else {
+ $collCouponRules = ChildCouponRuleQuery::create(null, $criteria)
+ ->filterByCoupon($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCouponRulesPartial && count($collCouponRules)) {
+ $this->initCouponRules(false);
+
+ foreach ($collCouponRules as $obj) {
+ if (false == $this->collCouponRules->contains($obj)) {
+ $this->collCouponRules->append($obj);
+ }
+ }
+
+ $this->collCouponRulesPartial = true;
+ }
+
+ $collCouponRules->getInternalIterator()->rewind();
+
+ return $collCouponRules;
+ }
+
+ if ($partial && $this->collCouponRules) {
+ foreach ($this->collCouponRules as $obj) {
+ if ($obj->isNew()) {
+ $collCouponRules[] = $obj;
+ }
+ }
+ }
+
+ $this->collCouponRules = $collCouponRules;
+ $this->collCouponRulesPartial = false;
+ }
+ }
+
+ return $this->collCouponRules;
+ }
+
+ /**
+ * Sets a collection of CouponRule objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $couponRules A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCoupon The current object (for fluent API support)
+ */
+ public function setCouponRules(Collection $couponRules, ConnectionInterface $con = null)
+ {
+ $couponRulesToDelete = $this->getCouponRules(new Criteria(), $con)->diff($couponRules);
+
+
+ $this->couponRulesScheduledForDeletion = $couponRulesToDelete;
+
+ foreach ($couponRulesToDelete as $couponRuleRemoved) {
+ $couponRuleRemoved->setCoupon(null);
+ }
+
+ $this->collCouponRules = null;
+ foreach ($couponRules as $couponRule) {
+ $this->addCouponRule($couponRule);
+ }
+
+ $this->collCouponRules = $couponRules;
+ $this->collCouponRulesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CouponRule objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CouponRule objects.
+ * @throws PropelException
+ */
+ public function countCouponRules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCouponRulesPartial && !$this->isNew();
+ if (null === $this->collCouponRules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCouponRules) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCouponRules());
+ }
+
+ $query = ChildCouponRuleQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCoupon($this)
+ ->count($con);
+ }
+
+ return count($this->collCouponRules);
+ }
+
+ /**
+ * Method called to associate a ChildCouponRule object to this object
+ * through the ChildCouponRule foreign key attribute.
+ *
+ * @param ChildCouponRule $l ChildCouponRule
+ * @return \Thelia\Model\Coupon The current object (for fluent API support)
+ */
+ public function addCouponRule(ChildCouponRule $l)
+ {
+ if ($this->collCouponRules === null) {
+ $this->initCouponRules();
+ $this->collCouponRulesPartial = true;
+ }
+
+ if (!in_array($l, $this->collCouponRules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCouponRule($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CouponRule $couponRule The couponRule object to add.
+ */
+ protected function doAddCouponRule($couponRule)
+ {
+ $this->collCouponRules[]= $couponRule;
+ $couponRule->setCoupon($this);
+ }
+
+ /**
+ * @param CouponRule $couponRule The couponRule object to remove.
+ * @return ChildCoupon The current object (for fluent API support)
+ */
+ public function removeCouponRule($couponRule)
+ {
+ if ($this->getCouponRules()->contains($couponRule)) {
+ $this->collCouponRules->remove($this->collCouponRules->search($couponRule));
+ if (null === $this->couponRulesScheduledForDeletion) {
+ $this->couponRulesScheduledForDeletion = clone $this->collCouponRules;
+ $this->couponRulesScheduledForDeletion->clear();
+ }
+ $this->couponRulesScheduledForDeletion[]= clone $couponRule;
+ $couponRule->setCoupon(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->action = null;
+ $this->value = null;
+ $this->used = null;
+ $this->available_since = null;
+ $this->date_limit = null;
+ $this->activate = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collCouponRules) {
+ foreach ($this->collCouponRules as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collCouponRules instanceof Collection) {
+ $this->collCouponRules->clearIterator();
+ }
+ $this->collCouponRules = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CouponTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCoupon The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = CouponTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/CouponOrder.php b/core/lib/Thelia/Model/Base/CouponOrder.php
new file mode 100644
index 000000000..32ae68fde
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CouponOrder.php
@@ -0,0 +1,1476 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CouponOrder instance. If
+ * obj is an instance of CouponOrder, delegates to
+ * equals(CouponOrder). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CouponOrder The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CouponOrder The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [order_id] column value.
+ *
+ * @return int
+ */
+ public function getOrderId()
+ {
+
+ return $this->order_id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * Get the [value] column value.
+ *
+ * @return double
+ */
+ public function getValue()
+ {
+
+ return $this->value;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\CouponOrder The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CouponOrderTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [order_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\CouponOrder The current object (for fluent API support)
+ */
+ public function setOrderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->order_id !== $v) {
+ $this->order_id = $v;
+ $this->modifiedColumns[] = CouponOrderTableMap::ORDER_ID;
+ }
+
+ if ($this->aOrder !== null && $this->aOrder->getId() !== $v) {
+ $this->aOrder = null;
+ }
+
+
+ return $this;
+ } // setOrderId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CouponOrder The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = CouponOrderTableMap::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [value] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\CouponOrder The current object (for fluent API support)
+ */
+ public function setValue($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->value !== $v) {
+ $this->value = $v;
+ $this->modifiedColumns[] = CouponOrderTableMap::VALUE;
+ }
+
+
+ return $this;
+ } // setValue()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\CouponOrder The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = CouponOrderTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\CouponOrder The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = CouponOrderTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CouponOrderTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CouponOrderTableMap::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->order_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CouponOrderTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->code = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponOrderTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->value = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponOrderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponOrderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = CouponOrderTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\CouponOrder object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) {
+ $this->aOrder = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CouponOrderTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCouponOrderQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aOrder = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CouponOrder::setDeleted()
+ * @see CouponOrder::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCouponOrderQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CouponOrderTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CouponOrderTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CouponOrderTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CouponOrderTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aOrder !== null) {
+ if ($this->aOrder->isModified() || $this->aOrder->isNew()) {
+ $affectedRows += $this->aOrder->save($con);
+ }
+ $this->setOrder($this->aOrder);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CouponOrderTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CouponOrderTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CouponOrderTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CouponOrderTableMap::ORDER_ID)) {
+ $modifiedColumns[':p' . $index++] = 'ORDER_ID';
+ }
+ if ($this->isColumnModified(CouponOrderTableMap::CODE)) {
+ $modifiedColumns[':p' . $index++] = 'CODE';
+ }
+ if ($this->isColumnModified(CouponOrderTableMap::VALUE)) {
+ $modifiedColumns[':p' . $index++] = 'VALUE';
+ }
+ if ($this->isColumnModified(CouponOrderTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CouponOrderTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO coupon_order (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'ORDER_ID':
+ $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT);
+ break;
+ case 'CODE':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case 'VALUE':
+ $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CouponOrderTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getOrderId();
+ break;
+ case 2:
+ return $this->getCode();
+ break;
+ case 3:
+ return $this->getValue();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CouponOrder'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CouponOrder'][$this->getPrimaryKey()] = true;
+ $keys = CouponOrderTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getOrderId(),
+ $keys[2] => $this->getCode(),
+ $keys[3] => $this->getValue(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aOrder) {
+ $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CouponOrderTableMap::translateFieldName($name, $type, TableMap::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->setOrderId($value);
+ break;
+ case 2:
+ $this->setCode($value);
+ break;
+ case 3:
+ $this->setValue($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CouponOrderTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setOrderId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCode($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setValue($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(CouponOrderTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CouponOrderTableMap::ID)) $criteria->add(CouponOrderTableMap::ID, $this->id);
+ if ($this->isColumnModified(CouponOrderTableMap::ORDER_ID)) $criteria->add(CouponOrderTableMap::ORDER_ID, $this->order_id);
+ if ($this->isColumnModified(CouponOrderTableMap::CODE)) $criteria->add(CouponOrderTableMap::CODE, $this->code);
+ if ($this->isColumnModified(CouponOrderTableMap::VALUE)) $criteria->add(CouponOrderTableMap::VALUE, $this->value);
+ if ($this->isColumnModified(CouponOrderTableMap::CREATED_AT)) $criteria->add(CouponOrderTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CouponOrderTableMap::UPDATED_AT)) $criteria->add(CouponOrderTableMap::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(CouponOrderTableMap::DATABASE_NAME);
+ $criteria->add(CouponOrderTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\CouponOrder (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setOrderId($this->getOrderId());
+ $copyObj->setCode($this->getCode());
+ $copyObj->setValue($this->getValue());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\CouponOrder 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildOrder object.
+ *
+ * @param ChildOrder $v
+ * @return \Thelia\Model\CouponOrder The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrder(ChildOrder $v = null)
+ {
+ if ($v === null) {
+ $this->setOrderId(NULL);
+ } else {
+ $this->setOrderId($v->getId());
+ }
+
+ $this->aOrder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildOrder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCouponOrder($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildOrder object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildOrder The associated ChildOrder object.
+ * @throws PropelException
+ */
+ public function getOrder(ConnectionInterface $con = null)
+ {
+ if ($this->aOrder === null && ($this->order_id !== null)) {
+ $this->aOrder = ChildOrderQuery::create()->findPk($this->order_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aOrder->addCouponOrders($this);
+ */
+ }
+
+ return $this->aOrder;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->order_id = null;
+ $this->code = null;
+ $this->value = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aOrder = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CouponOrderTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCouponOrder The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = CouponOrderTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/CouponOrderQuery.php b/core/lib/Thelia/Model/Base/CouponOrderQuery.php
new file mode 100644
index 000000000..6897f56dd
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CouponOrderQuery.php
@@ -0,0 +1,711 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCouponOrder|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CouponOrderTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CouponOrderTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCouponOrder A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, ORDER_ID, CODE, VALUE, CREATED_AT, UPDATED_AT FROM coupon_order WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildCouponOrder();
+ $obj->hydrate($row);
+ CouponOrderTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCouponOrder|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CouponOrderTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CouponOrderTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CouponOrderTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CouponOrderTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponOrderTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the order_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByOrderId(1234); // WHERE order_id = 1234
+ * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34)
+ * $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12
+ *
+ *
+ * @see filterByOrder()
+ *
+ * @param mixed $orderId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByOrderId($orderId = null, $comparison = null)
+ {
+ if (is_array($orderId)) {
+ $useMinMax = false;
+ if (isset($orderId['min'])) {
+ $this->addUsingAlias(CouponOrderTableMap::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($orderId['max'])) {
+ $this->addUsingAlias(CouponOrderTableMap::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponOrderTableMap::ORDER_ID, $orderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CouponOrderTableMap::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the value column
+ *
+ * Example usage:
+ *
+ * $query->filterByValue(1234); // WHERE value = 1234
+ * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34)
+ * $query->filterByValue(array('min' => 12)); // WHERE value > 12
+ *
+ *
+ * @param mixed $value The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByValue($value = null, $comparison = null)
+ {
+ if (is_array($value)) {
+ $useMinMax = false;
+ if (isset($value['min'])) {
+ $this->addUsingAlias(CouponOrderTableMap::VALUE, $value['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($value['max'])) {
+ $this->addUsingAlias(CouponOrderTableMap::VALUE, $value['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponOrderTableMap::VALUE, $value, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CouponOrderTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CouponOrderTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponOrderTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CouponOrderTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CouponOrderTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponOrderTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Order object
+ *
+ * @param \Thelia\Model\Order|ObjectCollection $order The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function filterByOrder($order, $comparison = null)
+ {
+ if ($order instanceof \Thelia\Model\Order) {
+ return $this
+ ->addUsingAlias(CouponOrderTableMap::ORDER_ID, $order->getId(), $comparison);
+ } elseif ($order instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CouponOrderTableMap::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Order relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Order');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Order');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Order relation Order object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCouponOrder $couponOrder Object to remove from the list of results
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function prune($couponOrder = null)
+ {
+ if ($couponOrder) {
+ $this->addUsingAlias(CouponOrderTableMap::ID, $couponOrder->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the coupon_order table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CouponOrderTableMap::clearInstancePool();
+ CouponOrderTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCouponOrder or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCouponOrder object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CouponOrderTableMap::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->beginTransaction();
+
+
+ CouponOrderTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CouponOrderTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CouponOrderTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CouponOrderTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CouponOrderTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CouponOrderTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CouponOrderTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCouponOrderQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CouponOrderTableMap::CREATED_AT);
+ }
+
+} // CouponOrderQuery
diff --git a/core/lib/Thelia/Model/Base/CouponQuery.php b/core/lib/Thelia/Model/Base/CouponQuery.php
new file mode 100644
index 000000000..23fdd2e4c
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CouponQuery.php
@@ -0,0 +1,879 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCoupon|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CouponTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CouponTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCoupon A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CODE, ACTION, VALUE, USED, AVAILABLE_SINCE, DATE_LIMIT, ACTIVATE, CREATED_AT, UPDATED_AT FROM coupon WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildCoupon();
+ $obj->hydrate($row);
+ CouponTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCoupon|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CouponTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CouponTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CouponTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CouponTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CouponTableMap::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the action column
+ *
+ * Example usage:
+ *
+ * $query->filterByAction('fooValue'); // WHERE action = 'fooValue'
+ * $query->filterByAction('%fooValue%'); // WHERE action LIKE '%fooValue%'
+ *
+ *
+ * @param string $action The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByAction($action = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($action)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $action)) {
+ $action = str_replace('*', '%', $action);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CouponTableMap::ACTION, $action, $comparison);
+ }
+
+ /**
+ * Filter the query on the value column
+ *
+ * Example usage:
+ *
+ * $query->filterByValue(1234); // WHERE value = 1234
+ * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34)
+ * $query->filterByValue(array('min' => 12)); // WHERE value > 12
+ *
+ *
+ * @param mixed $value The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByValue($value = null, $comparison = null)
+ {
+ if (is_array($value)) {
+ $useMinMax = false;
+ if (isset($value['min'])) {
+ $this->addUsingAlias(CouponTableMap::VALUE, $value['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($value['max'])) {
+ $this->addUsingAlias(CouponTableMap::VALUE, $value['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponTableMap::VALUE, $value, $comparison);
+ }
+
+ /**
+ * Filter the query on the used column
+ *
+ * Example usage:
+ *
+ * $query->filterByUsed(1234); // WHERE used = 1234
+ * $query->filterByUsed(array(12, 34)); // WHERE used IN (12, 34)
+ * $query->filterByUsed(array('min' => 12)); // WHERE used > 12
+ *
+ *
+ * @param mixed $used The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByUsed($used = null, $comparison = null)
+ {
+ if (is_array($used)) {
+ $useMinMax = false;
+ if (isset($used['min'])) {
+ $this->addUsingAlias(CouponTableMap::USED, $used['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($used['max'])) {
+ $this->addUsingAlias(CouponTableMap::USED, $used['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponTableMap::USED, $used, $comparison);
+ }
+
+ /**
+ * Filter the query on the available_since column
+ *
+ * Example usage:
+ *
+ * $query->filterByAvailableSince('2011-03-14'); // WHERE available_since = '2011-03-14'
+ * $query->filterByAvailableSince('now'); // WHERE available_since = '2011-03-14'
+ * $query->filterByAvailableSince(array('max' => 'yesterday')); // WHERE available_since > '2011-03-13'
+ *
+ *
+ * @param mixed $availableSince The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByAvailableSince($availableSince = null, $comparison = null)
+ {
+ if (is_array($availableSince)) {
+ $useMinMax = false;
+ if (isset($availableSince['min'])) {
+ $this->addUsingAlias(CouponTableMap::AVAILABLE_SINCE, $availableSince['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($availableSince['max'])) {
+ $this->addUsingAlias(CouponTableMap::AVAILABLE_SINCE, $availableSince['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponTableMap::AVAILABLE_SINCE, $availableSince, $comparison);
+ }
+
+ /**
+ * Filter the query on the date_limit column
+ *
+ * Example usage:
+ *
+ * $query->filterByDateLimit('2011-03-14'); // WHERE date_limit = '2011-03-14'
+ * $query->filterByDateLimit('now'); // WHERE date_limit = '2011-03-14'
+ * $query->filterByDateLimit(array('max' => 'yesterday')); // WHERE date_limit > '2011-03-13'
+ *
+ *
+ * @param mixed $dateLimit The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByDateLimit($dateLimit = null, $comparison = null)
+ {
+ if (is_array($dateLimit)) {
+ $useMinMax = false;
+ if (isset($dateLimit['min'])) {
+ $this->addUsingAlias(CouponTableMap::DATE_LIMIT, $dateLimit['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($dateLimit['max'])) {
+ $this->addUsingAlias(CouponTableMap::DATE_LIMIT, $dateLimit['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponTableMap::DATE_LIMIT, $dateLimit, $comparison);
+ }
+
+ /**
+ * Filter the query on the activate column
+ *
+ * Example usage:
+ *
+ * $query->filterByActivate(1234); // WHERE activate = 1234
+ * $query->filterByActivate(array(12, 34)); // WHERE activate IN (12, 34)
+ * $query->filterByActivate(array('min' => 12)); // WHERE activate > 12
+ *
+ *
+ * @param mixed $activate The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByActivate($activate = null, $comparison = null)
+ {
+ if (is_array($activate)) {
+ $useMinMax = false;
+ if (isset($activate['min'])) {
+ $this->addUsingAlias(CouponTableMap::ACTIVATE, $activate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($activate['max'])) {
+ $this->addUsingAlias(CouponTableMap::ACTIVATE, $activate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponTableMap::ACTIVATE, $activate, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CouponTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CouponTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CouponTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CouponTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\CouponRule object
+ *
+ * @param \Thelia\Model\CouponRule|ObjectCollection $couponRule the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function filterByCouponRule($couponRule, $comparison = null)
+ {
+ if ($couponRule instanceof \Thelia\Model\CouponRule) {
+ return $this
+ ->addUsingAlias(CouponTableMap::ID, $couponRule->getCouponId(), $comparison);
+ } elseif ($couponRule instanceof ObjectCollection) {
+ return $this
+ ->useCouponRuleQuery()
+ ->filterByPrimaryKeys($couponRule->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCouponRule() only accepts arguments of type \Thelia\Model\CouponRule or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CouponRule relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function joinCouponRule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CouponRule');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'CouponRule');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CouponRule relation CouponRule object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CouponRuleQuery A secondary query class using the current class as primary query
+ */
+ public function useCouponRuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCouponRule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CouponRule', '\Thelia\Model\CouponRuleQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCoupon $coupon Object to remove from the list of results
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function prune($coupon = null)
+ {
+ if ($coupon) {
+ $this->addUsingAlias(CouponTableMap::ID, $coupon->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the coupon table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CouponTableMap::clearInstancePool();
+ CouponTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCoupon or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCoupon object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CouponTableMap::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->beginTransaction();
+
+
+ CouponTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CouponTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CouponTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CouponTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CouponTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CouponTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CouponTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCouponQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CouponTableMap::CREATED_AT);
+ }
+
+} // CouponQuery
diff --git a/core/lib/Thelia/Model/Base/CouponRule.php b/core/lib/Thelia/Model/Base/CouponRule.php
new file mode 100644
index 000000000..5602b0044
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CouponRule.php
@@ -0,0 +1,1534 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CouponRule instance. If
+ * obj is an instance of CouponRule, delegates to
+ * equals(CouponRule). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CouponRule The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CouponRule The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [coupon_id] column value.
+ *
+ * @return int
+ */
+ public function getCouponId()
+ {
+
+ return $this->coupon_id;
+ }
+
+ /**
+ * Get the [controller] column value.
+ *
+ * @return string
+ */
+ public function getController()
+ {
+
+ return $this->controller;
+ }
+
+ /**
+ * Get the [operation] column value.
+ *
+ * @return string
+ */
+ public function getOperation()
+ {
+
+ return $this->operation;
+ }
+
+ /**
+ * Get the [value] column value.
+ *
+ * @return double
+ */
+ public function getValue()
+ {
+
+ return $this->value;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\CouponRule The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CouponRuleTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [coupon_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\CouponRule The current object (for fluent API support)
+ */
+ public function setCouponId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->coupon_id !== $v) {
+ $this->coupon_id = $v;
+ $this->modifiedColumns[] = CouponRuleTableMap::COUPON_ID;
+ }
+
+ if ($this->aCoupon !== null && $this->aCoupon->getId() !== $v) {
+ $this->aCoupon = null;
+ }
+
+
+ return $this;
+ } // setCouponId()
+
+ /**
+ * Set the value of [controller] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CouponRule The current object (for fluent API support)
+ */
+ public function setController($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->controller !== $v) {
+ $this->controller = $v;
+ $this->modifiedColumns[] = CouponRuleTableMap::CONTROLLER;
+ }
+
+
+ return $this;
+ } // setController()
+
+ /**
+ * Set the value of [operation] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CouponRule The current object (for fluent API support)
+ */
+ public function setOperation($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->operation !== $v) {
+ $this->operation = $v;
+ $this->modifiedColumns[] = CouponRuleTableMap::OPERATION;
+ }
+
+
+ return $this;
+ } // setOperation()
+
+ /**
+ * Set the value of [value] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\CouponRule The current object (for fluent API support)
+ */
+ public function setValue($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->value !== $v) {
+ $this->value = $v;
+ $this->modifiedColumns[] = CouponRuleTableMap::VALUE;
+ }
+
+
+ return $this;
+ } // setValue()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\CouponRule The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = CouponRuleTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\CouponRule The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = CouponRuleTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CouponRuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CouponRuleTableMap::translateFieldName('CouponId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->coupon_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CouponRuleTableMap::translateFieldName('Controller', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->controller = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponRuleTableMap::translateFieldName('Operation', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->operation = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponRuleTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->value = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponRuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponRuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = CouponRuleTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\CouponRule object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCoupon !== null && $this->coupon_id !== $this->aCoupon->getId()) {
+ $this->aCoupon = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CouponRuleTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCouponRuleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCoupon = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CouponRule::setDeleted()
+ * @see CouponRule::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponRuleTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCouponRuleQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponRuleTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CouponRuleTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CouponRuleTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CouponRuleTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CouponRuleTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCoupon !== null) {
+ if ($this->aCoupon->isModified() || $this->aCoupon->isNew()) {
+ $affectedRows += $this->aCoupon->save($con);
+ }
+ $this->setCoupon($this->aCoupon);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CouponRuleTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CouponRuleTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CouponRuleTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CouponRuleTableMap::COUPON_ID)) {
+ $modifiedColumns[':p' . $index++] = 'COUPON_ID';
+ }
+ if ($this->isColumnModified(CouponRuleTableMap::CONTROLLER)) {
+ $modifiedColumns[':p' . $index++] = 'CONTROLLER';
+ }
+ if ($this->isColumnModified(CouponRuleTableMap::OPERATION)) {
+ $modifiedColumns[':p' . $index++] = 'OPERATION';
+ }
+ if ($this->isColumnModified(CouponRuleTableMap::VALUE)) {
+ $modifiedColumns[':p' . $index++] = 'VALUE';
+ }
+ if ($this->isColumnModified(CouponRuleTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CouponRuleTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO coupon_rule (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'COUPON_ID':
+ $stmt->bindValue($identifier, $this->coupon_id, PDO::PARAM_INT);
+ break;
+ case 'CONTROLLER':
+ $stmt->bindValue($identifier, $this->controller, PDO::PARAM_STR);
+ break;
+ case 'OPERATION':
+ $stmt->bindValue($identifier, $this->operation, PDO::PARAM_STR);
+ break;
+ case 'VALUE':
+ $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CouponRuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getCouponId();
+ break;
+ case 2:
+ return $this->getController();
+ break;
+ case 3:
+ return $this->getOperation();
+ break;
+ case 4:
+ return $this->getValue();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CouponRule'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CouponRule'][$this->getPrimaryKey()] = true;
+ $keys = CouponRuleTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCouponId(),
+ $keys[2] => $this->getController(),
+ $keys[3] => $this->getOperation(),
+ $keys[4] => $this->getValue(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCoupon) {
+ $result['Coupon'] = $this->aCoupon->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CouponRuleTableMap::translateFieldName($name, $type, TableMap::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->setCouponId($value);
+ break;
+ case 2:
+ $this->setController($value);
+ break;
+ case 3:
+ $this->setOperation($value);
+ break;
+ case 4:
+ $this->setValue($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CouponRuleTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCouponId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setController($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setOperation($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setValue($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * 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(CouponRuleTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CouponRuleTableMap::ID)) $criteria->add(CouponRuleTableMap::ID, $this->id);
+ if ($this->isColumnModified(CouponRuleTableMap::COUPON_ID)) $criteria->add(CouponRuleTableMap::COUPON_ID, $this->coupon_id);
+ if ($this->isColumnModified(CouponRuleTableMap::CONTROLLER)) $criteria->add(CouponRuleTableMap::CONTROLLER, $this->controller);
+ if ($this->isColumnModified(CouponRuleTableMap::OPERATION)) $criteria->add(CouponRuleTableMap::OPERATION, $this->operation);
+ if ($this->isColumnModified(CouponRuleTableMap::VALUE)) $criteria->add(CouponRuleTableMap::VALUE, $this->value);
+ if ($this->isColumnModified(CouponRuleTableMap::CREATED_AT)) $criteria->add(CouponRuleTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CouponRuleTableMap::UPDATED_AT)) $criteria->add(CouponRuleTableMap::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(CouponRuleTableMap::DATABASE_NAME);
+ $criteria->add(CouponRuleTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\CouponRule (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCouponId($this->getCouponId());
+ $copyObj->setController($this->getController());
+ $copyObj->setOperation($this->getOperation());
+ $copyObj->setValue($this->getValue());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\CouponRule 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCoupon object.
+ *
+ * @param ChildCoupon $v
+ * @return \Thelia\Model\CouponRule The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCoupon(ChildCoupon $v = null)
+ {
+ if ($v === null) {
+ $this->setCouponId(NULL);
+ } else {
+ $this->setCouponId($v->getId());
+ }
+
+ $this->aCoupon = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCoupon object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCouponRule($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCoupon object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCoupon The associated ChildCoupon object.
+ * @throws PropelException
+ */
+ public function getCoupon(ConnectionInterface $con = null)
+ {
+ if ($this->aCoupon === null && ($this->coupon_id !== null)) {
+ $this->aCoupon = ChildCouponQuery::create()->findPk($this->coupon_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCoupon->addCouponRules($this);
+ */
+ }
+
+ return $this->aCoupon;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->coupon_id = null;
+ $this->controller = null;
+ $this->operation = null;
+ $this->value = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCoupon = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CouponRuleTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCouponRule The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = CouponRuleTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/CouponRuleQuery.php b/core/lib/Thelia/Model/Base/CouponRuleQuery.php
new file mode 100644
index 000000000..0789f84d6
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CouponRuleQuery.php
@@ -0,0 +1,744 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCouponRule|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CouponRuleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CouponRuleTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCouponRule A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, COUPON_ID, CONTROLLER, OPERATION, VALUE, CREATED_AT, UPDATED_AT FROM coupon_rule WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildCouponRule();
+ $obj->hydrate($row);
+ CouponRuleTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCouponRule|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CouponRuleTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CouponRuleTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CouponRuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CouponRuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponRuleTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the coupon_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCouponId(1234); // WHERE coupon_id = 1234
+ * $query->filterByCouponId(array(12, 34)); // WHERE coupon_id IN (12, 34)
+ * $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id > 12
+ *
+ *
+ * @see filterByCoupon()
+ *
+ * @param mixed $couponId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByCouponId($couponId = null, $comparison = null)
+ {
+ if (is_array($couponId)) {
+ $useMinMax = false;
+ if (isset($couponId['min'])) {
+ $this->addUsingAlias(CouponRuleTableMap::COUPON_ID, $couponId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($couponId['max'])) {
+ $this->addUsingAlias(CouponRuleTableMap::COUPON_ID, $couponId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponRuleTableMap::COUPON_ID, $couponId, $comparison);
+ }
+
+ /**
+ * Filter the query on the controller column
+ *
+ * Example usage:
+ *
+ * $query->filterByController('fooValue'); // WHERE controller = 'fooValue'
+ * $query->filterByController('%fooValue%'); // WHERE controller LIKE '%fooValue%'
+ *
+ *
+ * @param string $controller The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByController($controller = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($controller)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $controller)) {
+ $controller = str_replace('*', '%', $controller);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CouponRuleTableMap::CONTROLLER, $controller, $comparison);
+ }
+
+ /**
+ * Filter the query on the operation column
+ *
+ * Example usage:
+ *
+ * $query->filterByOperation('fooValue'); // WHERE operation = 'fooValue'
+ * $query->filterByOperation('%fooValue%'); // WHERE operation LIKE '%fooValue%'
+ *
+ *
+ * @param string $operation The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByOperation($operation = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($operation)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $operation)) {
+ $operation = str_replace('*', '%', $operation);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CouponRuleTableMap::OPERATION, $operation, $comparison);
+ }
+
+ /**
+ * Filter the query on the value column
+ *
+ * Example usage:
+ *
+ * $query->filterByValue(1234); // WHERE value = 1234
+ * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34)
+ * $query->filterByValue(array('min' => 12)); // WHERE value > 12
+ *
+ *
+ * @param mixed $value The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByValue($value = null, $comparison = null)
+ {
+ if (is_array($value)) {
+ $useMinMax = false;
+ if (isset($value['min'])) {
+ $this->addUsingAlias(CouponRuleTableMap::VALUE, $value['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($value['max'])) {
+ $this->addUsingAlias(CouponRuleTableMap::VALUE, $value['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponRuleTableMap::VALUE, $value, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CouponRuleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CouponRuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponRuleTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CouponRuleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CouponRuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CouponRuleTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Coupon object
+ *
+ * @param \Thelia\Model\Coupon|ObjectCollection $coupon The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function filterByCoupon($coupon, $comparison = null)
+ {
+ if ($coupon instanceof \Thelia\Model\Coupon) {
+ return $this
+ ->addUsingAlias(CouponRuleTableMap::COUPON_ID, $coupon->getId(), $comparison);
+ } elseif ($coupon instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CouponRuleTableMap::COUPON_ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCoupon() only accepts arguments of type \Thelia\Model\Coupon or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Coupon relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function joinCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Coupon');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Coupon');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Coupon relation Coupon object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CouponQuery A secondary query class using the current class as primary query
+ */
+ public function useCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCoupon($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Coupon', '\Thelia\Model\CouponQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCouponRule $couponRule Object to remove from the list of results
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function prune($couponRule = null)
+ {
+ if ($couponRule) {
+ $this->addUsingAlias(CouponRuleTableMap::ID, $couponRule->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the coupon_rule table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponRuleTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CouponRuleTableMap::clearInstancePool();
+ CouponRuleTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCouponRule or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCouponRule object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponRuleTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CouponRuleTableMap::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->beginTransaction();
+
+
+ CouponRuleTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CouponRuleTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CouponRuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CouponRuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CouponRuleTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CouponRuleTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CouponRuleTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCouponRuleQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CouponRuleTableMap::CREATED_AT);
+ }
+
+} // CouponRuleQuery
diff --git a/core/lib/Thelia/Model/Base/Currency.php b/core/lib/Thelia/Model/Base/Currency.php
new file mode 100644
index 000000000..5edf0b8e1
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Currency.php
@@ -0,0 +1,1905 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Currency instance. If
+ * obj is an instance of Currency, delegates to
+ * equals(Currency). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Currency The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Currency The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [name] column value.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+
+ return $this->name;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * Get the [symbol] column value.
+ *
+ * @return string
+ */
+ public function getSymbol()
+ {
+
+ return $this->symbol;
+ }
+
+ /**
+ * Get the [rate] column value.
+ *
+ * @return double
+ */
+ public function getRate()
+ {
+
+ return $this->rate;
+ }
+
+ /**
+ * Get the [by_default] column value.
+ *
+ * @return int
+ */
+ public function getByDefault()
+ {
+
+ return $this->by_default;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Currency The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CurrencyTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [name] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Currency The current object (for fluent API support)
+ */
+ public function setName($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->name !== $v) {
+ $this->name = $v;
+ $this->modifiedColumns[] = CurrencyTableMap::NAME;
+ }
+
+
+ return $this;
+ } // setName()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Currency The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = CurrencyTableMap::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [symbol] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Currency The current object (for fluent API support)
+ */
+ public function setSymbol($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->symbol !== $v) {
+ $this->symbol = $v;
+ $this->modifiedColumns[] = CurrencyTableMap::SYMBOL;
+ }
+
+
+ return $this;
+ } // setSymbol()
+
+ /**
+ * Set the value of [rate] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\Currency The current object (for fluent API support)
+ */
+ public function setRate($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->rate !== $v) {
+ $this->rate = $v;
+ $this->modifiedColumns[] = CurrencyTableMap::RATE;
+ }
+
+
+ return $this;
+ } // setRate()
+
+ /**
+ * Set the value of [by_default] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Currency The current object (for fluent API support)
+ */
+ public function setByDefault($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->by_default !== $v) {
+ $this->by_default = $v;
+ $this->modifiedColumns[] = CurrencyTableMap::BY_DEFAULT;
+ }
+
+
+ return $this;
+ } // setByDefault()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Currency The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = CurrencyTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Currency The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = CurrencyTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CurrencyTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CurrencyTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->name = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CurrencyTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->code = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CurrencyTableMap::translateFieldName('Symbol', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->symbol = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CurrencyTableMap::translateFieldName('Rate', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->rate = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CurrencyTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->by_default = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CurrencyTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CurrencyTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = CurrencyTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Currency object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CurrencyTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCurrencyQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collOrders = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Currency::setDeleted()
+ * @see Currency::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CurrencyTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCurrencyQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CurrencyTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CurrencyTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CurrencyTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CurrencyTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CurrencyTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->ordersScheduledForDeletion !== null) {
+ if (!$this->ordersScheduledForDeletion->isEmpty()) {
+ foreach ($this->ordersScheduledForDeletion as $order) {
+ // need to save related object because we set the relation to null
+ $order->save($con);
+ }
+ $this->ordersScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrders !== null) {
+ foreach ($this->collOrders as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CurrencyTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CurrencyTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CurrencyTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CurrencyTableMap::NAME)) {
+ $modifiedColumns[':p' . $index++] = 'NAME';
+ }
+ if ($this->isColumnModified(CurrencyTableMap::CODE)) {
+ $modifiedColumns[':p' . $index++] = 'CODE';
+ }
+ if ($this->isColumnModified(CurrencyTableMap::SYMBOL)) {
+ $modifiedColumns[':p' . $index++] = 'SYMBOL';
+ }
+ if ($this->isColumnModified(CurrencyTableMap::RATE)) {
+ $modifiedColumns[':p' . $index++] = 'RATE';
+ }
+ if ($this->isColumnModified(CurrencyTableMap::BY_DEFAULT)) {
+ $modifiedColumns[':p' . $index++] = 'BY_DEFAULT';
+ }
+ if ($this->isColumnModified(CurrencyTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CurrencyTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO currency (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'NAME':
+ $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
+ break;
+ case 'CODE':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case 'SYMBOL':
+ $stmt->bindValue($identifier, $this->symbol, PDO::PARAM_STR);
+ break;
+ case 'RATE':
+ $stmt->bindValue($identifier, $this->rate, PDO::PARAM_STR);
+ break;
+ case 'BY_DEFAULT':
+ $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CurrencyTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getName();
+ break;
+ case 2:
+ return $this->getCode();
+ break;
+ case 3:
+ return $this->getSymbol();
+ break;
+ case 4:
+ return $this->getRate();
+ break;
+ case 5:
+ return $this->getByDefault();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Currency'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Currency'][$this->getPrimaryKey()] = true;
+ $keys = CurrencyTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getName(),
+ $keys[2] => $this->getCode(),
+ $keys[3] => $this->getSymbol(),
+ $keys[4] => $this->getRate(),
+ $keys[5] => $this->getByDefault(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collOrders) {
+ $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CurrencyTableMap::translateFieldName($name, $type, TableMap::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->setName($value);
+ break;
+ case 2:
+ $this->setCode($value);
+ break;
+ case 3:
+ $this->setSymbol($value);
+ break;
+ case 4:
+ $this->setRate($value);
+ break;
+ case 5:
+ $this->setByDefault($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CurrencyTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCode($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setSymbol($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setRate($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setByDefault($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * 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(CurrencyTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CurrencyTableMap::ID)) $criteria->add(CurrencyTableMap::ID, $this->id);
+ if ($this->isColumnModified(CurrencyTableMap::NAME)) $criteria->add(CurrencyTableMap::NAME, $this->name);
+ if ($this->isColumnModified(CurrencyTableMap::CODE)) $criteria->add(CurrencyTableMap::CODE, $this->code);
+ if ($this->isColumnModified(CurrencyTableMap::SYMBOL)) $criteria->add(CurrencyTableMap::SYMBOL, $this->symbol);
+ if ($this->isColumnModified(CurrencyTableMap::RATE)) $criteria->add(CurrencyTableMap::RATE, $this->rate);
+ if ($this->isColumnModified(CurrencyTableMap::BY_DEFAULT)) $criteria->add(CurrencyTableMap::BY_DEFAULT, $this->by_default);
+ if ($this->isColumnModified(CurrencyTableMap::CREATED_AT)) $criteria->add(CurrencyTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CurrencyTableMap::UPDATED_AT)) $criteria->add(CurrencyTableMap::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(CurrencyTableMap::DATABASE_NAME);
+ $criteria->add(CurrencyTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Currency (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setName($this->getName());
+ $copyObj->setCode($this->getCode());
+ $copyObj->setSymbol($this->getSymbol());
+ $copyObj->setRate($this->getRate());
+ $copyObj->setByDefault($this->getByDefault());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getOrders() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrder($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Currency 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('Order' == $relationName) {
+ return $this->initOrders();
+ }
+ }
+
+ /**
+ * Clears out the collOrders collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addOrders()
+ */
+ public function clearOrders()
+ {
+ $this->collOrders = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collOrders collection loaded partially.
+ */
+ public function resetPartialOrders($v = true)
+ {
+ $this->collOrdersPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrders collection.
+ *
+ * By default this just sets the collOrders collection to an empty array (like clearcollOrders());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initOrders($overrideExisting = true)
+ {
+ if (null !== $this->collOrders && !$overrideExisting) {
+ return;
+ }
+ $this->collOrders = new ObjectCollection();
+ $this->collOrders->setModel('\Thelia\Model\Order');
+ }
+
+ /**
+ * Gets an array of ChildOrder objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCurrency is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ * @throws PropelException
+ */
+ public function getOrders($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrdersPartial && !$this->isNew();
+ if (null === $this->collOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrders) {
+ // return empty collection
+ $this->initOrders();
+ } else {
+ $collOrders = ChildOrderQuery::create(null, $criteria)
+ ->filterByCurrency($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collOrdersPartial && count($collOrders)) {
+ $this->initOrders(false);
+
+ foreach ($collOrders as $obj) {
+ if (false == $this->collOrders->contains($obj)) {
+ $this->collOrders->append($obj);
+ }
+ }
+
+ $this->collOrdersPartial = true;
+ }
+
+ $collOrders->getInternalIterator()->rewind();
+
+ return $collOrders;
+ }
+
+ if ($partial && $this->collOrders) {
+ foreach ($this->collOrders as $obj) {
+ if ($obj->isNew()) {
+ $collOrders[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrders = $collOrders;
+ $this->collOrdersPartial = false;
+ }
+ }
+
+ return $this->collOrders;
+ }
+
+ /**
+ * Sets a collection of Order objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $orders A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCurrency The current object (for fluent API support)
+ */
+ public function setOrders(Collection $orders, ConnectionInterface $con = null)
+ {
+ $ordersToDelete = $this->getOrders(new Criteria(), $con)->diff($orders);
+
+
+ $this->ordersScheduledForDeletion = $ordersToDelete;
+
+ foreach ($ordersToDelete as $orderRemoved) {
+ $orderRemoved->setCurrency(null);
+ }
+
+ $this->collOrders = null;
+ foreach ($orders as $order) {
+ $this->addOrder($order);
+ }
+
+ $this->collOrders = $orders;
+ $this->collOrdersPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Order objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Order objects.
+ * @throws PropelException
+ */
+ public function countOrders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrdersPartial && !$this->isNew();
+ if (null === $this->collOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrders) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getOrders());
+ }
+
+ $query = ChildOrderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCurrency($this)
+ ->count($con);
+ }
+
+ return count($this->collOrders);
+ }
+
+ /**
+ * Method called to associate a ChildOrder object to this object
+ * through the ChildOrder foreign key attribute.
+ *
+ * @param ChildOrder $l ChildOrder
+ * @return \Thelia\Model\Currency The current object (for fluent API support)
+ */
+ public function addOrder(ChildOrder $l)
+ {
+ if ($this->collOrders === null) {
+ $this->initOrders();
+ $this->collOrdersPartial = true;
+ }
+
+ if (!in_array($l, $this->collOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddOrder($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Order $order The order object to add.
+ */
+ protected function doAddOrder($order)
+ {
+ $this->collOrders[]= $order;
+ $order->setCurrency($this);
+ }
+
+ /**
+ * @param Order $order The order object to remove.
+ * @return ChildCurrency The current object (for fluent API support)
+ */
+ public function removeOrder($order)
+ {
+ if ($this->getOrders()->contains($order)) {
+ $this->collOrders->remove($this->collOrders->search($order));
+ if (null === $this->ordersScheduledForDeletion) {
+ $this->ordersScheduledForDeletion = clone $this->collOrders;
+ $this->ordersScheduledForDeletion->clear();
+ }
+ $this->ordersScheduledForDeletion[]= $order;
+ $order->setCurrency(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Currency is new, it will return
+ * an empty collection; or if this Currency has previously
+ * been saved, it will retrieve related Orders 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 Currency.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('Customer', $joinBehavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Currency is new, it will return
+ * an empty collection; or if this Currency has previously
+ * been saved, it will retrieve related Orders 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 Currency.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('OrderAddressRelatedByAddressInvoice', $joinBehavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Currency is new, it will return
+ * an empty collection; or if this Currency has previously
+ * been saved, it will retrieve related Orders 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 Currency.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('OrderAddressRelatedByAddressDelivery', $joinBehavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Currency is new, it will return
+ * an empty collection; or if this Currency has previously
+ * been saved, it will retrieve related Orders 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 Currency.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('OrderStatus', $joinBehavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->name = null;
+ $this->code = null;
+ $this->symbol = null;
+ $this->rate = null;
+ $this->by_default = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collOrders) {
+ foreach ($this->collOrders as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collOrders instanceof Collection) {
+ $this->collOrders->clearIterator();
+ }
+ $this->collOrders = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CurrencyTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCurrency The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = CurrencyTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/CurrencyQuery.php b/core/lib/Thelia/Model/Base/CurrencyQuery.php
new file mode 100644
index 000000000..6bc45c3d7
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CurrencyQuery.php
@@ -0,0 +1,773 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCurrency|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CurrencyTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CurrencyTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCurrency A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, NAME, CODE, SYMBOL, RATE, BY_DEFAULT, CREATED_AT, UPDATED_AT FROM currency WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildCurrency();
+ $obj->hydrate($row);
+ CurrencyTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCurrency|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CurrencyTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CurrencyTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CurrencyTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CurrencyTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the name column
+ *
+ * Example usage:
+ *
+ * $query->filterByName('fooValue'); // WHERE name = 'fooValue'
+ * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
+ *
+ *
+ * @param string $name The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function filterByName($name = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($name)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $name)) {
+ $name = str_replace('*', '%', $name);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyTableMap::NAME, $name, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyTableMap::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the symbol column
+ *
+ * Example usage:
+ *
+ * $query->filterBySymbol('fooValue'); // WHERE symbol = 'fooValue'
+ * $query->filterBySymbol('%fooValue%'); // WHERE symbol LIKE '%fooValue%'
+ *
+ *
+ * @param string $symbol The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function filterBySymbol($symbol = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($symbol)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $symbol)) {
+ $symbol = str_replace('*', '%', $symbol);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyTableMap::SYMBOL, $symbol, $comparison);
+ }
+
+ /**
+ * Filter the query on the rate column
+ *
+ * Example usage:
+ *
+ * $query->filterByRate(1234); // WHERE rate = 1234
+ * $query->filterByRate(array(12, 34)); // WHERE rate IN (12, 34)
+ * $query->filterByRate(array('min' => 12)); // WHERE rate > 12
+ *
+ *
+ * @param mixed $rate The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function filterByRate($rate = null, $comparison = null)
+ {
+ if (is_array($rate)) {
+ $useMinMax = false;
+ if (isset($rate['min'])) {
+ $this->addUsingAlias(CurrencyTableMap::RATE, $rate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($rate['max'])) {
+ $this->addUsingAlias(CurrencyTableMap::RATE, $rate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyTableMap::RATE, $rate, $comparison);
+ }
+
+ /**
+ * Filter the query on the by_default column
+ *
+ * Example usage:
+ *
+ * $query->filterByByDefault(1234); // WHERE by_default = 1234
+ * $query->filterByByDefault(array(12, 34)); // WHERE by_default IN (12, 34)
+ * $query->filterByByDefault(array('min' => 12)); // WHERE by_default > 12
+ *
+ *
+ * @param mixed $byDefault The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function filterByByDefault($byDefault = null, $comparison = null)
+ {
+ if (is_array($byDefault)) {
+ $useMinMax = false;
+ if (isset($byDefault['min'])) {
+ $this->addUsingAlias(CurrencyTableMap::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($byDefault['max'])) {
+ $this->addUsingAlias(CurrencyTableMap::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyTableMap::BY_DEFAULT, $byDefault, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CurrencyTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CurrencyTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CurrencyTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CurrencyTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CurrencyTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Order object
+ *
+ * @param \Thelia\Model\Order|ObjectCollection $order the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function filterByOrder($order, $comparison = null)
+ {
+ if ($order instanceof \Thelia\Model\Order) {
+ return $this
+ ->addUsingAlias(CurrencyTableMap::ID, $order->getCurrencyId(), $comparison);
+ } elseif ($order instanceof ObjectCollection) {
+ return $this
+ ->useOrderQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Order relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Order');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Order');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Order relation Order object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinOrder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCurrency $currency Object to remove from the list of results
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function prune($currency = null)
+ {
+ if ($currency) {
+ $this->addUsingAlias(CurrencyTableMap::ID, $currency->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the currency table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CurrencyTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CurrencyTableMap::clearInstancePool();
+ CurrencyTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCurrency or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCurrency object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CurrencyTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CurrencyTableMap::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->beginTransaction();
+
+
+ CurrencyTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CurrencyTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CurrencyTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CurrencyTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CurrencyTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CurrencyTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CurrencyTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCurrencyQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CurrencyTableMap::CREATED_AT);
+ }
+
+} // CurrencyQuery
diff --git a/core/lib/Thelia/Model/Base/Customer.php b/core/lib/Thelia/Model/Base/Customer.php
new file mode 100644
index 000000000..6941594a0
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Customer.php
@@ -0,0 +1,3211 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Customer instance. If
+ * obj is an instance of Customer, delegates to
+ * equals(Customer). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Customer The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Customer The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [ref] column value.
+ *
+ * @return string
+ */
+ public function getRef()
+ {
+
+ return $this->ref;
+ }
+
+ /**
+ * Get the [customer_title_id] column value.
+ *
+ * @return int
+ */
+ public function getCustomerTitleId()
+ {
+
+ return $this->customer_title_id;
+ }
+
+ /**
+ * Get the [company] column value.
+ *
+ * @return string
+ */
+ public function getCompany()
+ {
+
+ return $this->company;
+ }
+
+ /**
+ * Get the [firstname] column value.
+ *
+ * @return string
+ */
+ public function getFirstname()
+ {
+
+ return $this->firstname;
+ }
+
+ /**
+ * Get the [lastname] column value.
+ *
+ * @return string
+ */
+ public function getLastname()
+ {
+
+ return $this->lastname;
+ }
+
+ /**
+ * 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 [address3] column value.
+ *
+ * @return string
+ */
+ public function getAddress3()
+ {
+
+ return $this->address3;
+ }
+
+ /**
+ * Get the [zipcode] column value.
+ *
+ * @return string
+ */
+ public function getZipcode()
+ {
+
+ return $this->zipcode;
+ }
+
+ /**
+ * Get the [city] column value.
+ *
+ * @return string
+ */
+ public function getCity()
+ {
+
+ return $this->city;
+ }
+
+ /**
+ * Get the [country_id] column value.
+ *
+ * @return int
+ */
+ public function getCountryId()
+ {
+
+ return $this->country_id;
+ }
+
+ /**
+ * Get the [phone] column value.
+ *
+ * @return string
+ */
+ public function getPhone()
+ {
+
+ return $this->phone;
+ }
+
+ /**
+ * Get the [cellphone] column value.
+ *
+ * @return string
+ */
+ public function getCellphone()
+ {
+
+ return $this->cellphone;
+ }
+
+ /**
+ * Get the [email] column value.
+ *
+ * @return string
+ */
+ public function getEmail()
+ {
+
+ return $this->email;
+ }
+
+ /**
+ * Get the [password] column value.
+ *
+ * @return string
+ */
+ public function getPassword()
+ {
+
+ return $this->password;
+ }
+
+ /**
+ * Get the [algo] column value.
+ *
+ * @return string
+ */
+ public function getAlgo()
+ {
+
+ return $this->algo;
+ }
+
+ /**
+ * Get the [salt] column value.
+ *
+ * @return string
+ */
+ public function getSalt()
+ {
+
+ return $this->salt;
+ }
+
+ /**
+ * Get the [reseller] column value.
+ *
+ * @return int
+ */
+ public function getReseller()
+ {
+
+ return $this->reseller;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+
+ return $this->lang;
+ }
+
+ /**
+ * Get the [sponsor] column value.
+ *
+ * @return string
+ */
+ public function getSponsor()
+ {
+
+ return $this->sponsor;
+ }
+
+ /**
+ * Get the [discount] column value.
+ *
+ * @return double
+ */
+ public function getDiscount()
+ {
+
+ return $this->discount;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CustomerTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->ref !== $v) {
+ $this->ref = $v;
+ $this->modifiedColumns[] = CustomerTableMap::REF;
+ }
+
+
+ return $this;
+ } // setRef()
+
+ /**
+ * Set the value of [customer_title_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setCustomerTitleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_title_id !== $v) {
+ $this->customer_title_id = $v;
+ $this->modifiedColumns[] = CustomerTableMap::CUSTOMER_TITLE_ID;
+ }
+
+ if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) {
+ $this->aCustomerTitle = null;
+ }
+
+
+ return $this;
+ } // setCustomerTitleId()
+
+ /**
+ * Set the value of [company] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setCompany($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->company !== $v) {
+ $this->company = $v;
+ $this->modifiedColumns[] = CustomerTableMap::COMPANY;
+ }
+
+
+ return $this;
+ } // setCompany()
+
+ /**
+ * Set the value of [firstname] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setFirstname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->firstname !== $v) {
+ $this->firstname = $v;
+ $this->modifiedColumns[] = CustomerTableMap::FIRSTNAME;
+ }
+
+
+ return $this;
+ } // setFirstname()
+
+ /**
+ * Set the value of [lastname] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setLastname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lastname !== $v) {
+ $this->lastname = $v;
+ $this->modifiedColumns[] = CustomerTableMap::LASTNAME;
+ }
+
+
+ return $this;
+ } // setLastname()
+
+ /**
+ * Set the value of [address1] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setAddress1($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address1 !== $v) {
+ $this->address1 = $v;
+ $this->modifiedColumns[] = CustomerTableMap::ADDRESS1;
+ }
+
+
+ return $this;
+ } // setAddress1()
+
+ /**
+ * Set the value of [address2] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setAddress2($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address2 !== $v) {
+ $this->address2 = $v;
+ $this->modifiedColumns[] = CustomerTableMap::ADDRESS2;
+ }
+
+
+ return $this;
+ } // setAddress2()
+
+ /**
+ * Set the value of [address3] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setAddress3($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address3 !== $v) {
+ $this->address3 = $v;
+ $this->modifiedColumns[] = CustomerTableMap::ADDRESS3;
+ }
+
+
+ return $this;
+ } // setAddress3()
+
+ /**
+ * Set the value of [zipcode] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setZipcode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->zipcode !== $v) {
+ $this->zipcode = $v;
+ $this->modifiedColumns[] = CustomerTableMap::ZIPCODE;
+ }
+
+
+ return $this;
+ } // setZipcode()
+
+ /**
+ * Set the value of [city] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setCity($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->city !== $v) {
+ $this->city = $v;
+ $this->modifiedColumns[] = CustomerTableMap::CITY;
+ }
+
+
+ return $this;
+ } // setCity()
+
+ /**
+ * Set the value of [country_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setCountryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->country_id !== $v) {
+ $this->country_id = $v;
+ $this->modifiedColumns[] = CustomerTableMap::COUNTRY_ID;
+ }
+
+
+ return $this;
+ } // setCountryId()
+
+ /**
+ * Set the value of [phone] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setPhone($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->phone !== $v) {
+ $this->phone = $v;
+ $this->modifiedColumns[] = CustomerTableMap::PHONE;
+ }
+
+
+ return $this;
+ } // setPhone()
+
+ /**
+ * Set the value of [cellphone] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setCellphone($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->cellphone !== $v) {
+ $this->cellphone = $v;
+ $this->modifiedColumns[] = CustomerTableMap::CELLPHONE;
+ }
+
+
+ return $this;
+ } // setCellphone()
+
+ /**
+ * Set the value of [email] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setEmail($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->email !== $v) {
+ $this->email = $v;
+ $this->modifiedColumns[] = CustomerTableMap::EMAIL;
+ }
+
+
+ return $this;
+ } // setEmail()
+
+ /**
+ * Set the value of [password] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setPassword($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->password !== $v) {
+ $this->password = $v;
+ $this->modifiedColumns[] = CustomerTableMap::PASSWORD;
+ }
+
+
+ return $this;
+ } // setPassword()
+
+ /**
+ * Set the value of [algo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setAlgo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->algo !== $v) {
+ $this->algo = $v;
+ $this->modifiedColumns[] = CustomerTableMap::ALGO;
+ }
+
+
+ return $this;
+ } // setAlgo()
+
+ /**
+ * Set the value of [salt] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setSalt($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->salt !== $v) {
+ $this->salt = $v;
+ $this->modifiedColumns[] = CustomerTableMap::SALT;
+ }
+
+
+ return $this;
+ } // setSalt()
+
+ /**
+ * Set the value of [reseller] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setReseller($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->reseller !== $v) {
+ $this->reseller = $v;
+ $this->modifiedColumns[] = CustomerTableMap::RESELLER;
+ }
+
+
+ return $this;
+ } // setReseller()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = CustomerTableMap::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Set the value of [sponsor] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setSponsor($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->sponsor !== $v) {
+ $this->sponsor = $v;
+ $this->modifiedColumns[] = CustomerTableMap::SPONSOR;
+ }
+
+
+ return $this;
+ } // setSponsor()
+
+ /**
+ * Set the value of [discount] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setDiscount($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->discount !== $v) {
+ $this->discount = $v;
+ $this->modifiedColumns[] = CustomerTableMap::DISCOUNT;
+ }
+
+
+ return $this;
+ } // setDiscount()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = CustomerTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = CustomerTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CustomerTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->ref = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerTableMap::translateFieldName('CustomerTitleId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->customer_title_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerTableMap::translateFieldName('Company', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->company = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->firstname = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CustomerTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->lastname = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CustomerTableMap::translateFieldName('Address1', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->address1 = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CustomerTableMap::translateFieldName('Address2', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->address2 = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CustomerTableMap::translateFieldName('Address3', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->address3 = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CustomerTableMap::translateFieldName('Zipcode', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->zipcode = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CustomerTableMap::translateFieldName('City', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->city = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CustomerTableMap::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->country_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CustomerTableMap::translateFieldName('Phone', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->phone = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CustomerTableMap::translateFieldName('Cellphone', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->cellphone = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CustomerTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->email = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CustomerTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->password = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CustomerTableMap::translateFieldName('Algo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->algo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : CustomerTableMap::translateFieldName('Salt', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->salt = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 18 + $startcol : CustomerTableMap::translateFieldName('Reseller', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->reseller = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 19 + $startcol : CustomerTableMap::translateFieldName('Lang', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->lang = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 20 + $startcol : CustomerTableMap::translateFieldName('Sponsor', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->sponsor = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 21 + $startcol : CustomerTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->discount = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 22 + $startcol : CustomerTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 23 + $startcol : CustomerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 24; // 24 = CustomerTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Customer object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) {
+ $this->aCustomerTitle = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CustomerTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCustomerQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCustomerTitle = null;
+ $this->collAddresses = null;
+
+ $this->collOrders = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Customer::setDeleted()
+ * @see Customer::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCustomerQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CustomerTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CustomerTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CustomerTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CustomerTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCustomerTitle !== null) {
+ if ($this->aCustomerTitle->isModified() || $this->aCustomerTitle->isNew()) {
+ $affectedRows += $this->aCustomerTitle->save($con);
+ }
+ $this->setCustomerTitle($this->aCustomerTitle);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->addressesScheduledForDeletion !== null) {
+ if (!$this->addressesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\AddressQuery::create()
+ ->filterByPrimaryKeys($this->addressesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->addressesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAddresses !== null) {
+ foreach ($this->collAddresses as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->ordersScheduledForDeletion !== null) {
+ if (!$this->ordersScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\OrderQuery::create()
+ ->filterByPrimaryKeys($this->ordersScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->ordersScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrders !== null) {
+ foreach ($this->collOrders as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CustomerTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CustomerTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CustomerTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CustomerTableMap::REF)) {
+ $modifiedColumns[':p' . $index++] = 'REF';
+ }
+ if ($this->isColumnModified(CustomerTableMap::CUSTOMER_TITLE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CUSTOMER_TITLE_ID';
+ }
+ if ($this->isColumnModified(CustomerTableMap::COMPANY)) {
+ $modifiedColumns[':p' . $index++] = 'COMPANY';
+ }
+ if ($this->isColumnModified(CustomerTableMap::FIRSTNAME)) {
+ $modifiedColumns[':p' . $index++] = 'FIRSTNAME';
+ }
+ if ($this->isColumnModified(CustomerTableMap::LASTNAME)) {
+ $modifiedColumns[':p' . $index++] = 'LASTNAME';
+ }
+ if ($this->isColumnModified(CustomerTableMap::ADDRESS1)) {
+ $modifiedColumns[':p' . $index++] = 'ADDRESS1';
+ }
+ if ($this->isColumnModified(CustomerTableMap::ADDRESS2)) {
+ $modifiedColumns[':p' . $index++] = 'ADDRESS2';
+ }
+ if ($this->isColumnModified(CustomerTableMap::ADDRESS3)) {
+ $modifiedColumns[':p' . $index++] = 'ADDRESS3';
+ }
+ if ($this->isColumnModified(CustomerTableMap::ZIPCODE)) {
+ $modifiedColumns[':p' . $index++] = 'ZIPCODE';
+ }
+ if ($this->isColumnModified(CustomerTableMap::CITY)) {
+ $modifiedColumns[':p' . $index++] = 'CITY';
+ }
+ if ($this->isColumnModified(CustomerTableMap::COUNTRY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'COUNTRY_ID';
+ }
+ if ($this->isColumnModified(CustomerTableMap::PHONE)) {
+ $modifiedColumns[':p' . $index++] = 'PHONE';
+ }
+ if ($this->isColumnModified(CustomerTableMap::CELLPHONE)) {
+ $modifiedColumns[':p' . $index++] = 'CELLPHONE';
+ }
+ if ($this->isColumnModified(CustomerTableMap::EMAIL)) {
+ $modifiedColumns[':p' . $index++] = 'EMAIL';
+ }
+ if ($this->isColumnModified(CustomerTableMap::PASSWORD)) {
+ $modifiedColumns[':p' . $index++] = 'PASSWORD';
+ }
+ if ($this->isColumnModified(CustomerTableMap::ALGO)) {
+ $modifiedColumns[':p' . $index++] = 'ALGO';
+ }
+ if ($this->isColumnModified(CustomerTableMap::SALT)) {
+ $modifiedColumns[':p' . $index++] = 'SALT';
+ }
+ if ($this->isColumnModified(CustomerTableMap::RESELLER)) {
+ $modifiedColumns[':p' . $index++] = 'RESELLER';
+ }
+ if ($this->isColumnModified(CustomerTableMap::LANG)) {
+ $modifiedColumns[':p' . $index++] = 'LANG';
+ }
+ if ($this->isColumnModified(CustomerTableMap::SPONSOR)) {
+ $modifiedColumns[':p' . $index++] = 'SPONSOR';
+ }
+ if ($this->isColumnModified(CustomerTableMap::DISCOUNT)) {
+ $modifiedColumns[':p' . $index++] = 'DISCOUNT';
+ }
+ if ($this->isColumnModified(CustomerTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CustomerTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO customer (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'REF':
+ $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
+ break;
+ case 'CUSTOMER_TITLE_ID':
+ $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT);
+ break;
+ case 'COMPANY':
+ $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR);
+ break;
+ case 'FIRSTNAME':
+ $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR);
+ break;
+ case 'LASTNAME':
+ $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR);
+ break;
+ case 'ADDRESS1':
+ $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR);
+ break;
+ case 'ADDRESS2':
+ $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR);
+ break;
+ case 'ADDRESS3':
+ $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR);
+ break;
+ case 'ZIPCODE':
+ $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR);
+ break;
+ case 'CITY':
+ $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR);
+ break;
+ case 'COUNTRY_ID':
+ $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT);
+ break;
+ case 'PHONE':
+ $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR);
+ break;
+ case 'CELLPHONE':
+ $stmt->bindValue($identifier, $this->cellphone, PDO::PARAM_STR);
+ break;
+ case 'EMAIL':
+ $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR);
+ break;
+ case 'PASSWORD':
+ $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR);
+ break;
+ case 'ALGO':
+ $stmt->bindValue($identifier, $this->algo, PDO::PARAM_STR);
+ break;
+ case 'SALT':
+ $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR);
+ break;
+ case 'RESELLER':
+ $stmt->bindValue($identifier, $this->reseller, PDO::PARAM_INT);
+ break;
+ case 'LANG':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case 'SPONSOR':
+ $stmt->bindValue($identifier, $this->sponsor, PDO::PARAM_STR);
+ break;
+ case 'DISCOUNT':
+ $stmt->bindValue($identifier, $this->discount, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CustomerTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getRef();
+ break;
+ case 2:
+ return $this->getCustomerTitleId();
+ break;
+ case 3:
+ return $this->getCompany();
+ break;
+ case 4:
+ return $this->getFirstname();
+ break;
+ case 5:
+ return $this->getLastname();
+ break;
+ case 6:
+ return $this->getAddress1();
+ break;
+ case 7:
+ return $this->getAddress2();
+ break;
+ case 8:
+ return $this->getAddress3();
+ break;
+ case 9:
+ return $this->getZipcode();
+ break;
+ case 10:
+ return $this->getCity();
+ break;
+ case 11:
+ return $this->getCountryId();
+ break;
+ case 12:
+ return $this->getPhone();
+ break;
+ case 13:
+ return $this->getCellphone();
+ break;
+ case 14:
+ return $this->getEmail();
+ break;
+ case 15:
+ return $this->getPassword();
+ break;
+ case 16:
+ return $this->getAlgo();
+ break;
+ case 17:
+ return $this->getSalt();
+ break;
+ case 18:
+ return $this->getReseller();
+ break;
+ case 19:
+ return $this->getLang();
+ break;
+ case 20:
+ return $this->getSponsor();
+ break;
+ case 21:
+ return $this->getDiscount();
+ break;
+ case 22:
+ return $this->getCreatedAt();
+ break;
+ case 23:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Customer'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Customer'][$this->getPrimaryKey()] = true;
+ $keys = CustomerTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getRef(),
+ $keys[2] => $this->getCustomerTitleId(),
+ $keys[3] => $this->getCompany(),
+ $keys[4] => $this->getFirstname(),
+ $keys[5] => $this->getLastname(),
+ $keys[6] => $this->getAddress1(),
+ $keys[7] => $this->getAddress2(),
+ $keys[8] => $this->getAddress3(),
+ $keys[9] => $this->getZipcode(),
+ $keys[10] => $this->getCity(),
+ $keys[11] => $this->getCountryId(),
+ $keys[12] => $this->getPhone(),
+ $keys[13] => $this->getCellphone(),
+ $keys[14] => $this->getEmail(),
+ $keys[15] => $this->getPassword(),
+ $keys[16] => $this->getAlgo(),
+ $keys[17] => $this->getSalt(),
+ $keys[18] => $this->getReseller(),
+ $keys[19] => $this->getLang(),
+ $keys[20] => $this->getSponsor(),
+ $keys[21] => $this->getDiscount(),
+ $keys[22] => $this->getCreatedAt(),
+ $keys[23] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCustomerTitle) {
+ $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collAddresses) {
+ $result['Addresses'] = $this->collAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collOrders) {
+ $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CustomerTableMap::translateFieldName($name, $type, TableMap::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->setRef($value);
+ break;
+ case 2:
+ $this->setCustomerTitleId($value);
+ break;
+ case 3:
+ $this->setCompany($value);
+ break;
+ case 4:
+ $this->setFirstname($value);
+ break;
+ case 5:
+ $this->setLastname($value);
+ break;
+ case 6:
+ $this->setAddress1($value);
+ break;
+ case 7:
+ $this->setAddress2($value);
+ break;
+ case 8:
+ $this->setAddress3($value);
+ break;
+ case 9:
+ $this->setZipcode($value);
+ break;
+ case 10:
+ $this->setCity($value);
+ break;
+ case 11:
+ $this->setCountryId($value);
+ break;
+ case 12:
+ $this->setPhone($value);
+ break;
+ case 13:
+ $this->setCellphone($value);
+ break;
+ case 14:
+ $this->setEmail($value);
+ break;
+ case 15:
+ $this->setPassword($value);
+ break;
+ case 16:
+ $this->setAlgo($value);
+ break;
+ case 17:
+ $this->setSalt($value);
+ break;
+ case 18:
+ $this->setReseller($value);
+ break;
+ case 19:
+ $this->setLang($value);
+ break;
+ case 20:
+ $this->setSponsor($value);
+ break;
+ case 21:
+ $this->setDiscount($value);
+ break;
+ case 22:
+ $this->setCreatedAt($value);
+ break;
+ case 23:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CustomerTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCustomerTitleId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCompany($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setFirstname($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setLastname($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setAddress1($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setAddress2($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setAddress3($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setZipcode($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setCity($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setCountryId($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setPhone($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setCellphone($arr[$keys[13]]);
+ if (array_key_exists($keys[14], $arr)) $this->setEmail($arr[$keys[14]]);
+ if (array_key_exists($keys[15], $arr)) $this->setPassword($arr[$keys[15]]);
+ if (array_key_exists($keys[16], $arr)) $this->setAlgo($arr[$keys[16]]);
+ if (array_key_exists($keys[17], $arr)) $this->setSalt($arr[$keys[17]]);
+ if (array_key_exists($keys[18], $arr)) $this->setReseller($arr[$keys[18]]);
+ if (array_key_exists($keys[19], $arr)) $this->setLang($arr[$keys[19]]);
+ if (array_key_exists($keys[20], $arr)) $this->setSponsor($arr[$keys[20]]);
+ if (array_key_exists($keys[21], $arr)) $this->setDiscount($arr[$keys[21]]);
+ if (array_key_exists($keys[22], $arr)) $this->setCreatedAt($arr[$keys[22]]);
+ if (array_key_exists($keys[23], $arr)) $this->setUpdatedAt($arr[$keys[23]]);
+ }
+
+ /**
+ * 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(CustomerTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CustomerTableMap::ID)) $criteria->add(CustomerTableMap::ID, $this->id);
+ if ($this->isColumnModified(CustomerTableMap::REF)) $criteria->add(CustomerTableMap::REF, $this->ref);
+ if ($this->isColumnModified(CustomerTableMap::CUSTOMER_TITLE_ID)) $criteria->add(CustomerTableMap::CUSTOMER_TITLE_ID, $this->customer_title_id);
+ if ($this->isColumnModified(CustomerTableMap::COMPANY)) $criteria->add(CustomerTableMap::COMPANY, $this->company);
+ if ($this->isColumnModified(CustomerTableMap::FIRSTNAME)) $criteria->add(CustomerTableMap::FIRSTNAME, $this->firstname);
+ if ($this->isColumnModified(CustomerTableMap::LASTNAME)) $criteria->add(CustomerTableMap::LASTNAME, $this->lastname);
+ if ($this->isColumnModified(CustomerTableMap::ADDRESS1)) $criteria->add(CustomerTableMap::ADDRESS1, $this->address1);
+ if ($this->isColumnModified(CustomerTableMap::ADDRESS2)) $criteria->add(CustomerTableMap::ADDRESS2, $this->address2);
+ if ($this->isColumnModified(CustomerTableMap::ADDRESS3)) $criteria->add(CustomerTableMap::ADDRESS3, $this->address3);
+ if ($this->isColumnModified(CustomerTableMap::ZIPCODE)) $criteria->add(CustomerTableMap::ZIPCODE, $this->zipcode);
+ if ($this->isColumnModified(CustomerTableMap::CITY)) $criteria->add(CustomerTableMap::CITY, $this->city);
+ if ($this->isColumnModified(CustomerTableMap::COUNTRY_ID)) $criteria->add(CustomerTableMap::COUNTRY_ID, $this->country_id);
+ if ($this->isColumnModified(CustomerTableMap::PHONE)) $criteria->add(CustomerTableMap::PHONE, $this->phone);
+ if ($this->isColumnModified(CustomerTableMap::CELLPHONE)) $criteria->add(CustomerTableMap::CELLPHONE, $this->cellphone);
+ if ($this->isColumnModified(CustomerTableMap::EMAIL)) $criteria->add(CustomerTableMap::EMAIL, $this->email);
+ if ($this->isColumnModified(CustomerTableMap::PASSWORD)) $criteria->add(CustomerTableMap::PASSWORD, $this->password);
+ if ($this->isColumnModified(CustomerTableMap::ALGO)) $criteria->add(CustomerTableMap::ALGO, $this->algo);
+ if ($this->isColumnModified(CustomerTableMap::SALT)) $criteria->add(CustomerTableMap::SALT, $this->salt);
+ if ($this->isColumnModified(CustomerTableMap::RESELLER)) $criteria->add(CustomerTableMap::RESELLER, $this->reseller);
+ if ($this->isColumnModified(CustomerTableMap::LANG)) $criteria->add(CustomerTableMap::LANG, $this->lang);
+ if ($this->isColumnModified(CustomerTableMap::SPONSOR)) $criteria->add(CustomerTableMap::SPONSOR, $this->sponsor);
+ if ($this->isColumnModified(CustomerTableMap::DISCOUNT)) $criteria->add(CustomerTableMap::DISCOUNT, $this->discount);
+ if ($this->isColumnModified(CustomerTableMap::CREATED_AT)) $criteria->add(CustomerTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CustomerTableMap::UPDATED_AT)) $criteria->add(CustomerTableMap::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(CustomerTableMap::DATABASE_NAME);
+ $criteria->add(CustomerTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Customer (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setRef($this->getRef());
+ $copyObj->setCustomerTitleId($this->getCustomerTitleId());
+ $copyObj->setCompany($this->getCompany());
+ $copyObj->setFirstname($this->getFirstname());
+ $copyObj->setLastname($this->getLastname());
+ $copyObj->setAddress1($this->getAddress1());
+ $copyObj->setAddress2($this->getAddress2());
+ $copyObj->setAddress3($this->getAddress3());
+ $copyObj->setZipcode($this->getZipcode());
+ $copyObj->setCity($this->getCity());
+ $copyObj->setCountryId($this->getCountryId());
+ $copyObj->setPhone($this->getPhone());
+ $copyObj->setCellphone($this->getCellphone());
+ $copyObj->setEmail($this->getEmail());
+ $copyObj->setPassword($this->getPassword());
+ $copyObj->setAlgo($this->getAlgo());
+ $copyObj->setSalt($this->getSalt());
+ $copyObj->setReseller($this->getReseller());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setSponsor($this->getSponsor());
+ $copyObj->setDiscount($this->getDiscount());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getAddresses() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAddress($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getOrders() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrder($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Customer 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCustomerTitle object.
+ *
+ * @param ChildCustomerTitle $v
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCustomerTitle(ChildCustomerTitle $v = null)
+ {
+ if ($v === null) {
+ $this->setCustomerTitleId(NULL);
+ } else {
+ $this->setCustomerTitleId($v->getId());
+ }
+
+ $this->aCustomerTitle = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCustomerTitle object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCustomer($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCustomerTitle object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCustomerTitle The associated ChildCustomerTitle object.
+ * @throws PropelException
+ */
+ public function getCustomerTitle(ConnectionInterface $con = null)
+ {
+ if ($this->aCustomerTitle === null && ($this->customer_title_id !== null)) {
+ $this->aCustomerTitle = ChildCustomerTitleQuery::create()->findPk($this->customer_title_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCustomerTitle->addCustomers($this);
+ */
+ }
+
+ return $this->aCustomerTitle;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('Address' == $relationName) {
+ return $this->initAddresses();
+ }
+ if ('Order' == $relationName) {
+ return $this->initOrders();
+ }
+ }
+
+ /**
+ * Clears out the collAddresses collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAddresses()
+ */
+ public function clearAddresses()
+ {
+ $this->collAddresses = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collAddresses collection loaded partially.
+ */
+ public function resetPartialAddresses($v = true)
+ {
+ $this->collAddressesPartial = $v;
+ }
+
+ /**
+ * Initializes the collAddresses collection.
+ *
+ * By default this just sets the collAddresses collection to an empty array (like clearcollAddresses());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAddresses($overrideExisting = true)
+ {
+ if (null !== $this->collAddresses && !$overrideExisting) {
+ return;
+ }
+ $this->collAddresses = new ObjectCollection();
+ $this->collAddresses->setModel('\Thelia\Model\Address');
+ }
+
+ /**
+ * Gets an array of ChildAddress objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCustomer is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildAddress[] List of ChildAddress objects
+ * @throws PropelException
+ */
+ public function getAddresses($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAddressesPartial && !$this->isNew();
+ if (null === $this->collAddresses || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAddresses) {
+ // return empty collection
+ $this->initAddresses();
+ } else {
+ $collAddresses = ChildAddressQuery::create(null, $criteria)
+ ->filterByCustomer($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collAddressesPartial && count($collAddresses)) {
+ $this->initAddresses(false);
+
+ foreach ($collAddresses as $obj) {
+ if (false == $this->collAddresses->contains($obj)) {
+ $this->collAddresses->append($obj);
+ }
+ }
+
+ $this->collAddressesPartial = true;
+ }
+
+ $collAddresses->getInternalIterator()->rewind();
+
+ return $collAddresses;
+ }
+
+ if ($partial && $this->collAddresses) {
+ foreach ($this->collAddresses as $obj) {
+ if ($obj->isNew()) {
+ $collAddresses[] = $obj;
+ }
+ }
+ }
+
+ $this->collAddresses = $collAddresses;
+ $this->collAddressesPartial = false;
+ }
+ }
+
+ return $this->collAddresses;
+ }
+
+ /**
+ * Sets a collection of Address objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $addresses A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCustomer The current object (for fluent API support)
+ */
+ public function setAddresses(Collection $addresses, ConnectionInterface $con = null)
+ {
+ $addressesToDelete = $this->getAddresses(new Criteria(), $con)->diff($addresses);
+
+
+ $this->addressesScheduledForDeletion = $addressesToDelete;
+
+ foreach ($addressesToDelete as $addressRemoved) {
+ $addressRemoved->setCustomer(null);
+ }
+
+ $this->collAddresses = null;
+ foreach ($addresses as $address) {
+ $this->addAddress($address);
+ }
+
+ $this->collAddresses = $addresses;
+ $this->collAddressesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Address objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Address objects.
+ * @throws PropelException
+ */
+ public function countAddresses(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAddressesPartial && !$this->isNew();
+ if (null === $this->collAddresses || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAddresses) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getAddresses());
+ }
+
+ $query = ChildAddressQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCustomer($this)
+ ->count($con);
+ }
+
+ return count($this->collAddresses);
+ }
+
+ /**
+ * Method called to associate a ChildAddress object to this object
+ * through the ChildAddress foreign key attribute.
+ *
+ * @param ChildAddress $l ChildAddress
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function addAddress(ChildAddress $l)
+ {
+ if ($this->collAddresses === null) {
+ $this->initAddresses();
+ $this->collAddressesPartial = true;
+ }
+
+ if (!in_array($l, $this->collAddresses->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddAddress($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Address $address The address object to add.
+ */
+ protected function doAddAddress($address)
+ {
+ $this->collAddresses[]= $address;
+ $address->setCustomer($this);
+ }
+
+ /**
+ * @param Address $address The address object to remove.
+ * @return ChildCustomer The current object (for fluent API support)
+ */
+ public function removeAddress($address)
+ {
+ if ($this->getAddresses()->contains($address)) {
+ $this->collAddresses->remove($this->collAddresses->search($address));
+ if (null === $this->addressesScheduledForDeletion) {
+ $this->addressesScheduledForDeletion = clone $this->collAddresses;
+ $this->addressesScheduledForDeletion->clear();
+ }
+ $this->addressesScheduledForDeletion[]= clone $address;
+ $address->setCustomer(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Customer is new, it will return
+ * an empty collection; or if this Customer has previously
+ * been saved, it will retrieve related Addresses 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 Customer.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildAddress[] List of ChildAddress objects
+ */
+ public function getAddressesJoinCustomerTitle($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildAddressQuery::create(null, $criteria);
+ $query->joinWith('CustomerTitle', $joinBehavior);
+
+ return $this->getAddresses($query, $con);
+ }
+
+ /**
+ * Clears out the collOrders collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addOrders()
+ */
+ public function clearOrders()
+ {
+ $this->collOrders = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collOrders collection loaded partially.
+ */
+ public function resetPartialOrders($v = true)
+ {
+ $this->collOrdersPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrders collection.
+ *
+ * By default this just sets the collOrders collection to an empty array (like clearcollOrders());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initOrders($overrideExisting = true)
+ {
+ if (null !== $this->collOrders && !$overrideExisting) {
+ return;
+ }
+ $this->collOrders = new ObjectCollection();
+ $this->collOrders->setModel('\Thelia\Model\Order');
+ }
+
+ /**
+ * Gets an array of ChildOrder objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCustomer is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ * @throws PropelException
+ */
+ public function getOrders($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrdersPartial && !$this->isNew();
+ if (null === $this->collOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrders) {
+ // return empty collection
+ $this->initOrders();
+ } else {
+ $collOrders = ChildOrderQuery::create(null, $criteria)
+ ->filterByCustomer($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collOrdersPartial && count($collOrders)) {
+ $this->initOrders(false);
+
+ foreach ($collOrders as $obj) {
+ if (false == $this->collOrders->contains($obj)) {
+ $this->collOrders->append($obj);
+ }
+ }
+
+ $this->collOrdersPartial = true;
+ }
+
+ $collOrders->getInternalIterator()->rewind();
+
+ return $collOrders;
+ }
+
+ if ($partial && $this->collOrders) {
+ foreach ($this->collOrders as $obj) {
+ if ($obj->isNew()) {
+ $collOrders[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrders = $collOrders;
+ $this->collOrdersPartial = false;
+ }
+ }
+
+ return $this->collOrders;
+ }
+
+ /**
+ * Sets a collection of Order objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $orders A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCustomer The current object (for fluent API support)
+ */
+ public function setOrders(Collection $orders, ConnectionInterface $con = null)
+ {
+ $ordersToDelete = $this->getOrders(new Criteria(), $con)->diff($orders);
+
+
+ $this->ordersScheduledForDeletion = $ordersToDelete;
+
+ foreach ($ordersToDelete as $orderRemoved) {
+ $orderRemoved->setCustomer(null);
+ }
+
+ $this->collOrders = null;
+ foreach ($orders as $order) {
+ $this->addOrder($order);
+ }
+
+ $this->collOrders = $orders;
+ $this->collOrdersPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Order objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Order objects.
+ * @throws PropelException
+ */
+ public function countOrders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrdersPartial && !$this->isNew();
+ if (null === $this->collOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrders) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getOrders());
+ }
+
+ $query = ChildOrderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCustomer($this)
+ ->count($con);
+ }
+
+ return count($this->collOrders);
+ }
+
+ /**
+ * Method called to associate a ChildOrder object to this object
+ * through the ChildOrder foreign key attribute.
+ *
+ * @param ChildOrder $l ChildOrder
+ * @return \Thelia\Model\Customer The current object (for fluent API support)
+ */
+ public function addOrder(ChildOrder $l)
+ {
+ if ($this->collOrders === null) {
+ $this->initOrders();
+ $this->collOrdersPartial = true;
+ }
+
+ if (!in_array($l, $this->collOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddOrder($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Order $order The order object to add.
+ */
+ protected function doAddOrder($order)
+ {
+ $this->collOrders[]= $order;
+ $order->setCustomer($this);
+ }
+
+ /**
+ * @param Order $order The order object to remove.
+ * @return ChildCustomer The current object (for fluent API support)
+ */
+ public function removeOrder($order)
+ {
+ if ($this->getOrders()->contains($order)) {
+ $this->collOrders->remove($this->collOrders->search($order));
+ if (null === $this->ordersScheduledForDeletion) {
+ $this->ordersScheduledForDeletion = clone $this->collOrders;
+ $this->ordersScheduledForDeletion->clear();
+ }
+ $this->ordersScheduledForDeletion[]= clone $order;
+ $order->setCustomer(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Customer is new, it will return
+ * an empty collection; or if this Customer has previously
+ * been saved, it will retrieve related Orders 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 Customer.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('Currency', $joinBehavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Customer is new, it will return
+ * an empty collection; or if this Customer has previously
+ * been saved, it will retrieve related Orders 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 Customer.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('OrderAddressRelatedByAddressInvoice', $joinBehavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Customer is new, it will return
+ * an empty collection; or if this Customer has previously
+ * been saved, it will retrieve related Orders 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 Customer.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('OrderAddressRelatedByAddressDelivery', $joinBehavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Customer is new, it will return
+ * an empty collection; or if this Customer has previously
+ * been saved, it will retrieve related Orders 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 Customer.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('OrderStatus', $joinBehavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->ref = null;
+ $this->customer_title_id = null;
+ $this->company = null;
+ $this->firstname = null;
+ $this->lastname = null;
+ $this->address1 = null;
+ $this->address2 = null;
+ $this->address3 = null;
+ $this->zipcode = null;
+ $this->city = null;
+ $this->country_id = null;
+ $this->phone = null;
+ $this->cellphone = null;
+ $this->email = null;
+ $this->password = null;
+ $this->algo = null;
+ $this->salt = null;
+ $this->reseller = null;
+ $this->lang = null;
+ $this->sponsor = null;
+ $this->discount = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collAddresses) {
+ foreach ($this->collAddresses as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collOrders) {
+ foreach ($this->collOrders as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collAddresses instanceof Collection) {
+ $this->collAddresses->clearIterator();
+ }
+ $this->collAddresses = null;
+ if ($this->collOrders instanceof Collection) {
+ $this->collOrders->clearIterator();
+ }
+ $this->collOrders = null;
+ $this->aCustomerTitle = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CustomerTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCustomer The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = CustomerTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/CustomerQuery.php b/core/lib/Thelia/Model/Base/CustomerQuery.php
new file mode 100644
index 000000000..eb6371592
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CustomerQuery.php
@@ -0,0 +1,1483 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCustomer|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CustomerTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CustomerTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCustomer A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, REF, CUSTOMER_TITLE_ID, COMPANY, FIRSTNAME, LASTNAME, ADDRESS1, ADDRESS2, ADDRESS3, ZIPCODE, CITY, COUNTRY_ID, PHONE, CELLPHONE, EMAIL, PASSWORD, ALGO, SALT, RESELLER, LANG, SPONSOR, DISCOUNT, CREATED_AT, UPDATED_AT FROM customer WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildCustomer();
+ $obj->hydrate($row);
+ CustomerTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCustomer|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CustomerTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CustomerTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CustomerTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CustomerTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
+ * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $ref The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByRef($ref = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($ref)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $ref)) {
+ $ref = str_replace('*', '%', $ref);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::REF, $ref, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_title_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234
+ * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34)
+ * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12
+ *
+ *
+ * @see filterByCustomerTitle()
+ *
+ * @param mixed $customerTitleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByCustomerTitleId($customerTitleId = null, $comparison = null)
+ {
+ if (is_array($customerTitleId)) {
+ $useMinMax = false;
+ if (isset($customerTitleId['min'])) {
+ $this->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerTitleId['max'])) {
+ $this->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the company column
+ *
+ * Example usage:
+ *
+ * $query->filterByCompany('fooValue'); // WHERE company = 'fooValue'
+ * $query->filterByCompany('%fooValue%'); // WHERE company LIKE '%fooValue%'
+ *
+ *
+ * @param string $company The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByCompany($company = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($company)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $company)) {
+ $company = str_replace('*', '%', $company);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::COMPANY, $company, $comparison);
+ }
+
+ /**
+ * Filter the query on the firstname column
+ *
+ * Example usage:
+ *
+ * $query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue'
+ * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%'
+ *
+ *
+ * @param string $firstname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByFirstname($firstname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($firstname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $firstname)) {
+ $firstname = str_replace('*', '%', $firstname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::FIRSTNAME, $firstname, $comparison);
+ }
+
+ /**
+ * Filter the query on the lastname column
+ *
+ * Example usage:
+ *
+ * $query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue'
+ * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%'
+ *
+ *
+ * @param string $lastname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByLastname($lastname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lastname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lastname)) {
+ $lastname = str_replace('*', '%', $lastname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::LASTNAME, $lastname, $comparison);
+ }
+
+ /**
+ * Filter the query on the address1 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress1('fooValue'); // WHERE address1 = 'fooValue'
+ * $query->filterByAddress1('%fooValue%'); // WHERE address1 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address1 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByAddress1($address1 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address1)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address1)) {
+ $address1 = str_replace('*', '%', $address1);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::ADDRESS1, $address1, $comparison);
+ }
+
+ /**
+ * Filter the query on the address2 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress2('fooValue'); // WHERE address2 = 'fooValue'
+ * $query->filterByAddress2('%fooValue%'); // WHERE address2 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address2 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByAddress2($address2 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address2)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address2)) {
+ $address2 = str_replace('*', '%', $address2);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::ADDRESS2, $address2, $comparison);
+ }
+
+ /**
+ * Filter the query on the address3 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress3('fooValue'); // WHERE address3 = 'fooValue'
+ * $query->filterByAddress3('%fooValue%'); // WHERE address3 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address3 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByAddress3($address3 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address3)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address3)) {
+ $address3 = str_replace('*', '%', $address3);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::ADDRESS3, $address3, $comparison);
+ }
+
+ /**
+ * Filter the query on the zipcode column
+ *
+ * Example usage:
+ *
+ * $query->filterByZipcode('fooValue'); // WHERE zipcode = 'fooValue'
+ * $query->filterByZipcode('%fooValue%'); // WHERE zipcode LIKE '%fooValue%'
+ *
+ *
+ * @param string $zipcode The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByZipcode($zipcode = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($zipcode)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $zipcode)) {
+ $zipcode = str_replace('*', '%', $zipcode);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::ZIPCODE, $zipcode, $comparison);
+ }
+
+ /**
+ * Filter the query on the city column
+ *
+ * Example usage:
+ *
+ * $query->filterByCity('fooValue'); // WHERE city = 'fooValue'
+ * $query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%'
+ *
+ *
+ * @param string $city The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByCity($city = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($city)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $city)) {
+ $city = str_replace('*', '%', $city);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::CITY, $city, $comparison);
+ }
+
+ /**
+ * Filter the query on the country_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCountryId(1234); // WHERE country_id = 1234
+ * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
+ * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
+ *
+ *
+ * @param mixed $countryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByCountryId($countryId = null, $comparison = null)
+ {
+ if (is_array($countryId)) {
+ $useMinMax = false;
+ if (isset($countryId['min'])) {
+ $this->addUsingAlias(CustomerTableMap::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($countryId['max'])) {
+ $this->addUsingAlias(CustomerTableMap::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::COUNTRY_ID, $countryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the phone column
+ *
+ * Example usage:
+ *
+ * $query->filterByPhone('fooValue'); // WHERE phone = 'fooValue'
+ * $query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%'
+ *
+ *
+ * @param string $phone The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByPhone($phone = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($phone)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $phone)) {
+ $phone = str_replace('*', '%', $phone);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::PHONE, $phone, $comparison);
+ }
+
+ /**
+ * Filter the query on the cellphone column
+ *
+ * Example usage:
+ *
+ * $query->filterByCellphone('fooValue'); // WHERE cellphone = 'fooValue'
+ * $query->filterByCellphone('%fooValue%'); // WHERE cellphone LIKE '%fooValue%'
+ *
+ *
+ * @param string $cellphone The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByCellphone($cellphone = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($cellphone)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $cellphone)) {
+ $cellphone = str_replace('*', '%', $cellphone);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::CELLPHONE, $cellphone, $comparison);
+ }
+
+ /**
+ * Filter the query on the email column
+ *
+ * Example usage:
+ *
+ * $query->filterByEmail('fooValue'); // WHERE email = 'fooValue'
+ * $query->filterByEmail('%fooValue%'); // WHERE email LIKE '%fooValue%'
+ *
+ *
+ * @param string $email The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByEmail($email = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($email)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $email)) {
+ $email = str_replace('*', '%', $email);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::EMAIL, $email, $comparison);
+ }
+
+ /**
+ * Filter the query on the password column
+ *
+ * Example usage:
+ *
+ * $query->filterByPassword('fooValue'); // WHERE password = 'fooValue'
+ * $query->filterByPassword('%fooValue%'); // WHERE password LIKE '%fooValue%'
+ *
+ *
+ * @param string $password The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByPassword($password = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($password)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $password)) {
+ $password = str_replace('*', '%', $password);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::PASSWORD, $password, $comparison);
+ }
+
+ /**
+ * Filter the query on the algo column
+ *
+ * Example usage:
+ *
+ * $query->filterByAlgo('fooValue'); // WHERE algo = 'fooValue'
+ * $query->filterByAlgo('%fooValue%'); // WHERE algo LIKE '%fooValue%'
+ *
+ *
+ * @param string $algo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByAlgo($algo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($algo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $algo)) {
+ $algo = str_replace('*', '%', $algo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::ALGO, $algo, $comparison);
+ }
+
+ /**
+ * Filter the query on the salt column
+ *
+ * Example usage:
+ *
+ * $query->filterBySalt('fooValue'); // WHERE salt = 'fooValue'
+ * $query->filterBySalt('%fooValue%'); // WHERE salt LIKE '%fooValue%'
+ *
+ *
+ * @param string $salt The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterBySalt($salt = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($salt)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $salt)) {
+ $salt = str_replace('*', '%', $salt);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::SALT, $salt, $comparison);
+ }
+
+ /**
+ * Filter the query on the reseller column
+ *
+ * Example usage:
+ *
+ * $query->filterByReseller(1234); // WHERE reseller = 1234
+ * $query->filterByReseller(array(12, 34)); // WHERE reseller IN (12, 34)
+ * $query->filterByReseller(array('min' => 12)); // WHERE reseller > 12
+ *
+ *
+ * @param mixed $reseller The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByReseller($reseller = null, $comparison = null)
+ {
+ if (is_array($reseller)) {
+ $useMinMax = false;
+ if (isset($reseller['min'])) {
+ $this->addUsingAlias(CustomerTableMap::RESELLER, $reseller['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($reseller['max'])) {
+ $this->addUsingAlias(CustomerTableMap::RESELLER, $reseller['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::RESELLER, $reseller, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the sponsor column
+ *
+ * Example usage:
+ *
+ * $query->filterBySponsor('fooValue'); // WHERE sponsor = 'fooValue'
+ * $query->filterBySponsor('%fooValue%'); // WHERE sponsor LIKE '%fooValue%'
+ *
+ *
+ * @param string $sponsor The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterBySponsor($sponsor = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($sponsor)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $sponsor)) {
+ $sponsor = str_replace('*', '%', $sponsor);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::SPONSOR, $sponsor, $comparison);
+ }
+
+ /**
+ * Filter the query on the discount column
+ *
+ * Example usage:
+ *
+ * $query->filterByDiscount(1234); // WHERE discount = 1234
+ * $query->filterByDiscount(array(12, 34)); // WHERE discount IN (12, 34)
+ * $query->filterByDiscount(array('min' => 12)); // WHERE discount > 12
+ *
+ *
+ * @param mixed $discount The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByDiscount($discount = null, $comparison = null)
+ {
+ if (is_array($discount)) {
+ $useMinMax = false;
+ if (isset($discount['min'])) {
+ $this->addUsingAlias(CustomerTableMap::DISCOUNT, $discount['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($discount['max'])) {
+ $this->addUsingAlias(CustomerTableMap::DISCOUNT, $discount['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::DISCOUNT, $discount, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CustomerTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CustomerTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CustomerTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CustomerTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\CustomerTitle object
+ *
+ * @param \Thelia\Model\CustomerTitle|ObjectCollection $customerTitle The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByCustomerTitle($customerTitle, $comparison = null)
+ {
+ if ($customerTitle instanceof \Thelia\Model\CustomerTitle) {
+ return $this
+ ->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison);
+ } elseif ($customerTitle instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCustomerTitle() only accepts arguments of type \Thelia\Model\CustomerTitle or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CustomerTitle relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CustomerTitle');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'CustomerTitle');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CustomerTitle relation CustomerTitle object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query
+ */
+ public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCustomerTitle($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Address object
+ *
+ * @param \Thelia\Model\Address|ObjectCollection $address the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByAddress($address, $comparison = null)
+ {
+ if ($address instanceof \Thelia\Model\Address) {
+ return $this
+ ->addUsingAlias(CustomerTableMap::ID, $address->getCustomerId(), $comparison);
+ } elseif ($address instanceof ObjectCollection) {
+ return $this
+ ->useAddressQuery()
+ ->filterByPrimaryKeys($address->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAddress() only accepts arguments of type \Thelia\Model\Address or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Address relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function joinAddress($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Address');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Address');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Address relation Address object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AddressQuery A secondary query class using the current class as primary query
+ */
+ public function useAddressQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAddress($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Address', '\Thelia\Model\AddressQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Order object
+ *
+ * @param \Thelia\Model\Order|ObjectCollection $order the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function filterByOrder($order, $comparison = null)
+ {
+ if ($order instanceof \Thelia\Model\Order) {
+ return $this
+ ->addUsingAlias(CustomerTableMap::ID, $order->getCustomerId(), $comparison);
+ } elseif ($order instanceof ObjectCollection) {
+ return $this
+ ->useOrderQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Order relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Order');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Order');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Order relation Order object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCustomer $customer Object to remove from the list of results
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function prune($customer = null)
+ {
+ if ($customer) {
+ $this->addUsingAlias(CustomerTableMap::ID, $customer->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the customer table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CustomerTableMap::clearInstancePool();
+ CustomerTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCustomer or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCustomer object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CustomerTableMap::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->beginTransaction();
+
+
+ CustomerTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CustomerTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CustomerTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CustomerTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CustomerTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CustomerTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CustomerTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCustomerQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CustomerTableMap::CREATED_AT);
+ }
+
+} // CustomerQuery
diff --git a/core/lib/Thelia/Model/Base/CustomerTitle.php b/core/lib/Thelia/Model/Base/CustomerTitle.php
new file mode 100644
index 000000000..c060f7fae
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CustomerTitle.php
@@ -0,0 +1,2392 @@
+by_default = 0;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\CustomerTitle object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CustomerTitle instance. If
+ * obj is an instance of CustomerTitle, delegates to
+ * equals(CustomerTitle). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CustomerTitle The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CustomerTitle The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [by_default] column value.
+ *
+ * @return int
+ */
+ public function getByDefault()
+ {
+
+ return $this->by_default;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return string
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\CustomerTitle The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CustomerTitleTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [by_default] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\CustomerTitle The current object (for fluent API support)
+ */
+ public function setByDefault($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->by_default !== $v) {
+ $this->by_default = $v;
+ $this->modifiedColumns[] = CustomerTitleTableMap::BY_DEFAULT;
+ }
+
+
+ return $this;
+ } // setByDefault()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CustomerTitle The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = CustomerTitleTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\CustomerTitle The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = CustomerTitleTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\CustomerTitle The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = CustomerTitleTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->by_default !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CustomerTitleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerTitleTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->by_default = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerTitleTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerTitleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerTitleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = CustomerTitleTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\CustomerTitle object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CustomerTitleTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCustomerTitleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collCustomers = null;
+
+ $this->collAddresses = null;
+
+ $this->collCustomerTitleI18ns = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CustomerTitle::setDeleted()
+ * @see CustomerTitle::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCustomerTitleQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(CustomerTitleTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(CustomerTitleTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(CustomerTitleTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CustomerTitleTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->customersScheduledForDeletion !== null) {
+ if (!$this->customersScheduledForDeletion->isEmpty()) {
+ foreach ($this->customersScheduledForDeletion as $customer) {
+ // need to save related object because we set the relation to null
+ $customer->save($con);
+ }
+ $this->customersScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCustomers !== null) {
+ foreach ($this->collCustomers as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->addressesScheduledForDeletion !== null) {
+ if (!$this->addressesScheduledForDeletion->isEmpty()) {
+ foreach ($this->addressesScheduledForDeletion as $address) {
+ // need to save related object because we set the relation to null
+ $address->save($con);
+ }
+ $this->addressesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAddresses !== null) {
+ foreach ($this->collAddresses as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->customerTitleI18nsScheduledForDeletion !== null) {
+ if (!$this->customerTitleI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\CustomerTitleI18nQuery::create()
+ ->filterByPrimaryKeys($this->customerTitleI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->customerTitleI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCustomerTitleI18ns !== null) {
+ foreach ($this->collCustomerTitleI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = CustomerTitleTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . CustomerTitleTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CustomerTitleTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CustomerTitleTableMap::BY_DEFAULT)) {
+ $modifiedColumns[':p' . $index++] = 'BY_DEFAULT';
+ }
+ if ($this->isColumnModified(CustomerTitleTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(CustomerTitleTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(CustomerTitleTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO customer_title (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'BY_DEFAULT':
+ $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CustomerTitleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getByDefault();
+ break;
+ case 2:
+ return $this->getPosition();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CustomerTitle'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CustomerTitle'][$this->getPrimaryKey()] = true;
+ $keys = CustomerTitleTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getByDefault(),
+ $keys[2] => $this->getPosition(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collCustomers) {
+ $result['Customers'] = $this->collCustomers->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collAddresses) {
+ $result['Addresses'] = $this->collAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCustomerTitleI18ns) {
+ $result['CustomerTitleI18ns'] = $this->collCustomerTitleI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CustomerTitleTableMap::translateFieldName($name, $type, TableMap::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->setByDefault($value);
+ break;
+ case 2:
+ $this->setPosition($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CustomerTitleTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setByDefault($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * 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(CustomerTitleTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CustomerTitleTableMap::ID)) $criteria->add(CustomerTitleTableMap::ID, $this->id);
+ if ($this->isColumnModified(CustomerTitleTableMap::BY_DEFAULT)) $criteria->add(CustomerTitleTableMap::BY_DEFAULT, $this->by_default);
+ if ($this->isColumnModified(CustomerTitleTableMap::POSITION)) $criteria->add(CustomerTitleTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(CustomerTitleTableMap::CREATED_AT)) $criteria->add(CustomerTitleTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(CustomerTitleTableMap::UPDATED_AT)) $criteria->add(CustomerTitleTableMap::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(CustomerTitleTableMap::DATABASE_NAME);
+ $criteria->add(CustomerTitleTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\CustomerTitle (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setByDefault($this->getByDefault());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getCustomers() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCustomer($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getAddresses() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAddress($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getCustomerTitleI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCustomerTitleI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\CustomerTitle 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('Customer' == $relationName) {
+ return $this->initCustomers();
+ }
+ if ('Address' == $relationName) {
+ return $this->initAddresses();
+ }
+ if ('CustomerTitleI18n' == $relationName) {
+ return $this->initCustomerTitleI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collCustomers collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCustomers()
+ */
+ public function clearCustomers()
+ {
+ $this->collCustomers = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCustomers collection loaded partially.
+ */
+ public function resetPartialCustomers($v = true)
+ {
+ $this->collCustomersPartial = $v;
+ }
+
+ /**
+ * Initializes the collCustomers collection.
+ *
+ * By default this just sets the collCustomers collection to an empty array (like clearcollCustomers());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCustomers($overrideExisting = true)
+ {
+ if (null !== $this->collCustomers && !$overrideExisting) {
+ return;
+ }
+ $this->collCustomers = new ObjectCollection();
+ $this->collCustomers->setModel('\Thelia\Model\Customer');
+ }
+
+ /**
+ * Gets an array of ChildCustomer objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCustomerTitle is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCustomer[] List of ChildCustomer objects
+ * @throws PropelException
+ */
+ public function getCustomers($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCustomersPartial && !$this->isNew();
+ if (null === $this->collCustomers || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCustomers) {
+ // return empty collection
+ $this->initCustomers();
+ } else {
+ $collCustomers = ChildCustomerQuery::create(null, $criteria)
+ ->filterByCustomerTitle($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCustomersPartial && count($collCustomers)) {
+ $this->initCustomers(false);
+
+ foreach ($collCustomers as $obj) {
+ if (false == $this->collCustomers->contains($obj)) {
+ $this->collCustomers->append($obj);
+ }
+ }
+
+ $this->collCustomersPartial = true;
+ }
+
+ $collCustomers->getInternalIterator()->rewind();
+
+ return $collCustomers;
+ }
+
+ if ($partial && $this->collCustomers) {
+ foreach ($this->collCustomers as $obj) {
+ if ($obj->isNew()) {
+ $collCustomers[] = $obj;
+ }
+ }
+ }
+
+ $this->collCustomers = $collCustomers;
+ $this->collCustomersPartial = false;
+ }
+ }
+
+ return $this->collCustomers;
+ }
+
+ /**
+ * Sets a collection of Customer objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $customers A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCustomerTitle The current object (for fluent API support)
+ */
+ public function setCustomers(Collection $customers, ConnectionInterface $con = null)
+ {
+ $customersToDelete = $this->getCustomers(new Criteria(), $con)->diff($customers);
+
+
+ $this->customersScheduledForDeletion = $customersToDelete;
+
+ foreach ($customersToDelete as $customerRemoved) {
+ $customerRemoved->setCustomerTitle(null);
+ }
+
+ $this->collCustomers = null;
+ foreach ($customers as $customer) {
+ $this->addCustomer($customer);
+ }
+
+ $this->collCustomers = $customers;
+ $this->collCustomersPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Customer objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Customer objects.
+ * @throws PropelException
+ */
+ public function countCustomers(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCustomersPartial && !$this->isNew();
+ if (null === $this->collCustomers || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCustomers) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCustomers());
+ }
+
+ $query = ChildCustomerQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCustomerTitle($this)
+ ->count($con);
+ }
+
+ return count($this->collCustomers);
+ }
+
+ /**
+ * Method called to associate a ChildCustomer object to this object
+ * through the ChildCustomer foreign key attribute.
+ *
+ * @param ChildCustomer $l ChildCustomer
+ * @return \Thelia\Model\CustomerTitle The current object (for fluent API support)
+ */
+ public function addCustomer(ChildCustomer $l)
+ {
+ if ($this->collCustomers === null) {
+ $this->initCustomers();
+ $this->collCustomersPartial = true;
+ }
+
+ if (!in_array($l, $this->collCustomers->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCustomer($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Customer $customer The customer object to add.
+ */
+ protected function doAddCustomer($customer)
+ {
+ $this->collCustomers[]= $customer;
+ $customer->setCustomerTitle($this);
+ }
+
+ /**
+ * @param Customer $customer The customer object to remove.
+ * @return ChildCustomerTitle The current object (for fluent API support)
+ */
+ public function removeCustomer($customer)
+ {
+ if ($this->getCustomers()->contains($customer)) {
+ $this->collCustomers->remove($this->collCustomers->search($customer));
+ if (null === $this->customersScheduledForDeletion) {
+ $this->customersScheduledForDeletion = clone $this->collCustomers;
+ $this->customersScheduledForDeletion->clear();
+ }
+ $this->customersScheduledForDeletion[]= $customer;
+ $customer->setCustomerTitle(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collAddresses collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAddresses()
+ */
+ public function clearAddresses()
+ {
+ $this->collAddresses = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collAddresses collection loaded partially.
+ */
+ public function resetPartialAddresses($v = true)
+ {
+ $this->collAddressesPartial = $v;
+ }
+
+ /**
+ * Initializes the collAddresses collection.
+ *
+ * By default this just sets the collAddresses collection to an empty array (like clearcollAddresses());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAddresses($overrideExisting = true)
+ {
+ if (null !== $this->collAddresses && !$overrideExisting) {
+ return;
+ }
+ $this->collAddresses = new ObjectCollection();
+ $this->collAddresses->setModel('\Thelia\Model\Address');
+ }
+
+ /**
+ * Gets an array of ChildAddress objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCustomerTitle is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildAddress[] List of ChildAddress objects
+ * @throws PropelException
+ */
+ public function getAddresses($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAddressesPartial && !$this->isNew();
+ if (null === $this->collAddresses || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAddresses) {
+ // return empty collection
+ $this->initAddresses();
+ } else {
+ $collAddresses = ChildAddressQuery::create(null, $criteria)
+ ->filterByCustomerTitle($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collAddressesPartial && count($collAddresses)) {
+ $this->initAddresses(false);
+
+ foreach ($collAddresses as $obj) {
+ if (false == $this->collAddresses->contains($obj)) {
+ $this->collAddresses->append($obj);
+ }
+ }
+
+ $this->collAddressesPartial = true;
+ }
+
+ $collAddresses->getInternalIterator()->rewind();
+
+ return $collAddresses;
+ }
+
+ if ($partial && $this->collAddresses) {
+ foreach ($this->collAddresses as $obj) {
+ if ($obj->isNew()) {
+ $collAddresses[] = $obj;
+ }
+ }
+ }
+
+ $this->collAddresses = $collAddresses;
+ $this->collAddressesPartial = false;
+ }
+ }
+
+ return $this->collAddresses;
+ }
+
+ /**
+ * Sets a collection of Address objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $addresses A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCustomerTitle The current object (for fluent API support)
+ */
+ public function setAddresses(Collection $addresses, ConnectionInterface $con = null)
+ {
+ $addressesToDelete = $this->getAddresses(new Criteria(), $con)->diff($addresses);
+
+
+ $this->addressesScheduledForDeletion = $addressesToDelete;
+
+ foreach ($addressesToDelete as $addressRemoved) {
+ $addressRemoved->setCustomerTitle(null);
+ }
+
+ $this->collAddresses = null;
+ foreach ($addresses as $address) {
+ $this->addAddress($address);
+ }
+
+ $this->collAddresses = $addresses;
+ $this->collAddressesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Address objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Address objects.
+ * @throws PropelException
+ */
+ public function countAddresses(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAddressesPartial && !$this->isNew();
+ if (null === $this->collAddresses || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAddresses) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getAddresses());
+ }
+
+ $query = ChildAddressQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCustomerTitle($this)
+ ->count($con);
+ }
+
+ return count($this->collAddresses);
+ }
+
+ /**
+ * Method called to associate a ChildAddress object to this object
+ * through the ChildAddress foreign key attribute.
+ *
+ * @param ChildAddress $l ChildAddress
+ * @return \Thelia\Model\CustomerTitle The current object (for fluent API support)
+ */
+ public function addAddress(ChildAddress $l)
+ {
+ if ($this->collAddresses === null) {
+ $this->initAddresses();
+ $this->collAddressesPartial = true;
+ }
+
+ if (!in_array($l, $this->collAddresses->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddAddress($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Address $address The address object to add.
+ */
+ protected function doAddAddress($address)
+ {
+ $this->collAddresses[]= $address;
+ $address->setCustomerTitle($this);
+ }
+
+ /**
+ * @param Address $address The address object to remove.
+ * @return ChildCustomerTitle The current object (for fluent API support)
+ */
+ public function removeAddress($address)
+ {
+ if ($this->getAddresses()->contains($address)) {
+ $this->collAddresses->remove($this->collAddresses->search($address));
+ if (null === $this->addressesScheduledForDeletion) {
+ $this->addressesScheduledForDeletion = clone $this->collAddresses;
+ $this->addressesScheduledForDeletion->clear();
+ }
+ $this->addressesScheduledForDeletion[]= $address;
+ $address->setCustomerTitle(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this CustomerTitle is new, it will return
+ * an empty collection; or if this CustomerTitle has previously
+ * been saved, it will retrieve related Addresses 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 CustomerTitle.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildAddress[] List of ChildAddress objects
+ */
+ public function getAddressesJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildAddressQuery::create(null, $criteria);
+ $query->joinWith('Customer', $joinBehavior);
+
+ return $this->getAddresses($query, $con);
+ }
+
+ /**
+ * Clears out the collCustomerTitleI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCustomerTitleI18ns()
+ */
+ public function clearCustomerTitleI18ns()
+ {
+ $this->collCustomerTitleI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCustomerTitleI18ns collection loaded partially.
+ */
+ public function resetPartialCustomerTitleI18ns($v = true)
+ {
+ $this->collCustomerTitleI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collCustomerTitleI18ns collection.
+ *
+ * By default this just sets the collCustomerTitleI18ns collection to an empty array (like clearcollCustomerTitleI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCustomerTitleI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collCustomerTitleI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collCustomerTitleI18ns = new ObjectCollection();
+ $this->collCustomerTitleI18ns->setModel('\Thelia\Model\CustomerTitleI18n');
+ }
+
+ /**
+ * Gets an array of ChildCustomerTitleI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildCustomerTitle is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCustomerTitleI18n[] List of ChildCustomerTitleI18n objects
+ * @throws PropelException
+ */
+ public function getCustomerTitleI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCustomerTitleI18nsPartial && !$this->isNew();
+ if (null === $this->collCustomerTitleI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCustomerTitleI18ns) {
+ // return empty collection
+ $this->initCustomerTitleI18ns();
+ } else {
+ $collCustomerTitleI18ns = ChildCustomerTitleI18nQuery::create(null, $criteria)
+ ->filterByCustomerTitle($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCustomerTitleI18nsPartial && count($collCustomerTitleI18ns)) {
+ $this->initCustomerTitleI18ns(false);
+
+ foreach ($collCustomerTitleI18ns as $obj) {
+ if (false == $this->collCustomerTitleI18ns->contains($obj)) {
+ $this->collCustomerTitleI18ns->append($obj);
+ }
+ }
+
+ $this->collCustomerTitleI18nsPartial = true;
+ }
+
+ $collCustomerTitleI18ns->getInternalIterator()->rewind();
+
+ return $collCustomerTitleI18ns;
+ }
+
+ if ($partial && $this->collCustomerTitleI18ns) {
+ foreach ($this->collCustomerTitleI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collCustomerTitleI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collCustomerTitleI18ns = $collCustomerTitleI18ns;
+ $this->collCustomerTitleI18nsPartial = false;
+ }
+ }
+
+ return $this->collCustomerTitleI18ns;
+ }
+
+ /**
+ * Sets a collection of CustomerTitleI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $customerTitleI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildCustomerTitle The current object (for fluent API support)
+ */
+ public function setCustomerTitleI18ns(Collection $customerTitleI18ns, ConnectionInterface $con = null)
+ {
+ $customerTitleI18nsToDelete = $this->getCustomerTitleI18ns(new Criteria(), $con)->diff($customerTitleI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->customerTitleI18nsScheduledForDeletion = clone $customerTitleI18nsToDelete;
+
+ foreach ($customerTitleI18nsToDelete as $customerTitleI18nRemoved) {
+ $customerTitleI18nRemoved->setCustomerTitle(null);
+ }
+
+ $this->collCustomerTitleI18ns = null;
+ foreach ($customerTitleI18ns as $customerTitleI18n) {
+ $this->addCustomerTitleI18n($customerTitleI18n);
+ }
+
+ $this->collCustomerTitleI18ns = $customerTitleI18ns;
+ $this->collCustomerTitleI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CustomerTitleI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CustomerTitleI18n objects.
+ * @throws PropelException
+ */
+ public function countCustomerTitleI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCustomerTitleI18nsPartial && !$this->isNew();
+ if (null === $this->collCustomerTitleI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCustomerTitleI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCustomerTitleI18ns());
+ }
+
+ $query = ChildCustomerTitleI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByCustomerTitle($this)
+ ->count($con);
+ }
+
+ return count($this->collCustomerTitleI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildCustomerTitleI18n object to this object
+ * through the ChildCustomerTitleI18n foreign key attribute.
+ *
+ * @param ChildCustomerTitleI18n $l ChildCustomerTitleI18n
+ * @return \Thelia\Model\CustomerTitle The current object (for fluent API support)
+ */
+ public function addCustomerTitleI18n(ChildCustomerTitleI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collCustomerTitleI18ns === null) {
+ $this->initCustomerTitleI18ns();
+ $this->collCustomerTitleI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collCustomerTitleI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCustomerTitleI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CustomerTitleI18n $customerTitleI18n The customerTitleI18n object to add.
+ */
+ protected function doAddCustomerTitleI18n($customerTitleI18n)
+ {
+ $this->collCustomerTitleI18ns[]= $customerTitleI18n;
+ $customerTitleI18n->setCustomerTitle($this);
+ }
+
+ /**
+ * @param CustomerTitleI18n $customerTitleI18n The customerTitleI18n object to remove.
+ * @return ChildCustomerTitle The current object (for fluent API support)
+ */
+ public function removeCustomerTitleI18n($customerTitleI18n)
+ {
+ if ($this->getCustomerTitleI18ns()->contains($customerTitleI18n)) {
+ $this->collCustomerTitleI18ns->remove($this->collCustomerTitleI18ns->search($customerTitleI18n));
+ if (null === $this->customerTitleI18nsScheduledForDeletion) {
+ $this->customerTitleI18nsScheduledForDeletion = clone $this->collCustomerTitleI18ns;
+ $this->customerTitleI18nsScheduledForDeletion->clear();
+ }
+ $this->customerTitleI18nsScheduledForDeletion[]= clone $customerTitleI18n;
+ $customerTitleI18n->setCustomerTitle(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->by_default = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collCustomers) {
+ foreach ($this->collCustomers as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAddresses) {
+ foreach ($this->collAddresses as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCustomerTitleI18ns) {
+ foreach ($this->collCustomerTitleI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collCustomers instanceof Collection) {
+ $this->collCustomers->clearIterator();
+ }
+ $this->collCustomers = null;
+ if ($this->collAddresses instanceof Collection) {
+ $this->collAddresses->clearIterator();
+ }
+ $this->collAddresses = null;
+ if ($this->collCustomerTitleI18ns instanceof Collection) {
+ $this->collCustomerTitleI18ns->clearIterator();
+ }
+ $this->collCustomerTitleI18ns = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CustomerTitleTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildCustomerTitle The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = CustomerTitleTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildCustomerTitle The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCustomerTitleI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collCustomerTitleI18ns) {
+ foreach ($this->collCustomerTitleI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildCustomerTitleI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildCustomerTitleI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addCustomerTitleI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCustomerTitle The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildCustomerTitleI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collCustomerTitleI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collCustomerTitleI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCustomerTitleI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [short] column value.
+ *
+ * @return string
+ */
+ public function getShort()
+ {
+ return $this->getCurrentTranslation()->getShort();
+ }
+
+
+ /**
+ * Set the value of [short] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CustomerTitleI18n The current object (for fluent API support)
+ */
+ public function setShort($v)
+ { $this->getCurrentTranslation()->setShort($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [long] column value.
+ *
+ * @return string
+ */
+ public function getLong()
+ {
+ return $this->getCurrentTranslation()->getLong();
+ }
+
+
+ /**
+ * Set the value of [long] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CustomerTitleI18n The current object (for fluent API support)
+ */
+ public function setLong($v)
+ { $this->getCurrentTranslation()->setLong($v);
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/CustomerTitleI18n.php b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php
new file mode 100644
index 000000000..38e47ecda
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php
@@ -0,0 +1,1323 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\CustomerTitleI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another CustomerTitleI18n instance. If
+ * obj is an instance of CustomerTitleI18n, delegates to
+ * equals(CustomerTitleI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return CustomerTitleI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return CustomerTitleI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [short] column value.
+ *
+ * @return string
+ */
+ public function getShort()
+ {
+
+ return $this->short;
+ }
+
+ /**
+ * Get the [long] column value.
+ *
+ * @return string
+ */
+ public function getLong()
+ {
+
+ return $this->long;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\CustomerTitleI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = CustomerTitleI18nTableMap::ID;
+ }
+
+ if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) {
+ $this->aCustomerTitle = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CustomerTitleI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = CustomerTitleI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [short] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CustomerTitleI18n The current object (for fluent API support)
+ */
+ public function setShort($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->short !== $v) {
+ $this->short = $v;
+ $this->modifiedColumns[] = CustomerTitleI18nTableMap::SHORT;
+ }
+
+
+ return $this;
+ } // setShort()
+
+ /**
+ * Set the value of [long] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\CustomerTitleI18n The current object (for fluent API support)
+ */
+ public function setLong($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->long !== $v) {
+ $this->long = $v;
+ $this->modifiedColumns[] = CustomerTitleI18nTableMap::LONG;
+ }
+
+
+ return $this;
+ } // setLong()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CustomerTitleI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerTitleI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerTitleI18nTableMap::translateFieldName('Short', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->short = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerTitleI18nTableMap::translateFieldName('Long', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->long = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = CustomerTitleI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\CustomerTitleI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCustomerTitle !== null && $this->id !== $this->aCustomerTitle->getId()) {
+ $this->aCustomerTitle = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CustomerTitleI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildCustomerTitleI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCustomerTitle = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see CustomerTitleI18n::setDeleted()
+ * @see CustomerTitleI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildCustomerTitleI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ CustomerTitleI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCustomerTitle !== null) {
+ if ($this->aCustomerTitle->isModified() || $this->aCustomerTitle->isNew()) {
+ $affectedRows += $this->aCustomerTitle->save($con);
+ }
+ $this->setCustomerTitle($this->aCustomerTitle);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(CustomerTitleI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(CustomerTitleI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(CustomerTitleI18nTableMap::SHORT)) {
+ $modifiedColumns[':p' . $index++] = 'SHORT';
+ }
+ if ($this->isColumnModified(CustomerTitleI18nTableMap::LONG)) {
+ $modifiedColumns[':p' . $index++] = 'LONG';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO customer_title_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'SHORT':
+ $stmt->bindValue($identifier, $this->short, PDO::PARAM_STR);
+ break;
+ case 'LONG':
+ $stmt->bindValue($identifier, $this->long, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CustomerTitleI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getShort();
+ break;
+ case 3:
+ return $this->getLong();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['CustomerTitleI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['CustomerTitleI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = CustomerTitleI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getShort(),
+ $keys[3] => $this->getLong(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCustomerTitle) {
+ $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = CustomerTitleI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setShort($value);
+ break;
+ case 3:
+ $this->setLong($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = CustomerTitleI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setShort($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setLong($arr[$keys[3]]);
+ }
+
+ /**
+ * 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(CustomerTitleI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(CustomerTitleI18nTableMap::ID)) $criteria->add(CustomerTitleI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(CustomerTitleI18nTableMap::LOCALE)) $criteria->add(CustomerTitleI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(CustomerTitleI18nTableMap::SHORT)) $criteria->add(CustomerTitleI18nTableMap::SHORT, $this->short);
+ if ($this->isColumnModified(CustomerTitleI18nTableMap::LONG)) $criteria->add(CustomerTitleI18nTableMap::LONG, $this->long);
+
+ 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(CustomerTitleI18nTableMap::DATABASE_NAME);
+ $criteria->add(CustomerTitleI18nTableMap::ID, $this->id);
+ $criteria->add(CustomerTitleI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\CustomerTitleI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setShort($this->getShort());
+ $copyObj->setLong($this->getLong());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\CustomerTitleI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCustomerTitle object.
+ *
+ * @param ChildCustomerTitle $v
+ * @return \Thelia\Model\CustomerTitleI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCustomerTitle(ChildCustomerTitle $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aCustomerTitle = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCustomerTitle object, it will not be re-added.
+ if ($v !== null) {
+ $v->addCustomerTitleI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCustomerTitle object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCustomerTitle The associated ChildCustomerTitle object.
+ * @throws PropelException
+ */
+ public function getCustomerTitle(ConnectionInterface $con = null)
+ {
+ if ($this->aCustomerTitle === null && ($this->id !== null)) {
+ $this->aCustomerTitle = ChildCustomerTitleQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCustomerTitle->addCustomerTitleI18ns($this);
+ */
+ }
+
+ return $this->aCustomerTitle;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->short = null;
+ $this->long = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCustomerTitle = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(CustomerTitleI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/CustomerTitleI18nQuery.php b/core/lib/Thelia/Model/Base/CustomerTitleI18nQuery.php
new file mode 100644
index 000000000..4feeab473
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CustomerTitleI18nQuery.php
@@ -0,0 +1,541 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCustomerTitleI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CustomerTitleI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CustomerTitleI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCustomerTitleI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, SHORT, LONG FROM customer_title_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildCustomerTitleI18n();
+ $obj->hydrate($row);
+ CustomerTitleI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCustomerTitleI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCustomerTitleI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(CustomerTitleI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(CustomerTitleI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCustomerTitleI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(CustomerTitleI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(CustomerTitleI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByCustomerTitle()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerTitleI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CustomerTitleI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CustomerTitleI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerTitleI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the short column
+ *
+ * Example usage:
+ *
+ * $query->filterByShort('fooValue'); // WHERE short = 'fooValue'
+ * $query->filterByShort('%fooValue%'); // WHERE short LIKE '%fooValue%'
+ *
+ *
+ * @param string $short The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerTitleI18nQuery The current query, for fluid interface
+ */
+ public function filterByShort($short = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($short)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $short)) {
+ $short = str_replace('*', '%', $short);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleI18nTableMap::SHORT, $short, $comparison);
+ }
+
+ /**
+ * Filter the query on the long column
+ *
+ * Example usage:
+ *
+ * $query->filterByLong('fooValue'); // WHERE long = 'fooValue'
+ * $query->filterByLong('%fooValue%'); // WHERE long LIKE '%fooValue%'
+ *
+ *
+ * @param string $long The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerTitleI18nQuery The current query, for fluid interface
+ */
+ public function filterByLong($long = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($long)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $long)) {
+ $long = str_replace('*', '%', $long);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleI18nTableMap::LONG, $long, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\CustomerTitle object
+ *
+ * @param \Thelia\Model\CustomerTitle|ObjectCollection $customerTitle The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerTitleI18nQuery The current query, for fluid interface
+ */
+ public function filterByCustomerTitle($customerTitle, $comparison = null)
+ {
+ if ($customerTitle instanceof \Thelia\Model\CustomerTitle) {
+ return $this
+ ->addUsingAlias(CustomerTitleI18nTableMap::ID, $customerTitle->getId(), $comparison);
+ } elseif ($customerTitle instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(CustomerTitleI18nTableMap::ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCustomerTitle() only accepts arguments of type \Thelia\Model\CustomerTitle or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CustomerTitle relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCustomerTitleI18nQuery The current query, for fluid interface
+ */
+ public function joinCustomerTitle($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CustomerTitle');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'CustomerTitle');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CustomerTitle relation CustomerTitle object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query
+ */
+ public function useCustomerTitleQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinCustomerTitle($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCustomerTitleI18n $customerTitleI18n Object to remove from the list of results
+ *
+ * @return ChildCustomerTitleI18nQuery The current query, for fluid interface
+ */
+ public function prune($customerTitleI18n = null)
+ {
+ if ($customerTitleI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(CustomerTitleI18nTableMap::ID), $customerTitleI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(CustomerTitleI18nTableMap::LOCALE), $customerTitleI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the customer_title_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CustomerTitleI18nTableMap::clearInstancePool();
+ CustomerTitleI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCustomerTitleI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCustomerTitleI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CustomerTitleI18nTableMap::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->beginTransaction();
+
+
+ CustomerTitleI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CustomerTitleI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // CustomerTitleI18nQuery
diff --git a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php
new file mode 100644
index 000000000..a0b6d7b05
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php
@@ -0,0 +1,874 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildCustomerTitle|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = CustomerTitleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(CustomerTitleTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCustomerTitle A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, BY_DEFAULT, POSITION, CREATED_AT, UPDATED_AT FROM customer_title WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildCustomerTitle();
+ $obj->hydrate($row);
+ CustomerTitleTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildCustomerTitle|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(CustomerTitleTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(CustomerTitleTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(CustomerTitleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(CustomerTitleTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the by_default column
+ *
+ * Example usage:
+ *
+ * $query->filterByByDefault(1234); // WHERE by_default = 1234
+ * $query->filterByByDefault(array(12, 34)); // WHERE by_default IN (12, 34)
+ * $query->filterByByDefault(array('min' => 12)); // WHERE by_default > 12
+ *
+ *
+ * @param mixed $byDefault The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByByDefault($byDefault = null, $comparison = null)
+ {
+ if (is_array($byDefault)) {
+ $useMinMax = false;
+ if (isset($byDefault['min'])) {
+ $this->addUsingAlias(CustomerTitleTableMap::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($byDefault['max'])) {
+ $this->addUsingAlias(CustomerTitleTableMap::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleTableMap::BY_DEFAULT, $byDefault, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition('fooValue'); // WHERE position = 'fooValue'
+ * $query->filterByPosition('%fooValue%'); // WHERE position LIKE '%fooValue%'
+ *
+ *
+ * @param string $position The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($position)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $position)) {
+ $position = str_replace('*', '%', $position);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(CustomerTitleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(CustomerTitleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(CustomerTitleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(CustomerTitleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(CustomerTitleTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Customer object
+ *
+ * @param \Thelia\Model\Customer|ObjectCollection $customer the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByCustomer($customer, $comparison = null)
+ {
+ if ($customer instanceof \Thelia\Model\Customer) {
+ return $this
+ ->addUsingAlias(CustomerTitleTableMap::ID, $customer->getCustomerTitleId(), $comparison);
+ } elseif ($customer instanceof ObjectCollection) {
+ return $this
+ ->useCustomerQuery()
+ ->filterByPrimaryKeys($customer->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCustomer() only accepts arguments of type \Thelia\Model\Customer or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Customer relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function joinCustomer($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Customer');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Customer');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Customer relation Customer object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CustomerQuery A secondary query class using the current class as primary query
+ */
+ public function useCustomerQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCustomer($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Address object
+ *
+ * @param \Thelia\Model\Address|ObjectCollection $address the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByAddress($address, $comparison = null)
+ {
+ if ($address instanceof \Thelia\Model\Address) {
+ return $this
+ ->addUsingAlias(CustomerTitleTableMap::ID, $address->getCustomerTitleId(), $comparison);
+ } elseif ($address instanceof ObjectCollection) {
+ return $this
+ ->useAddressQuery()
+ ->filterByPrimaryKeys($address->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAddress() only accepts arguments of type \Thelia\Model\Address or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Address relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function joinAddress($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Address');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Address');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Address relation Address object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AddressQuery A secondary query class using the current class as primary query
+ */
+ public function useAddressQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinAddress($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Address', '\Thelia\Model\AddressQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\CustomerTitleI18n object
+ *
+ * @param \Thelia\Model\CustomerTitleI18n|ObjectCollection $customerTitleI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function filterByCustomerTitleI18n($customerTitleI18n, $comparison = null)
+ {
+ if ($customerTitleI18n instanceof \Thelia\Model\CustomerTitleI18n) {
+ return $this
+ ->addUsingAlias(CustomerTitleTableMap::ID, $customerTitleI18n->getId(), $comparison);
+ } elseif ($customerTitleI18n instanceof ObjectCollection) {
+ return $this
+ ->useCustomerTitleI18nQuery()
+ ->filterByPrimaryKeys($customerTitleI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCustomerTitleI18n() only accepts arguments of type \Thelia\Model\CustomerTitleI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CustomerTitleI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function joinCustomerTitleI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CustomerTitleI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'CustomerTitleI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CustomerTitleI18n relation CustomerTitleI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CustomerTitleI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useCustomerTitleI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinCustomerTitleI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CustomerTitleI18n', '\Thelia\Model\CustomerTitleI18nQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildCustomerTitle $customerTitle Object to remove from the list of results
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function prune($customerTitle = null)
+ {
+ if ($customerTitle) {
+ $this->addUsingAlias(CustomerTitleTableMap::ID, $customerTitle->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the customer_title table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ CustomerTitleTableMap::clearInstancePool();
+ CustomerTitleTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildCustomerTitle or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildCustomerTitle object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(CustomerTitleTableMap::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->beginTransaction();
+
+
+ CustomerTitleTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ CustomerTitleTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CustomerTitleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(CustomerTitleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CustomerTitleTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CustomerTitleTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(CustomerTitleTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(CustomerTitleTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'CustomerTitleI18n';
+
+ return $this
+ ->joinCustomerTitleI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCustomerTitleQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('CustomerTitleI18n');
+ $this->with['CustomerTitleI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildCustomerTitleI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CustomerTitleI18n', '\Thelia\Model\CustomerTitleI18nQuery');
+ }
+
+} // CustomerTitleQuery
diff --git a/core/lib/Thelia/Model/Base/Delivzone.php b/core/lib/Thelia/Model/Base/Delivzone.php
new file mode 100644
index 000000000..08125044e
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Delivzone.php
@@ -0,0 +1,1418 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Delivzone instance. If
+ * obj is an instance of Delivzone, delegates to
+ * equals(Delivzone). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Delivzone The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Delivzone The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [area_id] column value.
+ *
+ * @return int
+ */
+ public function getAreaId()
+ {
+
+ return $this->area_id;
+ }
+
+ /**
+ * Get the [delivery] column value.
+ *
+ * @return string
+ */
+ public function getDelivery()
+ {
+
+ return $this->delivery;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Delivzone The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = DelivzoneTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [area_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Delivzone The current object (for fluent API support)
+ */
+ public function setAreaId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->area_id !== $v) {
+ $this->area_id = $v;
+ $this->modifiedColumns[] = DelivzoneTableMap::AREA_ID;
+ }
+
+ if ($this->aArea !== null && $this->aArea->getId() !== $v) {
+ $this->aArea = null;
+ }
+
+
+ return $this;
+ } // setAreaId()
+
+ /**
+ * Set the value of [delivery] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Delivzone The current object (for fluent API support)
+ */
+ public function setDelivery($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->delivery !== $v) {
+ $this->delivery = $v;
+ $this->modifiedColumns[] = DelivzoneTableMap::DELIVERY;
+ }
+
+
+ return $this;
+ } // setDelivery()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Delivzone The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = DelivzoneTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Delivzone The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = DelivzoneTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : DelivzoneTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : DelivzoneTableMap::translateFieldName('AreaId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->area_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : DelivzoneTableMap::translateFieldName('Delivery', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->delivery = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : DelivzoneTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : DelivzoneTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = DelivzoneTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Delivzone object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aArea !== null && $this->area_id !== $this->aArea->getId()) {
+ $this->aArea = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(DelivzoneTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildDelivzoneQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aArea = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Delivzone::setDeleted()
+ * @see Delivzone::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildDelivzoneQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(DelivzoneTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ DelivzoneTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aArea !== null) {
+ if ($this->aArea->isModified() || $this->aArea->isNew()) {
+ $affectedRows += $this->aArea->save($con);
+ }
+ $this->setArea($this->aArea);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = DelivzoneTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . DelivzoneTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(DelivzoneTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(DelivzoneTableMap::AREA_ID)) {
+ $modifiedColumns[':p' . $index++] = 'AREA_ID';
+ }
+ if ($this->isColumnModified(DelivzoneTableMap::DELIVERY)) {
+ $modifiedColumns[':p' . $index++] = 'DELIVERY';
+ }
+ if ($this->isColumnModified(DelivzoneTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO delivzone (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'AREA_ID':
+ $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT);
+ break;
+ case 'DELIVERY':
+ $stmt->bindValue($identifier, $this->delivery, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = DelivzoneTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getAreaId();
+ break;
+ case 2:
+ return $this->getDelivery();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Delivzone'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Delivzone'][$this->getPrimaryKey()] = true;
+ $keys = DelivzoneTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getAreaId(),
+ $keys[2] => $this->getDelivery(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aArea) {
+ $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = DelivzoneTableMap::translateFieldName($name, $type, TableMap::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->setAreaId($value);
+ break;
+ case 2:
+ $this->setDelivery($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = DelivzoneTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setAreaId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setDelivery($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * 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(DelivzoneTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(DelivzoneTableMap::ID)) $criteria->add(DelivzoneTableMap::ID, $this->id);
+ if ($this->isColumnModified(DelivzoneTableMap::AREA_ID)) $criteria->add(DelivzoneTableMap::AREA_ID, $this->area_id);
+ if ($this->isColumnModified(DelivzoneTableMap::DELIVERY)) $criteria->add(DelivzoneTableMap::DELIVERY, $this->delivery);
+ if ($this->isColumnModified(DelivzoneTableMap::CREATED_AT)) $criteria->add(DelivzoneTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) $criteria->add(DelivzoneTableMap::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(DelivzoneTableMap::DATABASE_NAME);
+ $criteria->add(DelivzoneTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Delivzone (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setAreaId($this->getAreaId());
+ $copyObj->setDelivery($this->getDelivery());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Delivzone 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildArea object.
+ *
+ * @param ChildArea $v
+ * @return \Thelia\Model\Delivzone The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setArea(ChildArea $v = null)
+ {
+ if ($v === null) {
+ $this->setAreaId(NULL);
+ } else {
+ $this->setAreaId($v->getId());
+ }
+
+ $this->aArea = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildArea object, it will not be re-added.
+ if ($v !== null) {
+ $v->addDelivzone($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildArea object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildArea The associated ChildArea object.
+ * @throws PropelException
+ */
+ public function getArea(ConnectionInterface $con = null)
+ {
+ if ($this->aArea === null && ($this->area_id !== null)) {
+ $this->aArea = ChildAreaQuery::create()->findPk($this->area_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aArea->addDelivzones($this);
+ */
+ }
+
+ return $this->aArea;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->area_id = null;
+ $this->delivery = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aArea = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(DelivzoneTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildDelivzone The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = DelivzoneTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/DelivzoneQuery.php b/core/lib/Thelia/Model/Base/DelivzoneQuery.php
new file mode 100644
index 000000000..e4b8a8ab5
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/DelivzoneQuery.php
@@ -0,0 +1,666 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildDelivzone|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = DelivzoneTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(DelivzoneTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildDelivzone A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, AREA_ID, DELIVERY, CREATED_AT, UPDATED_AT FROM delivzone WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildDelivzone();
+ $obj->hydrate($row);
+ DelivzoneTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildDelivzone|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(DelivzoneTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(DelivzoneTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(DelivzoneTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(DelivzoneTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DelivzoneTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the area_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByAreaId(1234); // WHERE area_id = 1234
+ * $query->filterByAreaId(array(12, 34)); // WHERE area_id IN (12, 34)
+ * $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12
+ *
+ *
+ * @see filterByArea()
+ *
+ * @param mixed $areaId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function filterByAreaId($areaId = null, $comparison = null)
+ {
+ if (is_array($areaId)) {
+ $useMinMax = false;
+ if (isset($areaId['min'])) {
+ $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($areaId['max'])) {
+ $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId, $comparison);
+ }
+
+ /**
+ * Filter the query on the delivery column
+ *
+ * Example usage:
+ *
+ * $query->filterByDelivery('fooValue'); // WHERE delivery = 'fooValue'
+ * $query->filterByDelivery('%fooValue%'); // WHERE delivery LIKE '%fooValue%'
+ *
+ *
+ * @param string $delivery The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function filterByDelivery($delivery = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($delivery)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $delivery)) {
+ $delivery = str_replace('*', '%', $delivery);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(DelivzoneTableMap::DELIVERY, $delivery, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Area object
+ *
+ * @param \Thelia\Model\Area|ObjectCollection $area The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function filterByArea($area, $comparison = null)
+ {
+ if ($area instanceof \Thelia\Model\Area) {
+ return $this
+ ->addUsingAlias(DelivzoneTableMap::AREA_ID, $area->getId(), $comparison);
+ } elseif ($area instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(DelivzoneTableMap::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByArea() only accepts arguments of type \Thelia\Model\Area or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Area relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function joinArea($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Area');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Area');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Area relation Area object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AreaQuery A secondary query class using the current class as primary query
+ */
+ public function useAreaQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinArea($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Area', '\Thelia\Model\AreaQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildDelivzone $delivzone Object to remove from the list of results
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function prune($delivzone = null)
+ {
+ if ($delivzone) {
+ $this->addUsingAlias(DelivzoneTableMap::ID, $delivzone->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the delivzone table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ DelivzoneTableMap::clearInstancePool();
+ DelivzoneTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildDelivzone or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildDelivzone object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(DelivzoneTableMap::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->beginTransaction();
+
+
+ DelivzoneTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ DelivzoneTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(DelivzoneTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(DelivzoneTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(DelivzoneTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildDelivzoneQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(DelivzoneTableMap::CREATED_AT);
+ }
+
+} // DelivzoneQuery
diff --git a/core/lib/Thelia/Model/Base/Document.php b/core/lib/Thelia/Model/Base/Document.php
new file mode 100644
index 000000000..b12293f33
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Document.php
@@ -0,0 +1,2395 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Document instance. If
+ * obj is an instance of Document, delegates to
+ * equals(Document). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Document The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Document The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+
+ return $this->category_id;
+ }
+
+ /**
+ * Get the [folder_id] column value.
+ *
+ * @return int
+ */
+ public function getFolderId()
+ {
+
+ return $this->folder_id;
+ }
+
+ /**
+ * Get the [content_id] column value.
+ *
+ * @return int
+ */
+ public function getContentId()
+ {
+
+ return $this->content_id;
+ }
+
+ /**
+ * Get the [file] column value.
+ *
+ * @return string
+ */
+ public function getFile()
+ {
+
+ return $this->file;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Document The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = DocumentTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Document The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = DocumentTableMap::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Document The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = DocumentTableMap::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Set the value of [folder_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Document The current object (for fluent API support)
+ */
+ public function setFolderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->folder_id !== $v) {
+ $this->folder_id = $v;
+ $this->modifiedColumns[] = DocumentTableMap::FOLDER_ID;
+ }
+
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
+
+ return $this;
+ } // setFolderId()
+
+ /**
+ * Set the value of [content_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Document The current object (for fluent API support)
+ */
+ public function setContentId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->content_id !== $v) {
+ $this->content_id = $v;
+ $this->modifiedColumns[] = DocumentTableMap::CONTENT_ID;
+ }
+
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
+
+ return $this;
+ } // setContentId()
+
+ /**
+ * Set the value of [file] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Document The current object (for fluent API support)
+ */
+ public function setFile($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->file !== $v) {
+ $this->file = $v;
+ $this->modifiedColumns[] = DocumentTableMap::FILE;
+ }
+
+
+ return $this;
+ } // setFile()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Document The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = DocumentTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Document The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = DocumentTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Document The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = DocumentTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : DocumentTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : DocumentTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->product_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : DocumentTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->category_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : DocumentTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->folder_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : DocumentTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->content_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : DocumentTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->file = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : DocumentTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : DocumentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : DocumentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 9; // 9 = DocumentTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Document object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) {
+ $this->aFolder = null;
+ }
+ if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) {
+ $this->aContent = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(DocumentTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildDocumentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aContent = null;
+ $this->aFolder = null;
+ $this->collDocumentI18ns = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Document::setDeleted()
+ * @see Document::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildDocumentQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(DocumentTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(DocumentTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(DocumentTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ DocumentTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->aContent !== null) {
+ if ($this->aContent->isModified() || $this->aContent->isNew()) {
+ $affectedRows += $this->aContent->save($con);
+ }
+ $this->setContent($this->aContent);
+ }
+
+ if ($this->aFolder !== null) {
+ if ($this->aFolder->isModified() || $this->aFolder->isNew()) {
+ $affectedRows += $this->aFolder->save($con);
+ }
+ $this->setFolder($this->aFolder);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->documentI18nsScheduledForDeletion !== null) {
+ if (!$this->documentI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\DocumentI18nQuery::create()
+ ->filterByPrimaryKeys($this->documentI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->documentI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collDocumentI18ns !== null) {
+ foreach ($this->collDocumentI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = DocumentTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . DocumentTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(DocumentTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(DocumentTableMap::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'PRODUCT_ID';
+ }
+ if ($this->isColumnModified(DocumentTableMap::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CATEGORY_ID';
+ }
+ if ($this->isColumnModified(DocumentTableMap::FOLDER_ID)) {
+ $modifiedColumns[':p' . $index++] = 'FOLDER_ID';
+ }
+ if ($this->isColumnModified(DocumentTableMap::CONTENT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CONTENT_ID';
+ }
+ if ($this->isColumnModified(DocumentTableMap::FILE)) {
+ $modifiedColumns[':p' . $index++] = 'FILE';
+ }
+ if ($this->isColumnModified(DocumentTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(DocumentTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(DocumentTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO document (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'PRODUCT_ID':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case 'CATEGORY_ID':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ case 'FOLDER_ID':
+ $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT);
+ break;
+ case 'CONTENT_ID':
+ $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT);
+ break;
+ case 'FILE':
+ $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = DocumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getProductId();
+ break;
+ case 2:
+ return $this->getCategoryId();
+ break;
+ case 3:
+ return $this->getFolderId();
+ break;
+ case 4:
+ return $this->getContentId();
+ break;
+ case 5:
+ return $this->getFile();
+ break;
+ case 6:
+ return $this->getPosition();
+ break;
+ case 7:
+ return $this->getCreatedAt();
+ break;
+ case 8:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Document'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Document'][$this->getPrimaryKey()] = true;
+ $keys = DocumentTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getProductId(),
+ $keys[2] => $this->getCategoryId(),
+ $keys[3] => $this->getFolderId(),
+ $keys[4] => $this->getContentId(),
+ $keys[5] => $this->getFile(),
+ $keys[6] => $this->getPosition(),
+ $keys[7] => $this->getCreatedAt(),
+ $keys[8] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collDocumentI18ns) {
+ $result['DocumentI18ns'] = $this->collDocumentI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = DocumentTableMap::translateFieldName($name, $type, TableMap::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->setProductId($value);
+ break;
+ case 2:
+ $this->setCategoryId($value);
+ break;
+ case 3:
+ $this->setFolderId($value);
+ break;
+ case 4:
+ $this->setContentId($value);
+ break;
+ case 5:
+ $this->setFile($value);
+ break;
+ case 6:
+ $this->setPosition($value);
+ break;
+ case 7:
+ $this->setCreatedAt($value);
+ break;
+ case 8:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = DocumentTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCategoryId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setFolderId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setContentId($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setFile($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setPosition($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
+ }
+
+ /**
+ * 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(DocumentTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(DocumentTableMap::ID)) $criteria->add(DocumentTableMap::ID, $this->id);
+ if ($this->isColumnModified(DocumentTableMap::PRODUCT_ID)) $criteria->add(DocumentTableMap::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(DocumentTableMap::CATEGORY_ID)) $criteria->add(DocumentTableMap::CATEGORY_ID, $this->category_id);
+ if ($this->isColumnModified(DocumentTableMap::FOLDER_ID)) $criteria->add(DocumentTableMap::FOLDER_ID, $this->folder_id);
+ if ($this->isColumnModified(DocumentTableMap::CONTENT_ID)) $criteria->add(DocumentTableMap::CONTENT_ID, $this->content_id);
+ if ($this->isColumnModified(DocumentTableMap::FILE)) $criteria->add(DocumentTableMap::FILE, $this->file);
+ if ($this->isColumnModified(DocumentTableMap::POSITION)) $criteria->add(DocumentTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(DocumentTableMap::CREATED_AT)) $criteria->add(DocumentTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(DocumentTableMap::UPDATED_AT)) $criteria->add(DocumentTableMap::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(DocumentTableMap::DATABASE_NAME);
+ $criteria->add(DocumentTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Document (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setCategoryId($this->getCategoryId());
+ $copyObj->setFolderId($this->getFolderId());
+ $copyObj->setContentId($this->getContentId());
+ $copyObj->setFile($this->getFile());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getDocumentI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addDocumentI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Document 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildProduct object.
+ *
+ * @param ChildProduct $v
+ * @return \Thelia\Model\Document The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(ChildProduct $v = null)
+ {
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
+ }
+
+ $this->aProduct = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildProduct object, it will not be re-added.
+ if ($v !== null) {
+ $v->addDocument($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildProduct object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildProduct The associated ChildProduct object.
+ * @throws PropelException
+ */
+ public function getProduct(ConnectionInterface $con = null)
+ {
+ if ($this->aProduct === null && ($this->product_id !== null)) {
+ $this->aProduct = ChildProductQuery::create()->findPk($this->product_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aProduct->addDocuments($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCategory object.
+ *
+ * @param ChildCategory $v
+ * @return \Thelia\Model\Document The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCategory(ChildCategory $v = null)
+ {
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
+ }
+
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCategory object, it will not be re-added.
+ if ($v !== null) {
+ $v->addDocument($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCategory object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCategory The associated ChildCategory object.
+ * @throws PropelException
+ */
+ public function getCategory(ConnectionInterface $con = null)
+ {
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCategory->addDocuments($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Declares an association between this object and a ChildContent object.
+ *
+ * @param ChildContent $v
+ * @return \Thelia\Model\Document The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setContent(ChildContent $v = null)
+ {
+ if ($v === null) {
+ $this->setContentId(NULL);
+ } else {
+ $this->setContentId($v->getId());
+ }
+
+ $this->aContent = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildContent object, it will not be re-added.
+ if ($v !== null) {
+ $v->addDocument($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildContent object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildContent The associated ChildContent object.
+ * @throws PropelException
+ */
+ public function getContent(ConnectionInterface $con = null)
+ {
+ if ($this->aContent === null && ($this->content_id !== null)) {
+ $this->aContent = ChildContentQuery::create()->findPk($this->content_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aContent->addDocuments($this);
+ */
+ }
+
+ return $this->aContent;
+ }
+
+ /**
+ * Declares an association between this object and a ChildFolder object.
+ *
+ * @param ChildFolder $v
+ * @return \Thelia\Model\Document The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFolder(ChildFolder $v = null)
+ {
+ if ($v === null) {
+ $this->setFolderId(NULL);
+ } else {
+ $this->setFolderId($v->getId());
+ }
+
+ $this->aFolder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildFolder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addDocument($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildFolder object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildFolder The associated ChildFolder object.
+ * @throws PropelException
+ */
+ public function getFolder(ConnectionInterface $con = null)
+ {
+ if ($this->aFolder === null && ($this->folder_id !== null)) {
+ $this->aFolder = ChildFolderQuery::create()->findPk($this->folder_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aFolder->addDocuments($this);
+ */
+ }
+
+ return $this->aFolder;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('DocumentI18n' == $relationName) {
+ return $this->initDocumentI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collDocumentI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addDocumentI18ns()
+ */
+ public function clearDocumentI18ns()
+ {
+ $this->collDocumentI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collDocumentI18ns collection loaded partially.
+ */
+ public function resetPartialDocumentI18ns($v = true)
+ {
+ $this->collDocumentI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collDocumentI18ns collection.
+ *
+ * By default this just sets the collDocumentI18ns collection to an empty array (like clearcollDocumentI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initDocumentI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collDocumentI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collDocumentI18ns = new ObjectCollection();
+ $this->collDocumentI18ns->setModel('\Thelia\Model\DocumentI18n');
+ }
+
+ /**
+ * Gets an array of ChildDocumentI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildDocument is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildDocumentI18n[] List of ChildDocumentI18n objects
+ * @throws PropelException
+ */
+ public function getDocumentI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collDocumentI18nsPartial && !$this->isNew();
+ if (null === $this->collDocumentI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocumentI18ns) {
+ // return empty collection
+ $this->initDocumentI18ns();
+ } else {
+ $collDocumentI18ns = ChildDocumentI18nQuery::create(null, $criteria)
+ ->filterByDocument($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collDocumentI18nsPartial && count($collDocumentI18ns)) {
+ $this->initDocumentI18ns(false);
+
+ foreach ($collDocumentI18ns as $obj) {
+ if (false == $this->collDocumentI18ns->contains($obj)) {
+ $this->collDocumentI18ns->append($obj);
+ }
+ }
+
+ $this->collDocumentI18nsPartial = true;
+ }
+
+ $collDocumentI18ns->getInternalIterator()->rewind();
+
+ return $collDocumentI18ns;
+ }
+
+ if ($partial && $this->collDocumentI18ns) {
+ foreach ($this->collDocumentI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collDocumentI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collDocumentI18ns = $collDocumentI18ns;
+ $this->collDocumentI18nsPartial = false;
+ }
+ }
+
+ return $this->collDocumentI18ns;
+ }
+
+ /**
+ * Sets a collection of DocumentI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $documentI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildDocument The current object (for fluent API support)
+ */
+ public function setDocumentI18ns(Collection $documentI18ns, ConnectionInterface $con = null)
+ {
+ $documentI18nsToDelete = $this->getDocumentI18ns(new Criteria(), $con)->diff($documentI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->documentI18nsScheduledForDeletion = clone $documentI18nsToDelete;
+
+ foreach ($documentI18nsToDelete as $documentI18nRemoved) {
+ $documentI18nRemoved->setDocument(null);
+ }
+
+ $this->collDocumentI18ns = null;
+ foreach ($documentI18ns as $documentI18n) {
+ $this->addDocumentI18n($documentI18n);
+ }
+
+ $this->collDocumentI18ns = $documentI18ns;
+ $this->collDocumentI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related DocumentI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related DocumentI18n objects.
+ * @throws PropelException
+ */
+ public function countDocumentI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collDocumentI18nsPartial && !$this->isNew();
+ if (null === $this->collDocumentI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocumentI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getDocumentI18ns());
+ }
+
+ $query = ChildDocumentI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByDocument($this)
+ ->count($con);
+ }
+
+ return count($this->collDocumentI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildDocumentI18n object to this object
+ * through the ChildDocumentI18n foreign key attribute.
+ *
+ * @param ChildDocumentI18n $l ChildDocumentI18n
+ * @return \Thelia\Model\Document The current object (for fluent API support)
+ */
+ public function addDocumentI18n(ChildDocumentI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collDocumentI18ns === null) {
+ $this->initDocumentI18ns();
+ $this->collDocumentI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collDocumentI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddDocumentI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param DocumentI18n $documentI18n The documentI18n object to add.
+ */
+ protected function doAddDocumentI18n($documentI18n)
+ {
+ $this->collDocumentI18ns[]= $documentI18n;
+ $documentI18n->setDocument($this);
+ }
+
+ /**
+ * @param DocumentI18n $documentI18n The documentI18n object to remove.
+ * @return ChildDocument The current object (for fluent API support)
+ */
+ public function removeDocumentI18n($documentI18n)
+ {
+ if ($this->getDocumentI18ns()->contains($documentI18n)) {
+ $this->collDocumentI18ns->remove($this->collDocumentI18ns->search($documentI18n));
+ if (null === $this->documentI18nsScheduledForDeletion) {
+ $this->documentI18nsScheduledForDeletion = clone $this->collDocumentI18ns;
+ $this->documentI18nsScheduledForDeletion->clear();
+ }
+ $this->documentI18nsScheduledForDeletion[]= clone $documentI18n;
+ $documentI18n->setDocument(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->product_id = null;
+ $this->category_id = null;
+ $this->folder_id = null;
+ $this->content_id = null;
+ $this->file = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collDocumentI18ns) {
+ foreach ($this->collDocumentI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collDocumentI18ns instanceof Collection) {
+ $this->collDocumentI18ns->clearIterator();
+ }
+ $this->collDocumentI18ns = null;
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aContent = null;
+ $this->aFolder = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(DocumentTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildDocument The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = DocumentTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildDocument The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildDocumentI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collDocumentI18ns) {
+ foreach ($this->collDocumentI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildDocumentI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildDocumentI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addDocumentI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildDocument The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildDocumentI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collDocumentI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collDocumentI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildDocumentI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\DocumentI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\DocumentI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\DocumentI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\DocumentI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/DocumentI18n.php b/core/lib/Thelia/Model/Base/DocumentI18n.php
new file mode 100644
index 000000000..adc6acd36
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/DocumentI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\DocumentI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another DocumentI18n instance. If
+ * obj is an instance of DocumentI18n, delegates to
+ * equals(DocumentI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return DocumentI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return DocumentI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\DocumentI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = DocumentI18nTableMap::ID;
+ }
+
+ if ($this->aDocument !== null && $this->aDocument->getId() !== $v) {
+ $this->aDocument = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\DocumentI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = DocumentI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\DocumentI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = DocumentI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\DocumentI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = DocumentI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\DocumentI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = DocumentI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\DocumentI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = DocumentI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : DocumentI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : DocumentI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : DocumentI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : DocumentI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : DocumentI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : DocumentI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = DocumentI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\DocumentI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aDocument !== null && $this->id !== $this->aDocument->getId()) {
+ $this->aDocument = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(DocumentI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildDocumentI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aDocument = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see DocumentI18n::setDeleted()
+ * @see DocumentI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildDocumentI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ DocumentI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aDocument !== null) {
+ if ($this->aDocument->isModified() || $this->aDocument->isNew()) {
+ $affectedRows += $this->aDocument->save($con);
+ }
+ $this->setDocument($this->aDocument);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(DocumentI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(DocumentI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(DocumentI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(DocumentI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(DocumentI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(DocumentI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO document_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = DocumentI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['DocumentI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['DocumentI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = DocumentI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aDocument) {
+ $result['Document'] = $this->aDocument->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = DocumentI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = DocumentI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(DocumentI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(DocumentI18nTableMap::ID)) $criteria->add(DocumentI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(DocumentI18nTableMap::LOCALE)) $criteria->add(DocumentI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(DocumentI18nTableMap::TITLE)) $criteria->add(DocumentI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(DocumentI18nTableMap::DESCRIPTION)) $criteria->add(DocumentI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(DocumentI18nTableMap::CHAPO)) $criteria->add(DocumentI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(DocumentI18nTableMap::POSTSCRIPTUM)) $criteria->add(DocumentI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(DocumentI18nTableMap::DATABASE_NAME);
+ $criteria->add(DocumentI18nTableMap::ID, $this->id);
+ $criteria->add(DocumentI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\DocumentI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\DocumentI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildDocument object.
+ *
+ * @param ChildDocument $v
+ * @return \Thelia\Model\DocumentI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setDocument(ChildDocument $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aDocument = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildDocument object, it will not be re-added.
+ if ($v !== null) {
+ $v->addDocumentI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildDocument object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildDocument The associated ChildDocument object.
+ * @throws PropelException
+ */
+ public function getDocument(ConnectionInterface $con = null)
+ {
+ if ($this->aDocument === null && ($this->id !== null)) {
+ $this->aDocument = ChildDocumentQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aDocument->addDocumentI18ns($this);
+ */
+ }
+
+ return $this->aDocument;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aDocument = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(DocumentI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/DocumentI18nQuery.php b/core/lib/Thelia/Model/Base/DocumentI18nQuery.php
new file mode 100644
index 000000000..47b598bf0
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/DocumentI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildDocumentI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = DocumentI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(DocumentI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildDocumentI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM document_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildDocumentI18n();
+ $obj->hydrate($row);
+ DocumentI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildDocumentI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildDocumentI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(DocumentI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(DocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildDocumentI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(DocumentI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(DocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByDocument()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(DocumentI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(DocumentI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Document object
+ *
+ * @param \Thelia\Model\Document|ObjectCollection $document The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentI18nQuery The current query, for fluid interface
+ */
+ public function filterByDocument($document, $comparison = null)
+ {
+ if ($document instanceof \Thelia\Model\Document) {
+ return $this
+ ->addUsingAlias(DocumentI18nTableMap::ID, $document->getId(), $comparison);
+ } elseif ($document instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(DocumentI18nTableMap::ID, $document->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Document relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildDocumentI18nQuery The current query, for fluid interface
+ */
+ public function joinDocument($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Document');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Document');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Document relation Document object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query
+ */
+ public function useDocumentQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinDocument($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildDocumentI18n $documentI18n Object to remove from the list of results
+ *
+ * @return ChildDocumentI18nQuery The current query, for fluid interface
+ */
+ public function prune($documentI18n = null)
+ {
+ if ($documentI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(DocumentI18nTableMap::ID), $documentI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(DocumentI18nTableMap::LOCALE), $documentI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the document_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ DocumentI18nTableMap::clearInstancePool();
+ DocumentI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildDocumentI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildDocumentI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentI18nTableMap::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->beginTransaction();
+
+
+ DocumentI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ DocumentI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // DocumentI18nQuery
diff --git a/core/lib/Thelia/Model/Base/DocumentQuery.php b/core/lib/Thelia/Model/Base/DocumentQuery.php
new file mode 100644
index 000000000..20c897994
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/DocumentQuery.php
@@ -0,0 +1,1224 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildDocument|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = DocumentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(DocumentTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildDocument A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, PRODUCT_ID, CATEGORY_ID, FOLDER_ID, CONTENT_ID, FILE, POSITION, CREATED_AT, UPDATED_AT FROM document WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildDocument();
+ $obj->hydrate($row);
+ DocumentTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildDocument|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(DocumentTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(DocumentTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(DocumentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(DocumentTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(DocumentTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(DocumentTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentTableMap::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId)) {
+ $useMinMax = false;
+ if (isset($categoryId['min'])) {
+ $this->addUsingAlias(DocumentTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($categoryId['max'])) {
+ $this->addUsingAlias(DocumentTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentTableMap::CATEGORY_ID, $categoryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the folder_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFolderId(1234); // WHERE folder_id = 1234
+ * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34)
+ * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12
+ *
+ *
+ * @see filterByFolder()
+ *
+ * @param mixed $folderId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByFolderId($folderId = null, $comparison = null)
+ {
+ if (is_array($folderId)) {
+ $useMinMax = false;
+ if (isset($folderId['min'])) {
+ $this->addUsingAlias(DocumentTableMap::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($folderId['max'])) {
+ $this->addUsingAlias(DocumentTableMap::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentTableMap::FOLDER_ID, $folderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the content_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByContentId(1234); // WHERE content_id = 1234
+ * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34)
+ * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
+ *
+ *
+ * @see filterByContent()
+ *
+ * @param mixed $contentId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByContentId($contentId = null, $comparison = null)
+ {
+ if (is_array($contentId)) {
+ $useMinMax = false;
+ if (isset($contentId['min'])) {
+ $this->addUsingAlias(DocumentTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($contentId['max'])) {
+ $this->addUsingAlias(DocumentTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentTableMap::CONTENT_ID, $contentId, $comparison);
+ }
+
+ /**
+ * Filter the query on the file column
+ *
+ * Example usage:
+ *
+ * $query->filterByFile('fooValue'); // WHERE file = 'fooValue'
+ * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%'
+ *
+ *
+ * @param string $file The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByFile($file = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($file)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $file)) {
+ $file = str_replace('*', '%', $file);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentTableMap::FILE, $file, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(DocumentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(DocumentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(DocumentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(DocumentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(DocumentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(DocumentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(DocumentTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Product object
+ *
+ * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByProduct($product, $comparison = null)
+ {
+ if ($product instanceof \Thelia\Model\Product) {
+ return $this
+ ->addUsingAlias(DocumentTableMap::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(DocumentTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Product relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Product');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Product');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Product relation Product object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
+ */
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Category object
+ *
+ * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByCategory($category, $comparison = null)
+ {
+ if ($category instanceof \Thelia\Model\Category) {
+ return $this
+ ->addUsingAlias(DocumentTableMap::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(DocumentTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Category relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Category');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Category');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Category relation Category object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Content object
+ *
+ * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByContent($content, $comparison = null)
+ {
+ if ($content instanceof \Thelia\Model\Content) {
+ return $this
+ ->addUsingAlias(DocumentTableMap::CONTENT_ID, $content->getId(), $comparison);
+ } elseif ($content instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(DocumentTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Content relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Content');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Content');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Content relation Content object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query
+ */
+ public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinContent($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Folder object
+ *
+ * @param \Thelia\Model\Folder|ObjectCollection $folder The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByFolder($folder, $comparison = null)
+ {
+ if ($folder instanceof \Thelia\Model\Folder) {
+ return $this
+ ->addUsingAlias(DocumentTableMap::FOLDER_ID, $folder->getId(), $comparison);
+ } elseif ($folder instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(DocumentTableMap::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Folder relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Folder');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Folder');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Folder relation Folder object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query
+ */
+ public function useFolderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinFolder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\DocumentI18n object
+ *
+ * @param \Thelia\Model\DocumentI18n|ObjectCollection $documentI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function filterByDocumentI18n($documentI18n, $comparison = null)
+ {
+ if ($documentI18n instanceof \Thelia\Model\DocumentI18n) {
+ return $this
+ ->addUsingAlias(DocumentTableMap::ID, $documentI18n->getId(), $comparison);
+ } elseif ($documentI18n instanceof ObjectCollection) {
+ return $this
+ ->useDocumentI18nQuery()
+ ->filterByPrimaryKeys($documentI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByDocumentI18n() only accepts arguments of type \Thelia\Model\DocumentI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the DocumentI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function joinDocumentI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('DocumentI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'DocumentI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the DocumentI18n relation DocumentI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\DocumentI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useDocumentI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinDocumentI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'DocumentI18n', '\Thelia\Model\DocumentI18nQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildDocument $document Object to remove from the list of results
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function prune($document = null)
+ {
+ if ($document) {
+ $this->addUsingAlias(DocumentTableMap::ID, $document->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the document table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ DocumentTableMap::clearInstancePool();
+ DocumentTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildDocument or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildDocument object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(DocumentTableMap::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->beginTransaction();
+
+
+ DocumentTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ DocumentTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(DocumentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(DocumentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(DocumentTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(DocumentTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(DocumentTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(DocumentTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'DocumentI18n';
+
+ return $this
+ ->joinDocumentI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildDocumentQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('DocumentI18n');
+ $this->with['DocumentI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildDocumentI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'DocumentI18n', '\Thelia\Model\DocumentI18nQuery');
+ }
+
+} // DocumentQuery
diff --git a/core/lib/Thelia/Model/Base/Feature.php b/core/lib/Thelia/Model/Base/Feature.php
new file mode 100644
index 000000000..33125c87b
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Feature.php
@@ -0,0 +1,2993 @@
+visible = 0;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\Feature object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Feature instance. If
+ * obj is an instance of Feature, delegates to
+ * equals(Feature). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Feature The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Feature The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [visible] column value.
+ *
+ * @return int
+ */
+ public function getVisible()
+ {
+
+ return $this->visible;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Feature The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FeatureTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Feature The current object (for fluent API support)
+ */
+ public function setVisible($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->visible !== $v) {
+ $this->visible = $v;
+ $this->modifiedColumns[] = FeatureTableMap::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Feature The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = FeatureTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Feature The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = FeatureTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Feature The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = FeatureTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->visible !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FeatureTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->visible = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = FeatureTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Feature object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FeatureTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildFeatureQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collFeatureAvs = null;
+
+ $this->collFeatureProds = null;
+
+ $this->collFeatureCategories = null;
+
+ $this->collFeatureI18ns = null;
+
+ $this->collCategories = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Feature::setDeleted()
+ * @see Feature::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildFeatureQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(FeatureTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(FeatureTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(FeatureTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FeatureTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->categoriesScheduledForDeletion !== null) {
+ if (!$this->categoriesScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->categoriesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($remotePk, $pk);
+ }
+
+ FeatureCategoryQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->categoriesScheduledForDeletion = null;
+ }
+
+ foreach ($this->getCategories() as $category) {
+ if ($category->isModified()) {
+ $category->save($con);
+ }
+ }
+ } elseif ($this->collCategories) {
+ foreach ($this->collCategories as $category) {
+ if ($category->isModified()) {
+ $category->save($con);
+ }
+ }
+ }
+
+ if ($this->featureAvsScheduledForDeletion !== null) {
+ if (!$this->featureAvsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\FeatureAvQuery::create()
+ ->filterByPrimaryKeys($this->featureAvsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->featureAvsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collFeatureAvs !== null) {
+ foreach ($this->collFeatureAvs as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->featureProdsScheduledForDeletion !== null) {
+ if (!$this->featureProdsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\FeatureProdQuery::create()
+ ->filterByPrimaryKeys($this->featureProdsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->featureProdsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collFeatureProds !== null) {
+ foreach ($this->collFeatureProds as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->featureCategoriesScheduledForDeletion !== null) {
+ if (!$this->featureCategoriesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\FeatureCategoryQuery::create()
+ ->filterByPrimaryKeys($this->featureCategoriesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->featureCategoriesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collFeatureCategories !== null) {
+ foreach ($this->collFeatureCategories as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->featureI18nsScheduledForDeletion !== null) {
+ if (!$this->featureI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\FeatureI18nQuery::create()
+ ->filterByPrimaryKeys($this->featureI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->featureI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collFeatureI18ns !== null) {
+ foreach ($this->collFeatureI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = FeatureTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FeatureTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(FeatureTableMap::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = 'VISIBLE';
+ }
+ if ($this->isColumnModified(FeatureTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(FeatureTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(FeatureTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO feature (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'VISIBLE':
+ $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FeatureTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getVisible();
+ break;
+ case 2:
+ return $this->getPosition();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Feature'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Feature'][$this->getPrimaryKey()] = true;
+ $keys = FeatureTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getVisible(),
+ $keys[2] => $this->getPosition(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collFeatureAvs) {
+ $result['FeatureAvs'] = $this->collFeatureAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFeatureProds) {
+ $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFeatureCategories) {
+ $result['FeatureCategories'] = $this->collFeatureCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFeatureI18ns) {
+ $result['FeatureI18ns'] = $this->collFeatureI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FeatureTableMap::translateFieldName($name, $type, TableMap::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->setVisible($value);
+ break;
+ case 2:
+ $this->setPosition($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = FeatureTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setVisible($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * 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(FeatureTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(FeatureTableMap::ID)) $criteria->add(FeatureTableMap::ID, $this->id);
+ if ($this->isColumnModified(FeatureTableMap::VISIBLE)) $criteria->add(FeatureTableMap::VISIBLE, $this->visible);
+ if ($this->isColumnModified(FeatureTableMap::POSITION)) $criteria->add(FeatureTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(FeatureTableMap::CREATED_AT)) $criteria->add(FeatureTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(FeatureTableMap::UPDATED_AT)) $criteria->add(FeatureTableMap::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(FeatureTableMap::DATABASE_NAME);
+ $criteria->add(FeatureTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Feature (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getFeatureAvs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFeatureAv($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getFeatureProds() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFeatureProd($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getFeatureCategories() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFeatureCategory($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getFeatureI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFeatureI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Feature 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('FeatureAv' == $relationName) {
+ return $this->initFeatureAvs();
+ }
+ if ('FeatureProd' == $relationName) {
+ return $this->initFeatureProds();
+ }
+ if ('FeatureCategory' == $relationName) {
+ return $this->initFeatureCategories();
+ }
+ if ('FeatureI18n' == $relationName) {
+ return $this->initFeatureI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collFeatureAvs collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addFeatureAvs()
+ */
+ public function clearFeatureAvs()
+ {
+ $this->collFeatureAvs = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collFeatureAvs collection loaded partially.
+ */
+ public function resetPartialFeatureAvs($v = true)
+ {
+ $this->collFeatureAvsPartial = $v;
+ }
+
+ /**
+ * Initializes the collFeatureAvs collection.
+ *
+ * By default this just sets the collFeatureAvs collection to an empty array (like clearcollFeatureAvs());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initFeatureAvs($overrideExisting = true)
+ {
+ if (null !== $this->collFeatureAvs && !$overrideExisting) {
+ return;
+ }
+ $this->collFeatureAvs = new ObjectCollection();
+ $this->collFeatureAvs->setModel('\Thelia\Model\FeatureAv');
+ }
+
+ /**
+ * Gets an array of ChildFeatureAv objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildFeature is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildFeatureAv[] List of ChildFeatureAv objects
+ * @throws PropelException
+ */
+ public function getFeatureAvs($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureAvsPartial && !$this->isNew();
+ if (null === $this->collFeatureAvs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureAvs) {
+ // return empty collection
+ $this->initFeatureAvs();
+ } else {
+ $collFeatureAvs = ChildFeatureAvQuery::create(null, $criteria)
+ ->filterByFeature($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collFeatureAvsPartial && count($collFeatureAvs)) {
+ $this->initFeatureAvs(false);
+
+ foreach ($collFeatureAvs as $obj) {
+ if (false == $this->collFeatureAvs->contains($obj)) {
+ $this->collFeatureAvs->append($obj);
+ }
+ }
+
+ $this->collFeatureAvsPartial = true;
+ }
+
+ $collFeatureAvs->getInternalIterator()->rewind();
+
+ return $collFeatureAvs;
+ }
+
+ if ($partial && $this->collFeatureAvs) {
+ foreach ($this->collFeatureAvs as $obj) {
+ if ($obj->isNew()) {
+ $collFeatureAvs[] = $obj;
+ }
+ }
+ }
+
+ $this->collFeatureAvs = $collFeatureAvs;
+ $this->collFeatureAvsPartial = false;
+ }
+ }
+
+ return $this->collFeatureAvs;
+ }
+
+ /**
+ * Sets a collection of FeatureAv objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $featureAvs A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildFeature The current object (for fluent API support)
+ */
+ public function setFeatureAvs(Collection $featureAvs, ConnectionInterface $con = null)
+ {
+ $featureAvsToDelete = $this->getFeatureAvs(new Criteria(), $con)->diff($featureAvs);
+
+
+ $this->featureAvsScheduledForDeletion = $featureAvsToDelete;
+
+ foreach ($featureAvsToDelete as $featureAvRemoved) {
+ $featureAvRemoved->setFeature(null);
+ }
+
+ $this->collFeatureAvs = null;
+ foreach ($featureAvs as $featureAv) {
+ $this->addFeatureAv($featureAv);
+ }
+
+ $this->collFeatureAvs = $featureAvs;
+ $this->collFeatureAvsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related FeatureAv objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related FeatureAv objects.
+ * @throws PropelException
+ */
+ public function countFeatureAvs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureAvsPartial && !$this->isNew();
+ if (null === $this->collFeatureAvs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureAvs) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getFeatureAvs());
+ }
+
+ $query = ChildFeatureAvQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFeature($this)
+ ->count($con);
+ }
+
+ return count($this->collFeatureAvs);
+ }
+
+ /**
+ * Method called to associate a ChildFeatureAv object to this object
+ * through the ChildFeatureAv foreign key attribute.
+ *
+ * @param ChildFeatureAv $l ChildFeatureAv
+ * @return \Thelia\Model\Feature The current object (for fluent API support)
+ */
+ public function addFeatureAv(ChildFeatureAv $l)
+ {
+ if ($this->collFeatureAvs === null) {
+ $this->initFeatureAvs();
+ $this->collFeatureAvsPartial = true;
+ }
+
+ if (!in_array($l, $this->collFeatureAvs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddFeatureAv($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param FeatureAv $featureAv The featureAv object to add.
+ */
+ protected function doAddFeatureAv($featureAv)
+ {
+ $this->collFeatureAvs[]= $featureAv;
+ $featureAv->setFeature($this);
+ }
+
+ /**
+ * @param FeatureAv $featureAv The featureAv object to remove.
+ * @return ChildFeature The current object (for fluent API support)
+ */
+ public function removeFeatureAv($featureAv)
+ {
+ if ($this->getFeatureAvs()->contains($featureAv)) {
+ $this->collFeatureAvs->remove($this->collFeatureAvs->search($featureAv));
+ if (null === $this->featureAvsScheduledForDeletion) {
+ $this->featureAvsScheduledForDeletion = clone $this->collFeatureAvs;
+ $this->featureAvsScheduledForDeletion->clear();
+ }
+ $this->featureAvsScheduledForDeletion[]= clone $featureAv;
+ $featureAv->setFeature(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collFeatureProds collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addFeatureProds()
+ */
+ public function clearFeatureProds()
+ {
+ $this->collFeatureProds = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collFeatureProds collection loaded partially.
+ */
+ public function resetPartialFeatureProds($v = true)
+ {
+ $this->collFeatureProdsPartial = $v;
+ }
+
+ /**
+ * Initializes the collFeatureProds collection.
+ *
+ * By default this just sets the collFeatureProds collection to an empty array (like clearcollFeatureProds());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initFeatureProds($overrideExisting = true)
+ {
+ if (null !== $this->collFeatureProds && !$overrideExisting) {
+ return;
+ }
+ $this->collFeatureProds = new ObjectCollection();
+ $this->collFeatureProds->setModel('\Thelia\Model\FeatureProd');
+ }
+
+ /**
+ * Gets an array of ChildFeatureProd objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildFeature is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects
+ * @throws PropelException
+ */
+ public function getFeatureProds($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureProdsPartial && !$this->isNew();
+ if (null === $this->collFeatureProds || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureProds) {
+ // return empty collection
+ $this->initFeatureProds();
+ } else {
+ $collFeatureProds = ChildFeatureProdQuery::create(null, $criteria)
+ ->filterByFeature($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) {
+ $this->initFeatureProds(false);
+
+ foreach ($collFeatureProds as $obj) {
+ if (false == $this->collFeatureProds->contains($obj)) {
+ $this->collFeatureProds->append($obj);
+ }
+ }
+
+ $this->collFeatureProdsPartial = true;
+ }
+
+ $collFeatureProds->getInternalIterator()->rewind();
+
+ return $collFeatureProds;
+ }
+
+ if ($partial && $this->collFeatureProds) {
+ foreach ($this->collFeatureProds as $obj) {
+ if ($obj->isNew()) {
+ $collFeatureProds[] = $obj;
+ }
+ }
+ }
+
+ $this->collFeatureProds = $collFeatureProds;
+ $this->collFeatureProdsPartial = false;
+ }
+ }
+
+ return $this->collFeatureProds;
+ }
+
+ /**
+ * Sets a collection of FeatureProd objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $featureProds A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildFeature The current object (for fluent API support)
+ */
+ public function setFeatureProds(Collection $featureProds, ConnectionInterface $con = null)
+ {
+ $featureProdsToDelete = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds);
+
+
+ $this->featureProdsScheduledForDeletion = $featureProdsToDelete;
+
+ foreach ($featureProdsToDelete as $featureProdRemoved) {
+ $featureProdRemoved->setFeature(null);
+ }
+
+ $this->collFeatureProds = null;
+ foreach ($featureProds as $featureProd) {
+ $this->addFeatureProd($featureProd);
+ }
+
+ $this->collFeatureProds = $featureProds;
+ $this->collFeatureProdsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related FeatureProd objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related FeatureProd objects.
+ * @throws PropelException
+ */
+ public function countFeatureProds(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureProdsPartial && !$this->isNew();
+ if (null === $this->collFeatureProds || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureProds) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getFeatureProds());
+ }
+
+ $query = ChildFeatureProdQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFeature($this)
+ ->count($con);
+ }
+
+ return count($this->collFeatureProds);
+ }
+
+ /**
+ * Method called to associate a ChildFeatureProd object to this object
+ * through the ChildFeatureProd foreign key attribute.
+ *
+ * @param ChildFeatureProd $l ChildFeatureProd
+ * @return \Thelia\Model\Feature The current object (for fluent API support)
+ */
+ public function addFeatureProd(ChildFeatureProd $l)
+ {
+ if ($this->collFeatureProds === null) {
+ $this->initFeatureProds();
+ $this->collFeatureProdsPartial = true;
+ }
+
+ if (!in_array($l, $this->collFeatureProds->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddFeatureProd($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param FeatureProd $featureProd The featureProd object to add.
+ */
+ protected function doAddFeatureProd($featureProd)
+ {
+ $this->collFeatureProds[]= $featureProd;
+ $featureProd->setFeature($this);
+ }
+
+ /**
+ * @param FeatureProd $featureProd The featureProd object to remove.
+ * @return ChildFeature The current object (for fluent API support)
+ */
+ public function removeFeatureProd($featureProd)
+ {
+ if ($this->getFeatureProds()->contains($featureProd)) {
+ $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd));
+ if (null === $this->featureProdsScheduledForDeletion) {
+ $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds;
+ $this->featureProdsScheduledForDeletion->clear();
+ }
+ $this->featureProdsScheduledForDeletion[]= clone $featureProd;
+ $featureProd->setFeature(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Feature is new, it will return
+ * an empty collection; or if this Feature has previously
+ * been saved, it will retrieve related FeatureProds 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 Feature.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects
+ */
+ public function getFeatureProdsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildFeatureProdQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getFeatureProds($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Feature is new, it will return
+ * an empty collection; or if this Feature has previously
+ * been saved, it will retrieve related FeatureProds 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 Feature.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects
+ */
+ public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildFeatureProdQuery::create(null, $criteria);
+ $query->joinWith('FeatureAv', $joinBehavior);
+
+ return $this->getFeatureProds($query, $con);
+ }
+
+ /**
+ * Clears out the collFeatureCategories collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addFeatureCategories()
+ */
+ public function clearFeatureCategories()
+ {
+ $this->collFeatureCategories = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collFeatureCategories collection loaded partially.
+ */
+ public function resetPartialFeatureCategories($v = true)
+ {
+ $this->collFeatureCategoriesPartial = $v;
+ }
+
+ /**
+ * Initializes the collFeatureCategories collection.
+ *
+ * By default this just sets the collFeatureCategories collection to an empty array (like clearcollFeatureCategories());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initFeatureCategories($overrideExisting = true)
+ {
+ if (null !== $this->collFeatureCategories && !$overrideExisting) {
+ return;
+ }
+ $this->collFeatureCategories = new ObjectCollection();
+ $this->collFeatureCategories->setModel('\Thelia\Model\FeatureCategory');
+ }
+
+ /**
+ * Gets an array of ChildFeatureCategory objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildFeature is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildFeatureCategory[] List of ChildFeatureCategory objects
+ * @throws PropelException
+ */
+ public function getFeatureCategories($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureCategoriesPartial && !$this->isNew();
+ if (null === $this->collFeatureCategories || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureCategories) {
+ // return empty collection
+ $this->initFeatureCategories();
+ } else {
+ $collFeatureCategories = ChildFeatureCategoryQuery::create(null, $criteria)
+ ->filterByFeature($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collFeatureCategoriesPartial && count($collFeatureCategories)) {
+ $this->initFeatureCategories(false);
+
+ foreach ($collFeatureCategories as $obj) {
+ if (false == $this->collFeatureCategories->contains($obj)) {
+ $this->collFeatureCategories->append($obj);
+ }
+ }
+
+ $this->collFeatureCategoriesPartial = true;
+ }
+
+ $collFeatureCategories->getInternalIterator()->rewind();
+
+ return $collFeatureCategories;
+ }
+
+ if ($partial && $this->collFeatureCategories) {
+ foreach ($this->collFeatureCategories as $obj) {
+ if ($obj->isNew()) {
+ $collFeatureCategories[] = $obj;
+ }
+ }
+ }
+
+ $this->collFeatureCategories = $collFeatureCategories;
+ $this->collFeatureCategoriesPartial = false;
+ }
+ }
+
+ return $this->collFeatureCategories;
+ }
+
+ /**
+ * Sets a collection of FeatureCategory objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $featureCategories A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildFeature The current object (for fluent API support)
+ */
+ public function setFeatureCategories(Collection $featureCategories, ConnectionInterface $con = null)
+ {
+ $featureCategoriesToDelete = $this->getFeatureCategories(new Criteria(), $con)->diff($featureCategories);
+
+
+ $this->featureCategoriesScheduledForDeletion = $featureCategoriesToDelete;
+
+ foreach ($featureCategoriesToDelete as $featureCategoryRemoved) {
+ $featureCategoryRemoved->setFeature(null);
+ }
+
+ $this->collFeatureCategories = null;
+ foreach ($featureCategories as $featureCategory) {
+ $this->addFeatureCategory($featureCategory);
+ }
+
+ $this->collFeatureCategories = $featureCategories;
+ $this->collFeatureCategoriesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related FeatureCategory objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related FeatureCategory objects.
+ * @throws PropelException
+ */
+ public function countFeatureCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureCategoriesPartial && !$this->isNew();
+ if (null === $this->collFeatureCategories || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureCategories) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getFeatureCategories());
+ }
+
+ $query = ChildFeatureCategoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFeature($this)
+ ->count($con);
+ }
+
+ return count($this->collFeatureCategories);
+ }
+
+ /**
+ * Method called to associate a ChildFeatureCategory object to this object
+ * through the ChildFeatureCategory foreign key attribute.
+ *
+ * @param ChildFeatureCategory $l ChildFeatureCategory
+ * @return \Thelia\Model\Feature The current object (for fluent API support)
+ */
+ public function addFeatureCategory(ChildFeatureCategory $l)
+ {
+ if ($this->collFeatureCategories === null) {
+ $this->initFeatureCategories();
+ $this->collFeatureCategoriesPartial = true;
+ }
+
+ if (!in_array($l, $this->collFeatureCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddFeatureCategory($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param FeatureCategory $featureCategory The featureCategory object to add.
+ */
+ protected function doAddFeatureCategory($featureCategory)
+ {
+ $this->collFeatureCategories[]= $featureCategory;
+ $featureCategory->setFeature($this);
+ }
+
+ /**
+ * @param FeatureCategory $featureCategory The featureCategory object to remove.
+ * @return ChildFeature The current object (for fluent API support)
+ */
+ public function removeFeatureCategory($featureCategory)
+ {
+ if ($this->getFeatureCategories()->contains($featureCategory)) {
+ $this->collFeatureCategories->remove($this->collFeatureCategories->search($featureCategory));
+ if (null === $this->featureCategoriesScheduledForDeletion) {
+ $this->featureCategoriesScheduledForDeletion = clone $this->collFeatureCategories;
+ $this->featureCategoriesScheduledForDeletion->clear();
+ }
+ $this->featureCategoriesScheduledForDeletion[]= clone $featureCategory;
+ $featureCategory->setFeature(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Feature is new, it will return
+ * an empty collection; or if this Feature has previously
+ * been saved, it will retrieve related FeatureCategories 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 Feature.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildFeatureCategory[] List of ChildFeatureCategory objects
+ */
+ public function getFeatureCategoriesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildFeatureCategoryQuery::create(null, $criteria);
+ $query->joinWith('Category', $joinBehavior);
+
+ return $this->getFeatureCategories($query, $con);
+ }
+
+ /**
+ * Clears out the collFeatureI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addFeatureI18ns()
+ */
+ public function clearFeatureI18ns()
+ {
+ $this->collFeatureI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collFeatureI18ns collection loaded partially.
+ */
+ public function resetPartialFeatureI18ns($v = true)
+ {
+ $this->collFeatureI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collFeatureI18ns collection.
+ *
+ * By default this just sets the collFeatureI18ns collection to an empty array (like clearcollFeatureI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initFeatureI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collFeatureI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collFeatureI18ns = new ObjectCollection();
+ $this->collFeatureI18ns->setModel('\Thelia\Model\FeatureI18n');
+ }
+
+ /**
+ * Gets an array of ChildFeatureI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildFeature is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildFeatureI18n[] List of ChildFeatureI18n objects
+ * @throws PropelException
+ */
+ public function getFeatureI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureI18nsPartial && !$this->isNew();
+ if (null === $this->collFeatureI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureI18ns) {
+ // return empty collection
+ $this->initFeatureI18ns();
+ } else {
+ $collFeatureI18ns = ChildFeatureI18nQuery::create(null, $criteria)
+ ->filterByFeature($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collFeatureI18nsPartial && count($collFeatureI18ns)) {
+ $this->initFeatureI18ns(false);
+
+ foreach ($collFeatureI18ns as $obj) {
+ if (false == $this->collFeatureI18ns->contains($obj)) {
+ $this->collFeatureI18ns->append($obj);
+ }
+ }
+
+ $this->collFeatureI18nsPartial = true;
+ }
+
+ $collFeatureI18ns->getInternalIterator()->rewind();
+
+ return $collFeatureI18ns;
+ }
+
+ if ($partial && $this->collFeatureI18ns) {
+ foreach ($this->collFeatureI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collFeatureI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collFeatureI18ns = $collFeatureI18ns;
+ $this->collFeatureI18nsPartial = false;
+ }
+ }
+
+ return $this->collFeatureI18ns;
+ }
+
+ /**
+ * Sets a collection of FeatureI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $featureI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildFeature The current object (for fluent API support)
+ */
+ public function setFeatureI18ns(Collection $featureI18ns, ConnectionInterface $con = null)
+ {
+ $featureI18nsToDelete = $this->getFeatureI18ns(new Criteria(), $con)->diff($featureI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->featureI18nsScheduledForDeletion = clone $featureI18nsToDelete;
+
+ foreach ($featureI18nsToDelete as $featureI18nRemoved) {
+ $featureI18nRemoved->setFeature(null);
+ }
+
+ $this->collFeatureI18ns = null;
+ foreach ($featureI18ns as $featureI18n) {
+ $this->addFeatureI18n($featureI18n);
+ }
+
+ $this->collFeatureI18ns = $featureI18ns;
+ $this->collFeatureI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related FeatureI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related FeatureI18n objects.
+ * @throws PropelException
+ */
+ public function countFeatureI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureI18nsPartial && !$this->isNew();
+ if (null === $this->collFeatureI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getFeatureI18ns());
+ }
+
+ $query = ChildFeatureI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFeature($this)
+ ->count($con);
+ }
+
+ return count($this->collFeatureI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildFeatureI18n object to this object
+ * through the ChildFeatureI18n foreign key attribute.
+ *
+ * @param ChildFeatureI18n $l ChildFeatureI18n
+ * @return \Thelia\Model\Feature The current object (for fluent API support)
+ */
+ public function addFeatureI18n(ChildFeatureI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collFeatureI18ns === null) {
+ $this->initFeatureI18ns();
+ $this->collFeatureI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collFeatureI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddFeatureI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param FeatureI18n $featureI18n The featureI18n object to add.
+ */
+ protected function doAddFeatureI18n($featureI18n)
+ {
+ $this->collFeatureI18ns[]= $featureI18n;
+ $featureI18n->setFeature($this);
+ }
+
+ /**
+ * @param FeatureI18n $featureI18n The featureI18n object to remove.
+ * @return ChildFeature The current object (for fluent API support)
+ */
+ public function removeFeatureI18n($featureI18n)
+ {
+ if ($this->getFeatureI18ns()->contains($featureI18n)) {
+ $this->collFeatureI18ns->remove($this->collFeatureI18ns->search($featureI18n));
+ if (null === $this->featureI18nsScheduledForDeletion) {
+ $this->featureI18nsScheduledForDeletion = clone $this->collFeatureI18ns;
+ $this->featureI18nsScheduledForDeletion->clear();
+ }
+ $this->featureI18nsScheduledForDeletion[]= clone $featureI18n;
+ $featureI18n->setFeature(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collCategories collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCategories()
+ */
+ public function clearCategories()
+ {
+ $this->collCategories = null; // important to set this to NULL since that means it is uninitialized
+ $this->collCategoriesPartial = null;
+ }
+
+ /**
+ * Initializes the collCategories collection.
+ *
+ * By default this just sets the collCategories collection to an empty collection (like clearCategories());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initCategories()
+ {
+ $this->collCategories = new ObjectCollection();
+ $this->collCategories->setModel('\Thelia\Model\Category');
+ }
+
+ /**
+ * Gets a collection of ChildCategory objects related by a many-to-many relationship
+ * to the current object by way of the feature_category cross-reference table.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildFeature is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return ObjectCollection|ChildCategory[] List of ChildCategory objects
+ */
+ public function getCategories($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collCategories || null !== $criteria) {
+ if ($this->isNew() && null === $this->collCategories) {
+ // return empty collection
+ $this->initCategories();
+ } else {
+ $collCategories = ChildCategoryQuery::create(null, $criteria)
+ ->filterByFeature($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collCategories;
+ }
+ $this->collCategories = $collCategories;
+ }
+ }
+
+ return $this->collCategories;
+ }
+
+ /**
+ * Sets a collection of Category objects related by a many-to-many relationship
+ * to the current object by way of the feature_category cross-reference table.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $categories A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildFeature The current object (for fluent API support)
+ */
+ public function setCategories(Collection $categories, ConnectionInterface $con = null)
+ {
+ $this->clearCategories();
+ $currentCategories = $this->getCategories();
+
+ $this->categoriesScheduledForDeletion = $currentCategories->diff($categories);
+
+ foreach ($categories as $category) {
+ if (!$currentCategories->contains($category)) {
+ $this->doAddCategory($category);
+ }
+ }
+
+ $this->collCategories = $categories;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildCategory objects related by a many-to-many relationship
+ * to the current object by way of the feature_category cross-reference table.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param boolean $distinct Set to true to force count distinct
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return int the number of related ChildCategory objects
+ */
+ public function countCategories($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collCategories || null !== $criteria) {
+ if ($this->isNew() && null === $this->collCategories) {
+ return 0;
+ } else {
+ $query = ChildCategoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFeature($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collCategories);
+ }
+ }
+
+ /**
+ * Associate a ChildCategory object to this object
+ * through the feature_category cross reference table.
+ *
+ * @param ChildCategory $category The ChildFeatureCategory object to relate
+ * @return ChildFeature The current object (for fluent API support)
+ */
+ public function addCategory(ChildCategory $category)
+ {
+ if ($this->collCategories === null) {
+ $this->initCategories();
+ }
+
+ if (!$this->collCategories->contains($category)) { // only add it if the **same** object is not already associated
+ $this->doAddCategory($category);
+ $this->collCategories[] = $category;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Category $category The category object to add.
+ */
+ protected function doAddCategory($category)
+ {
+ $featureCategory = new ChildFeatureCategory();
+ $featureCategory->setCategory($category);
+ $this->addFeatureCategory($featureCategory);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$category->getFeatures()->contains($this)) {
+ $foreignCollection = $category->getFeatures();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildCategory object to this object
+ * through the feature_category cross reference table.
+ *
+ * @param ChildCategory $category The ChildFeatureCategory object to relate
+ * @return ChildFeature The current object (for fluent API support)
+ */
+ public function removeCategory(ChildCategory $category)
+ {
+ if ($this->getCategories()->contains($category)) {
+ $this->collCategories->remove($this->collCategories->search($category));
+
+ if (null === $this->categoriesScheduledForDeletion) {
+ $this->categoriesScheduledForDeletion = clone $this->collCategories;
+ $this->categoriesScheduledForDeletion->clear();
+ }
+
+ $this->categoriesScheduledForDeletion[] = $category;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->visible = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collFeatureAvs) {
+ foreach ($this->collFeatureAvs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collFeatureProds) {
+ foreach ($this->collFeatureProds as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collFeatureCategories) {
+ foreach ($this->collFeatureCategories as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collFeatureI18ns) {
+ foreach ($this->collFeatureI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCategories) {
+ foreach ($this->collCategories as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collFeatureAvs instanceof Collection) {
+ $this->collFeatureAvs->clearIterator();
+ }
+ $this->collFeatureAvs = null;
+ if ($this->collFeatureProds instanceof Collection) {
+ $this->collFeatureProds->clearIterator();
+ }
+ $this->collFeatureProds = null;
+ if ($this->collFeatureCategories instanceof Collection) {
+ $this->collFeatureCategories->clearIterator();
+ }
+ $this->collFeatureCategories = null;
+ if ($this->collFeatureI18ns instanceof Collection) {
+ $this->collFeatureI18ns->clearIterator();
+ }
+ $this->collFeatureI18ns = null;
+ if ($this->collCategories instanceof Collection) {
+ $this->collCategories->clearIterator();
+ }
+ $this->collCategories = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FeatureTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildFeature The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = FeatureTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildFeature The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFeatureI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collFeatureI18ns) {
+ foreach ($this->collFeatureI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildFeatureI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildFeatureI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addFeatureI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFeature The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildFeatureI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collFeatureI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collFeatureI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFeatureI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/FeatureAv.php b/core/lib/Thelia/Model/Base/FeatureAv.php
new file mode 100644
index 000000000..baa930702
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FeatureAv.php
@@ -0,0 +1,2196 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another FeatureAv instance. If
+ * obj is an instance of FeatureAv, delegates to
+ * equals(FeatureAv). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return FeatureAv The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return FeatureAv The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [feature_id] column value.
+ *
+ * @return int
+ */
+ public function getFeatureId()
+ {
+
+ return $this->feature_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FeatureAv The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FeatureAvTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [feature_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FeatureAv The current object (for fluent API support)
+ */
+ public function setFeatureId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->feature_id !== $v) {
+ $this->feature_id = $v;
+ $this->modifiedColumns[] = FeatureAvTableMap::FEATURE_ID;
+ }
+
+ if ($this->aFeature !== null && $this->aFeature->getId() !== $v) {
+ $this->aFeature = null;
+ }
+
+
+ return $this;
+ } // setFeatureId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\FeatureAv The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = FeatureAvTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\FeatureAv The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = FeatureAvTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FeatureAvTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureAvTableMap::translateFieldName('FeatureId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->feature_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureAvTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureAvTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = FeatureAvTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\FeatureAv object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) {
+ $this->aFeature = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FeatureAvTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildFeatureAvQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aFeature = null;
+ $this->collFeatureProds = null;
+
+ $this->collFeatureAvI18ns = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see FeatureAv::setDeleted()
+ * @see FeatureAv::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildFeatureAvQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(FeatureAvTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(FeatureAvTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(FeatureAvTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FeatureAvTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aFeature !== null) {
+ if ($this->aFeature->isModified() || $this->aFeature->isNew()) {
+ $affectedRows += $this->aFeature->save($con);
+ }
+ $this->setFeature($this->aFeature);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->featureProdsScheduledForDeletion !== null) {
+ if (!$this->featureProdsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\FeatureProdQuery::create()
+ ->filterByPrimaryKeys($this->featureProdsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->featureProdsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collFeatureProds !== null) {
+ foreach ($this->collFeatureProds as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->featureAvI18nsScheduledForDeletion !== null) {
+ if (!$this->featureAvI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\FeatureAvI18nQuery::create()
+ ->filterByPrimaryKeys($this->featureAvI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->featureAvI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collFeatureAvI18ns !== null) {
+ foreach ($this->collFeatureAvI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = FeatureAvTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureAvTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FeatureAvTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(FeatureAvTableMap::FEATURE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'FEATURE_ID';
+ }
+ if ($this->isColumnModified(FeatureAvTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(FeatureAvTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO feature_av (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'FEATURE_ID':
+ $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FeatureAvTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getFeatureId();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['FeatureAv'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['FeatureAv'][$this->getPrimaryKey()] = true;
+ $keys = FeatureAvTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getFeatureId(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aFeature) {
+ $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collFeatureProds) {
+ $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFeatureAvI18ns) {
+ $result['FeatureAvI18ns'] = $this->collFeatureAvI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FeatureAvTableMap::translateFieldName($name, $type, TableMap::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->setFeatureId($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = FeatureAvTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setFeatureId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * 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(FeatureAvTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(FeatureAvTableMap::ID)) $criteria->add(FeatureAvTableMap::ID, $this->id);
+ if ($this->isColumnModified(FeatureAvTableMap::FEATURE_ID)) $criteria->add(FeatureAvTableMap::FEATURE_ID, $this->feature_id);
+ if ($this->isColumnModified(FeatureAvTableMap::CREATED_AT)) $criteria->add(FeatureAvTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(FeatureAvTableMap::UPDATED_AT)) $criteria->add(FeatureAvTableMap::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(FeatureAvTableMap::DATABASE_NAME);
+ $criteria->add(FeatureAvTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\FeatureAv (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setFeatureId($this->getFeatureId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getFeatureProds() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFeatureProd($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getFeatureAvI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFeatureAvI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\FeatureAv 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildFeature object.
+ *
+ * @param ChildFeature $v
+ * @return \Thelia\Model\FeatureAv The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFeature(ChildFeature $v = null)
+ {
+ if ($v === null) {
+ $this->setFeatureId(NULL);
+ } else {
+ $this->setFeatureId($v->getId());
+ }
+
+ $this->aFeature = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildFeature object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFeatureAv($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildFeature object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildFeature The associated ChildFeature object.
+ * @throws PropelException
+ */
+ public function getFeature(ConnectionInterface $con = null)
+ {
+ if ($this->aFeature === null && ($this->feature_id !== null)) {
+ $this->aFeature = ChildFeatureQuery::create()->findPk($this->feature_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aFeature->addFeatureAvs($this);
+ */
+ }
+
+ return $this->aFeature;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('FeatureProd' == $relationName) {
+ return $this->initFeatureProds();
+ }
+ if ('FeatureAvI18n' == $relationName) {
+ return $this->initFeatureAvI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collFeatureProds collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addFeatureProds()
+ */
+ public function clearFeatureProds()
+ {
+ $this->collFeatureProds = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collFeatureProds collection loaded partially.
+ */
+ public function resetPartialFeatureProds($v = true)
+ {
+ $this->collFeatureProdsPartial = $v;
+ }
+
+ /**
+ * Initializes the collFeatureProds collection.
+ *
+ * By default this just sets the collFeatureProds collection to an empty array (like clearcollFeatureProds());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initFeatureProds($overrideExisting = true)
+ {
+ if (null !== $this->collFeatureProds && !$overrideExisting) {
+ return;
+ }
+ $this->collFeatureProds = new ObjectCollection();
+ $this->collFeatureProds->setModel('\Thelia\Model\FeatureProd');
+ }
+
+ /**
+ * Gets an array of ChildFeatureProd objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildFeatureAv is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects
+ * @throws PropelException
+ */
+ public function getFeatureProds($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureProdsPartial && !$this->isNew();
+ if (null === $this->collFeatureProds || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureProds) {
+ // return empty collection
+ $this->initFeatureProds();
+ } else {
+ $collFeatureProds = ChildFeatureProdQuery::create(null, $criteria)
+ ->filterByFeatureAv($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) {
+ $this->initFeatureProds(false);
+
+ foreach ($collFeatureProds as $obj) {
+ if (false == $this->collFeatureProds->contains($obj)) {
+ $this->collFeatureProds->append($obj);
+ }
+ }
+
+ $this->collFeatureProdsPartial = true;
+ }
+
+ $collFeatureProds->getInternalIterator()->rewind();
+
+ return $collFeatureProds;
+ }
+
+ if ($partial && $this->collFeatureProds) {
+ foreach ($this->collFeatureProds as $obj) {
+ if ($obj->isNew()) {
+ $collFeatureProds[] = $obj;
+ }
+ }
+ }
+
+ $this->collFeatureProds = $collFeatureProds;
+ $this->collFeatureProdsPartial = false;
+ }
+ }
+
+ return $this->collFeatureProds;
+ }
+
+ /**
+ * Sets a collection of FeatureProd objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $featureProds A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildFeatureAv The current object (for fluent API support)
+ */
+ public function setFeatureProds(Collection $featureProds, ConnectionInterface $con = null)
+ {
+ $featureProdsToDelete = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds);
+
+
+ $this->featureProdsScheduledForDeletion = $featureProdsToDelete;
+
+ foreach ($featureProdsToDelete as $featureProdRemoved) {
+ $featureProdRemoved->setFeatureAv(null);
+ }
+
+ $this->collFeatureProds = null;
+ foreach ($featureProds as $featureProd) {
+ $this->addFeatureProd($featureProd);
+ }
+
+ $this->collFeatureProds = $featureProds;
+ $this->collFeatureProdsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related FeatureProd objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related FeatureProd objects.
+ * @throws PropelException
+ */
+ public function countFeatureProds(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureProdsPartial && !$this->isNew();
+ if (null === $this->collFeatureProds || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureProds) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getFeatureProds());
+ }
+
+ $query = ChildFeatureProdQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFeatureAv($this)
+ ->count($con);
+ }
+
+ return count($this->collFeatureProds);
+ }
+
+ /**
+ * Method called to associate a ChildFeatureProd object to this object
+ * through the ChildFeatureProd foreign key attribute.
+ *
+ * @param ChildFeatureProd $l ChildFeatureProd
+ * @return \Thelia\Model\FeatureAv The current object (for fluent API support)
+ */
+ public function addFeatureProd(ChildFeatureProd $l)
+ {
+ if ($this->collFeatureProds === null) {
+ $this->initFeatureProds();
+ $this->collFeatureProdsPartial = true;
+ }
+
+ if (!in_array($l, $this->collFeatureProds->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddFeatureProd($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param FeatureProd $featureProd The featureProd object to add.
+ */
+ protected function doAddFeatureProd($featureProd)
+ {
+ $this->collFeatureProds[]= $featureProd;
+ $featureProd->setFeatureAv($this);
+ }
+
+ /**
+ * @param FeatureProd $featureProd The featureProd object to remove.
+ * @return ChildFeatureAv The current object (for fluent API support)
+ */
+ public function removeFeatureProd($featureProd)
+ {
+ if ($this->getFeatureProds()->contains($featureProd)) {
+ $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd));
+ if (null === $this->featureProdsScheduledForDeletion) {
+ $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds;
+ $this->featureProdsScheduledForDeletion->clear();
+ }
+ $this->featureProdsScheduledForDeletion[]= $featureProd;
+ $featureProd->setFeatureAv(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this FeatureAv is new, it will return
+ * an empty collection; or if this FeatureAv has previously
+ * been saved, it will retrieve related FeatureProds 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 FeatureAv.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects
+ */
+ public function getFeatureProdsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildFeatureProdQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getFeatureProds($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this FeatureAv is new, it will return
+ * an empty collection; or if this FeatureAv has previously
+ * been saved, it will retrieve related FeatureProds 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 FeatureAv.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects
+ */
+ public function getFeatureProdsJoinFeature($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildFeatureProdQuery::create(null, $criteria);
+ $query->joinWith('Feature', $joinBehavior);
+
+ return $this->getFeatureProds($query, $con);
+ }
+
+ /**
+ * Clears out the collFeatureAvI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addFeatureAvI18ns()
+ */
+ public function clearFeatureAvI18ns()
+ {
+ $this->collFeatureAvI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collFeatureAvI18ns collection loaded partially.
+ */
+ public function resetPartialFeatureAvI18ns($v = true)
+ {
+ $this->collFeatureAvI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collFeatureAvI18ns collection.
+ *
+ * By default this just sets the collFeatureAvI18ns collection to an empty array (like clearcollFeatureAvI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initFeatureAvI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collFeatureAvI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collFeatureAvI18ns = new ObjectCollection();
+ $this->collFeatureAvI18ns->setModel('\Thelia\Model\FeatureAvI18n');
+ }
+
+ /**
+ * Gets an array of ChildFeatureAvI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildFeatureAv is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildFeatureAvI18n[] List of ChildFeatureAvI18n objects
+ * @throws PropelException
+ */
+ public function getFeatureAvI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureAvI18nsPartial && !$this->isNew();
+ if (null === $this->collFeatureAvI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureAvI18ns) {
+ // return empty collection
+ $this->initFeatureAvI18ns();
+ } else {
+ $collFeatureAvI18ns = ChildFeatureAvI18nQuery::create(null, $criteria)
+ ->filterByFeatureAv($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collFeatureAvI18nsPartial && count($collFeatureAvI18ns)) {
+ $this->initFeatureAvI18ns(false);
+
+ foreach ($collFeatureAvI18ns as $obj) {
+ if (false == $this->collFeatureAvI18ns->contains($obj)) {
+ $this->collFeatureAvI18ns->append($obj);
+ }
+ }
+
+ $this->collFeatureAvI18nsPartial = true;
+ }
+
+ $collFeatureAvI18ns->getInternalIterator()->rewind();
+
+ return $collFeatureAvI18ns;
+ }
+
+ if ($partial && $this->collFeatureAvI18ns) {
+ foreach ($this->collFeatureAvI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collFeatureAvI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collFeatureAvI18ns = $collFeatureAvI18ns;
+ $this->collFeatureAvI18nsPartial = false;
+ }
+ }
+
+ return $this->collFeatureAvI18ns;
+ }
+
+ /**
+ * Sets a collection of FeatureAvI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $featureAvI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildFeatureAv The current object (for fluent API support)
+ */
+ public function setFeatureAvI18ns(Collection $featureAvI18ns, ConnectionInterface $con = null)
+ {
+ $featureAvI18nsToDelete = $this->getFeatureAvI18ns(new Criteria(), $con)->diff($featureAvI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->featureAvI18nsScheduledForDeletion = clone $featureAvI18nsToDelete;
+
+ foreach ($featureAvI18nsToDelete as $featureAvI18nRemoved) {
+ $featureAvI18nRemoved->setFeatureAv(null);
+ }
+
+ $this->collFeatureAvI18ns = null;
+ foreach ($featureAvI18ns as $featureAvI18n) {
+ $this->addFeatureAvI18n($featureAvI18n);
+ }
+
+ $this->collFeatureAvI18ns = $featureAvI18ns;
+ $this->collFeatureAvI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related FeatureAvI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related FeatureAvI18n objects.
+ * @throws PropelException
+ */
+ public function countFeatureAvI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureAvI18nsPartial && !$this->isNew();
+ if (null === $this->collFeatureAvI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureAvI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getFeatureAvI18ns());
+ }
+
+ $query = ChildFeatureAvI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFeatureAv($this)
+ ->count($con);
+ }
+
+ return count($this->collFeatureAvI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildFeatureAvI18n object to this object
+ * through the ChildFeatureAvI18n foreign key attribute.
+ *
+ * @param ChildFeatureAvI18n $l ChildFeatureAvI18n
+ * @return \Thelia\Model\FeatureAv The current object (for fluent API support)
+ */
+ public function addFeatureAvI18n(ChildFeatureAvI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collFeatureAvI18ns === null) {
+ $this->initFeatureAvI18ns();
+ $this->collFeatureAvI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collFeatureAvI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddFeatureAvI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param FeatureAvI18n $featureAvI18n The featureAvI18n object to add.
+ */
+ protected function doAddFeatureAvI18n($featureAvI18n)
+ {
+ $this->collFeatureAvI18ns[]= $featureAvI18n;
+ $featureAvI18n->setFeatureAv($this);
+ }
+
+ /**
+ * @param FeatureAvI18n $featureAvI18n The featureAvI18n object to remove.
+ * @return ChildFeatureAv The current object (for fluent API support)
+ */
+ public function removeFeatureAvI18n($featureAvI18n)
+ {
+ if ($this->getFeatureAvI18ns()->contains($featureAvI18n)) {
+ $this->collFeatureAvI18ns->remove($this->collFeatureAvI18ns->search($featureAvI18n));
+ if (null === $this->featureAvI18nsScheduledForDeletion) {
+ $this->featureAvI18nsScheduledForDeletion = clone $this->collFeatureAvI18ns;
+ $this->featureAvI18nsScheduledForDeletion->clear();
+ }
+ $this->featureAvI18nsScheduledForDeletion[]= clone $featureAvI18n;
+ $featureAvI18n->setFeatureAv(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->feature_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collFeatureProds) {
+ foreach ($this->collFeatureProds as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collFeatureAvI18ns) {
+ foreach ($this->collFeatureAvI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collFeatureProds instanceof Collection) {
+ $this->collFeatureProds->clearIterator();
+ }
+ $this->collFeatureProds = null;
+ if ($this->collFeatureAvI18ns instanceof Collection) {
+ $this->collFeatureAvI18ns->clearIterator();
+ }
+ $this->collFeatureAvI18ns = null;
+ $this->aFeature = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FeatureAvTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildFeatureAv The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = FeatureAvTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildFeatureAv The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFeatureAvI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collFeatureAvI18ns) {
+ foreach ($this->collFeatureAvI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildFeatureAvI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildFeatureAvI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addFeatureAvI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFeatureAv The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildFeatureAvI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collFeatureAvI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collFeatureAvI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFeatureAvI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/FeatureAvI18n.php b/core/lib/Thelia/Model/Base/FeatureAvI18n.php
new file mode 100644
index 000000000..aa524c430
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FeatureAvI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\FeatureAvI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another FeatureAvI18n instance. If
+ * obj is an instance of FeatureAvI18n, delegates to
+ * equals(FeatureAvI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return FeatureAvI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return FeatureAvI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FeatureAvI18nTableMap::ID;
+ }
+
+ if ($this->aFeatureAv !== null && $this->aFeatureAv->getId() !== $v) {
+ $this->aFeatureAv = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = FeatureAvI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = FeatureAvI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = FeatureAvI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = FeatureAvI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = FeatureAvI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FeatureAvI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureAvI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureAvI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureAvI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureAvI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FeatureAvI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = FeatureAvI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\FeatureAvI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aFeatureAv !== null && $this->id !== $this->aFeatureAv->getId()) {
+ $this->aFeatureAv = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FeatureAvI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildFeatureAvI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aFeatureAv = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see FeatureAvI18n::setDeleted()
+ * @see FeatureAvI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildFeatureAvI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FeatureAvI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aFeatureAv !== null) {
+ if ($this->aFeatureAv->isModified() || $this->aFeatureAv->isNew()) {
+ $affectedRows += $this->aFeatureAv->save($con);
+ }
+ $this->setFeatureAv($this->aFeatureAv);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FeatureAvI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(FeatureAvI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(FeatureAvI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(FeatureAvI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(FeatureAvI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(FeatureAvI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO feature_av_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FeatureAvI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['FeatureAvI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['FeatureAvI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = FeatureAvI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aFeatureAv) {
+ $result['FeatureAv'] = $this->aFeatureAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FeatureAvI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = FeatureAvI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(FeatureAvI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(FeatureAvI18nTableMap::ID)) $criteria->add(FeatureAvI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(FeatureAvI18nTableMap::LOCALE)) $criteria->add(FeatureAvI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(FeatureAvI18nTableMap::TITLE)) $criteria->add(FeatureAvI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(FeatureAvI18nTableMap::DESCRIPTION)) $criteria->add(FeatureAvI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(FeatureAvI18nTableMap::CHAPO)) $criteria->add(FeatureAvI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(FeatureAvI18nTableMap::POSTSCRIPTUM)) $criteria->add(FeatureAvI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(FeatureAvI18nTableMap::DATABASE_NAME);
+ $criteria->add(FeatureAvI18nTableMap::ID, $this->id);
+ $criteria->add(FeatureAvI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\FeatureAvI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\FeatureAvI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildFeatureAv object.
+ *
+ * @param ChildFeatureAv $v
+ * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFeatureAv(ChildFeatureAv $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aFeatureAv = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildFeatureAv object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFeatureAvI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildFeatureAv object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildFeatureAv The associated ChildFeatureAv object.
+ * @throws PropelException
+ */
+ public function getFeatureAv(ConnectionInterface $con = null)
+ {
+ if ($this->aFeatureAv === null && ($this->id !== null)) {
+ $this->aFeatureAv = ChildFeatureAvQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aFeatureAv->addFeatureAvI18ns($this);
+ */
+ }
+
+ return $this->aFeatureAv;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aFeatureAv = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FeatureAvI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/FeatureAvI18nQuery.php b/core/lib/Thelia/Model/Base/FeatureAvI18nQuery.php
new file mode 100644
index 000000000..bab9fd843
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FeatureAvI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFeatureAvI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FeatureAvI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FeatureAvI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFeatureAvI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM feature_av_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildFeatureAvI18n();
+ $obj->hydrate($row);
+ FeatureAvI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFeatureAvI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildFeatureAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(FeatureAvI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(FeatureAvI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildFeatureAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(FeatureAvI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(FeatureAvI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByFeatureAv()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureAvI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(FeatureAvI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(FeatureAvI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\FeatureAv object
+ *
+ * @param \Thelia\Model\FeatureAv|ObjectCollection $featureAv The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureAvI18nQuery The current query, for fluid interface
+ */
+ public function filterByFeatureAv($featureAv, $comparison = null)
+ {
+ if ($featureAv instanceof \Thelia\Model\FeatureAv) {
+ return $this
+ ->addUsingAlias(FeatureAvI18nTableMap::ID, $featureAv->getId(), $comparison);
+ } elseif ($featureAv instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureAvI18nTableMap::ID, $featureAv->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFeatureAv() only accepts arguments of type \Thelia\Model\FeatureAv or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureAv relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFeatureAvI18nQuery The current query, for fluid interface
+ */
+ public function joinFeatureAv($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureAv');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureAv');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureAv relation FeatureAv object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureAvQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureAvQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinFeatureAv($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildFeatureAvI18n $featureAvI18n Object to remove from the list of results
+ *
+ * @return ChildFeatureAvI18nQuery The current query, for fluid interface
+ */
+ public function prune($featureAvI18n = null)
+ {
+ if ($featureAvI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(FeatureAvI18nTableMap::ID), $featureAvI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(FeatureAvI18nTableMap::LOCALE), $featureAvI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the feature_av_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ FeatureAvI18nTableMap::clearInstancePool();
+ FeatureAvI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildFeatureAvI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildFeatureAvI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureAvI18nTableMap::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->beginTransaction();
+
+
+ FeatureAvI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ FeatureAvI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // FeatureAvI18nQuery
diff --git a/core/lib/Thelia/Model/Base/FeatureAvQuery.php b/core/lib/Thelia/Model/Base/FeatureAvQuery.php
new file mode 100644
index 000000000..abdb2f497
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FeatureAvQuery.php
@@ -0,0 +1,845 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFeatureAv|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FeatureAvTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FeatureAvTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFeatureAv A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, FEATURE_ID, CREATED_AT, UPDATED_AT FROM feature_av WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildFeatureAv();
+ $obj->hydrate($row);
+ FeatureAvTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFeatureAv|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(FeatureAvTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(FeatureAvTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(FeatureAvTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(FeatureAvTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the feature_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFeatureId(1234); // WHERE feature_id = 1234
+ * $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34)
+ * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12
+ *
+ *
+ * @see filterByFeature()
+ *
+ * @param mixed $featureId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function filterByFeatureId($featureId = null, $comparison = null)
+ {
+ if (is_array($featureId)) {
+ $useMinMax = false;
+ if (isset($featureId['min'])) {
+ $this->addUsingAlias(FeatureAvTableMap::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($featureId['max'])) {
+ $this->addUsingAlias(FeatureAvTableMap::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvTableMap::FEATURE_ID, $featureId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(FeatureAvTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(FeatureAvTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(FeatureAvTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(FeatureAvTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureAvTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Feature object
+ *
+ * @param \Thelia\Model\Feature|ObjectCollection $feature The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function filterByFeature($feature, $comparison = null)
+ {
+ if ($feature instanceof \Thelia\Model\Feature) {
+ return $this
+ ->addUsingAlias(FeatureAvTableMap::FEATURE_ID, $feature->getId(), $comparison);
+ } elseif ($feature instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureAvTableMap::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFeature() only accepts arguments of type \Thelia\Model\Feature or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Feature relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function joinFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Feature');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Feature');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Feature relation Feature object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeature($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\FeatureProd object
+ *
+ * @param \Thelia\Model\FeatureProd|ObjectCollection $featureProd the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function filterByFeatureProd($featureProd, $comparison = null)
+ {
+ if ($featureProd instanceof \Thelia\Model\FeatureProd) {
+ return $this
+ ->addUsingAlias(FeatureAvTableMap::ID, $featureProd->getFeatureAvId(), $comparison);
+ } elseif ($featureProd instanceof ObjectCollection) {
+ return $this
+ ->useFeatureProdQuery()
+ ->filterByPrimaryKeys($featureProd->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureProd() only accepts arguments of type \Thelia\Model\FeatureProd or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureProd relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function joinFeatureProd($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureProd');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureProd');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureProd relation FeatureProd object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureProdQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureProdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinFeatureProd($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureProd', '\Thelia\Model\FeatureProdQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\FeatureAvI18n object
+ *
+ * @param \Thelia\Model\FeatureAvI18n|ObjectCollection $featureAvI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function filterByFeatureAvI18n($featureAvI18n, $comparison = null)
+ {
+ if ($featureAvI18n instanceof \Thelia\Model\FeatureAvI18n) {
+ return $this
+ ->addUsingAlias(FeatureAvTableMap::ID, $featureAvI18n->getId(), $comparison);
+ } elseif ($featureAvI18n instanceof ObjectCollection) {
+ return $this
+ ->useFeatureAvI18nQuery()
+ ->filterByPrimaryKeys($featureAvI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureAvI18n() only accepts arguments of type \Thelia\Model\FeatureAvI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureAvI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function joinFeatureAvI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureAvI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureAvI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureAvI18n relation FeatureAvI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureAvI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureAvI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinFeatureAvI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureAvI18n', '\Thelia\Model\FeatureAvI18nQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildFeatureAv $featureAv Object to remove from the list of results
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function prune($featureAv = null)
+ {
+ if ($featureAv) {
+ $this->addUsingAlias(FeatureAvTableMap::ID, $featureAv->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the feature_av table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ FeatureAvTableMap::clearInstancePool();
+ FeatureAvTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildFeatureAv or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildFeatureAv object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureAvTableMap::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->beginTransaction();
+
+
+ FeatureAvTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ FeatureAvTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(FeatureAvTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(FeatureAvTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(FeatureAvTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(FeatureAvTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(FeatureAvTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(FeatureAvTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'FeatureAvI18n';
+
+ return $this
+ ->joinFeatureAvI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildFeatureAvQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('FeatureAvI18n');
+ $this->with['FeatureAvI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildFeatureAvI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureAvI18n', '\Thelia\Model\FeatureAvI18nQuery');
+ }
+
+} // FeatureAvQuery
diff --git a/core/lib/Thelia/Model/Base/FeatureCategory.php b/core/lib/Thelia/Model/Base/FeatureCategory.php
new file mode 100644
index 000000000..f3ce14349
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FeatureCategory.php
@@ -0,0 +1,1495 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another FeatureCategory instance. If
+ * obj is an instance of FeatureCategory, delegates to
+ * equals(FeatureCategory). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return FeatureCategory The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return FeatureCategory The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [feature_id] column value.
+ *
+ * @return int
+ */
+ public function getFeatureId()
+ {
+
+ return $this->feature_id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+
+ return $this->category_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FeatureCategory The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FeatureCategoryTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [feature_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FeatureCategory The current object (for fluent API support)
+ */
+ public function setFeatureId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->feature_id !== $v) {
+ $this->feature_id = $v;
+ $this->modifiedColumns[] = FeatureCategoryTableMap::FEATURE_ID;
+ }
+
+ if ($this->aFeature !== null && $this->aFeature->getId() !== $v) {
+ $this->aFeature = null;
+ }
+
+
+ return $this;
+ } // setFeatureId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FeatureCategory The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = FeatureCategoryTableMap::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\FeatureCategory The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = FeatureCategoryTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\FeatureCategory The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = FeatureCategoryTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FeatureCategoryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureCategoryTableMap::translateFieldName('FeatureId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->feature_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureCategoryTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->category_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureCategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureCategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = FeatureCategoryTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\FeatureCategory object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) {
+ $this->aFeature = null;
+ }
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FeatureCategoryTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildFeatureCategoryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCategory = null;
+ $this->aFeature = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see FeatureCategory::setDeleted()
+ * @see FeatureCategory::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildFeatureCategoryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(FeatureCategoryTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FeatureCategoryTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->aFeature !== null) {
+ if ($this->aFeature->isModified() || $this->aFeature->isNew()) {
+ $affectedRows += $this->aFeature->save($con);
+ }
+ $this->setFeature($this->aFeature);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = FeatureCategoryTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureCategoryTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FeatureCategoryTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(FeatureCategoryTableMap::FEATURE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'FEATURE_ID';
+ }
+ if ($this->isColumnModified(FeatureCategoryTableMap::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CATEGORY_ID';
+ }
+ if ($this->isColumnModified(FeatureCategoryTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO feature_category (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'FEATURE_ID':
+ $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT);
+ break;
+ case 'CATEGORY_ID':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FeatureCategoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getFeatureId();
+ break;
+ case 2:
+ return $this->getCategoryId();
+ break;
+ case 3:
+ return $this->getCreatedAt();
+ break;
+ case 4:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['FeatureCategory'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['FeatureCategory'][$this->getPrimaryKey()] = true;
+ $keys = FeatureCategoryTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getFeatureId(),
+ $keys[2] => $this->getCategoryId(),
+ $keys[3] => $this->getCreatedAt(),
+ $keys[4] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aFeature) {
+ $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FeatureCategoryTableMap::translateFieldName($name, $type, TableMap::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->setFeatureId($value);
+ break;
+ case 2:
+ $this->setCategoryId($value);
+ break;
+ case 3:
+ $this->setCreatedAt($value);
+ break;
+ case 4:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = FeatureCategoryTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setFeatureId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCategoryId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
+ }
+
+ /**
+ * 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(FeatureCategoryTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(FeatureCategoryTableMap::ID)) $criteria->add(FeatureCategoryTableMap::ID, $this->id);
+ if ($this->isColumnModified(FeatureCategoryTableMap::FEATURE_ID)) $criteria->add(FeatureCategoryTableMap::FEATURE_ID, $this->feature_id);
+ if ($this->isColumnModified(FeatureCategoryTableMap::CATEGORY_ID)) $criteria->add(FeatureCategoryTableMap::CATEGORY_ID, $this->category_id);
+ if ($this->isColumnModified(FeatureCategoryTableMap::CREATED_AT)) $criteria->add(FeatureCategoryTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) $criteria->add(FeatureCategoryTableMap::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(FeatureCategoryTableMap::DATABASE_NAME);
+ $criteria->add(FeatureCategoryTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\FeatureCategory (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setFeatureId($this->getFeatureId());
+ $copyObj->setCategoryId($this->getCategoryId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\FeatureCategory 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCategory object.
+ *
+ * @param ChildCategory $v
+ * @return \Thelia\Model\FeatureCategory The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCategory(ChildCategory $v = null)
+ {
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
+ }
+
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCategory object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFeatureCategory($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCategory object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCategory The associated ChildCategory object.
+ * @throws PropelException
+ */
+ public function getCategory(ConnectionInterface $con = null)
+ {
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCategory->addFeatureCategories($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Declares an association between this object and a ChildFeature object.
+ *
+ * @param ChildFeature $v
+ * @return \Thelia\Model\FeatureCategory The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFeature(ChildFeature $v = null)
+ {
+ if ($v === null) {
+ $this->setFeatureId(NULL);
+ } else {
+ $this->setFeatureId($v->getId());
+ }
+
+ $this->aFeature = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildFeature object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFeatureCategory($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildFeature object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildFeature The associated ChildFeature object.
+ * @throws PropelException
+ */
+ public function getFeature(ConnectionInterface $con = null)
+ {
+ if ($this->aFeature === null && ($this->feature_id !== null)) {
+ $this->aFeature = ChildFeatureQuery::create()->findPk($this->feature_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aFeature->addFeatureCategories($this);
+ */
+ }
+
+ return $this->aFeature;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->feature_id = null;
+ $this->category_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCategory = null;
+ $this->aFeature = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FeatureCategoryTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildFeatureCategory The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = FeatureCategoryTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/FeatureCategoryQuery.php b/core/lib/Thelia/Model/Base/FeatureCategoryQuery.php
new file mode 100644
index 000000000..b9c9a67be
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FeatureCategoryQuery.php
@@ -0,0 +1,759 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFeatureCategory|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FeatureCategoryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FeatureCategoryTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFeatureCategory A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, FEATURE_ID, CATEGORY_ID, CREATED_AT, UPDATED_AT FROM feature_category WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildFeatureCategory();
+ $obj->hydrate($row);
+ FeatureCategoryTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFeatureCategory|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(FeatureCategoryTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(FeatureCategoryTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(FeatureCategoryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(FeatureCategoryTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureCategoryTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the feature_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFeatureId(1234); // WHERE feature_id = 1234
+ * $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34)
+ * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12
+ *
+ *
+ * @see filterByFeature()
+ *
+ * @param mixed $featureId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterByFeatureId($featureId = null, $comparison = null)
+ {
+ if (is_array($featureId)) {
+ $useMinMax = false;
+ if (isset($featureId['min'])) {
+ $this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($featureId['max'])) {
+ $this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId)) {
+ $useMinMax = false;
+ if (isset($categoryId['min'])) {
+ $this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($categoryId['max'])) {
+ $this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Category object
+ *
+ * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCategory($category, $comparison = null)
+ {
+ if ($category instanceof \Thelia\Model\Category) {
+ return $this
+ ->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Category relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Category');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Category');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Category relation Category object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Feature object
+ *
+ * @param \Thelia\Model\Feature|ObjectCollection $feature The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function filterByFeature($feature, $comparison = null)
+ {
+ if ($feature instanceof \Thelia\Model\Feature) {
+ return $this
+ ->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $feature->getId(), $comparison);
+ } elseif ($feature instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFeature() only accepts arguments of type \Thelia\Model\Feature or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Feature relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function joinFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Feature');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Feature');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Feature relation Feature object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeature($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildFeatureCategory $featureCategory Object to remove from the list of results
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function prune($featureCategory = null)
+ {
+ if ($featureCategory) {
+ $this->addUsingAlias(FeatureCategoryTableMap::ID, $featureCategory->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the feature_category table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ FeatureCategoryTableMap::clearInstancePool();
+ FeatureCategoryTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildFeatureCategory or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildFeatureCategory object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureCategoryTableMap::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->beginTransaction();
+
+
+ FeatureCategoryTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ FeatureCategoryTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(FeatureCategoryTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(FeatureCategoryTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(FeatureCategoryTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildFeatureCategoryQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(FeatureCategoryTableMap::CREATED_AT);
+ }
+
+} // FeatureCategoryQuery
diff --git a/core/lib/Thelia/Model/Base/FeatureI18n.php b/core/lib/Thelia/Model/Base/FeatureI18n.php
new file mode 100644
index 000000000..b6070932e
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FeatureI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\FeatureI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another FeatureI18n instance. If
+ * obj is an instance of FeatureI18n, delegates to
+ * equals(FeatureI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return FeatureI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return FeatureI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FeatureI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FeatureI18nTableMap::ID;
+ }
+
+ if ($this->aFeature !== null && $this->aFeature->getId() !== $v) {
+ $this->aFeature = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = FeatureI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = FeatureI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = FeatureI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = FeatureI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = FeatureI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FeatureI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FeatureI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = FeatureI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\FeatureI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aFeature !== null && $this->id !== $this->aFeature->getId()) {
+ $this->aFeature = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FeatureI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildFeatureI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aFeature = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see FeatureI18n::setDeleted()
+ * @see FeatureI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildFeatureI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FeatureI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aFeature !== null) {
+ if ($this->aFeature->isModified() || $this->aFeature->isNew()) {
+ $affectedRows += $this->aFeature->save($con);
+ }
+ $this->setFeature($this->aFeature);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FeatureI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(FeatureI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(FeatureI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(FeatureI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(FeatureI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(FeatureI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO feature_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FeatureI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['FeatureI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['FeatureI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = FeatureI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aFeature) {
+ $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FeatureI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = FeatureI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(FeatureI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(FeatureI18nTableMap::ID)) $criteria->add(FeatureI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(FeatureI18nTableMap::LOCALE)) $criteria->add(FeatureI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(FeatureI18nTableMap::TITLE)) $criteria->add(FeatureI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(FeatureI18nTableMap::DESCRIPTION)) $criteria->add(FeatureI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(FeatureI18nTableMap::CHAPO)) $criteria->add(FeatureI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(FeatureI18nTableMap::POSTSCRIPTUM)) $criteria->add(FeatureI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(FeatureI18nTableMap::DATABASE_NAME);
+ $criteria->add(FeatureI18nTableMap::ID, $this->id);
+ $criteria->add(FeatureI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\FeatureI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\FeatureI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildFeature object.
+ *
+ * @param ChildFeature $v
+ * @return \Thelia\Model\FeatureI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFeature(ChildFeature $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aFeature = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildFeature object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFeatureI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildFeature object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildFeature The associated ChildFeature object.
+ * @throws PropelException
+ */
+ public function getFeature(ConnectionInterface $con = null)
+ {
+ if ($this->aFeature === null && ($this->id !== null)) {
+ $this->aFeature = ChildFeatureQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aFeature->addFeatureI18ns($this);
+ */
+ }
+
+ return $this->aFeature;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aFeature = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FeatureI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/FeatureI18nQuery.php b/core/lib/Thelia/Model/Base/FeatureI18nQuery.php
new file mode 100644
index 000000000..5f7080be6
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FeatureI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFeatureI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FeatureI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FeatureI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFeatureI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM feature_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildFeatureI18n();
+ $obj->hydrate($row);
+ FeatureI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFeatureI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildFeatureI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(FeatureI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(FeatureI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildFeatureI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(FeatureI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(FeatureI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByFeature()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(FeatureI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(FeatureI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Feature object
+ *
+ * @param \Thelia\Model\Feature|ObjectCollection $feature The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureI18nQuery The current query, for fluid interface
+ */
+ public function filterByFeature($feature, $comparison = null)
+ {
+ if ($feature instanceof \Thelia\Model\Feature) {
+ return $this
+ ->addUsingAlias(FeatureI18nTableMap::ID, $feature->getId(), $comparison);
+ } elseif ($feature instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureI18nTableMap::ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFeature() only accepts arguments of type \Thelia\Model\Feature or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Feature relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFeatureI18nQuery The current query, for fluid interface
+ */
+ public function joinFeature($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Feature');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Feature');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Feature relation Feature object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinFeature($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildFeatureI18n $featureI18n Object to remove from the list of results
+ *
+ * @return ChildFeatureI18nQuery The current query, for fluid interface
+ */
+ public function prune($featureI18n = null)
+ {
+ if ($featureI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(FeatureI18nTableMap::ID), $featureI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(FeatureI18nTableMap::LOCALE), $featureI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the feature_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ FeatureI18nTableMap::clearInstancePool();
+ FeatureI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildFeatureI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildFeatureI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureI18nTableMap::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->beginTransaction();
+
+
+ FeatureI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ FeatureI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // FeatureI18nQuery
diff --git a/core/lib/Thelia/Model/Base/FeatureProd.php b/core/lib/Thelia/Model/Base/FeatureProd.php
new file mode 100644
index 000000000..0f14fae8e
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FeatureProd.php
@@ -0,0 +1,1746 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another FeatureProd instance. If
+ * obj is an instance of FeatureProd, delegates to
+ * equals(FeatureProd). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return FeatureProd The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return FeatureProd The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [feature_id] column value.
+ *
+ * @return int
+ */
+ public function getFeatureId()
+ {
+
+ return $this->feature_id;
+ }
+
+ /**
+ * Get the [feature_av_id] column value.
+ *
+ * @return int
+ */
+ public function getFeatureAvId()
+ {
+
+ return $this->feature_av_id;
+ }
+
+ /**
+ * Get the [by_default] column value.
+ *
+ * @return string
+ */
+ public function getByDefault()
+ {
+
+ return $this->by_default;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FeatureProd The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FeatureProdTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FeatureProd The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = FeatureProdTableMap::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [feature_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FeatureProd The current object (for fluent API support)
+ */
+ public function setFeatureId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->feature_id !== $v) {
+ $this->feature_id = $v;
+ $this->modifiedColumns[] = FeatureProdTableMap::FEATURE_ID;
+ }
+
+ if ($this->aFeature !== null && $this->aFeature->getId() !== $v) {
+ $this->aFeature = null;
+ }
+
+
+ return $this;
+ } // setFeatureId()
+
+ /**
+ * Set the value of [feature_av_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FeatureProd The current object (for fluent API support)
+ */
+ public function setFeatureAvId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->feature_av_id !== $v) {
+ $this->feature_av_id = $v;
+ $this->modifiedColumns[] = FeatureProdTableMap::FEATURE_AV_ID;
+ }
+
+ if ($this->aFeatureAv !== null && $this->aFeatureAv->getId() !== $v) {
+ $this->aFeatureAv = null;
+ }
+
+
+ return $this;
+ } // setFeatureAvId()
+
+ /**
+ * Set the value of [by_default] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FeatureProd The current object (for fluent API support)
+ */
+ public function setByDefault($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->by_default !== $v) {
+ $this->by_default = $v;
+ $this->modifiedColumns[] = FeatureProdTableMap::BY_DEFAULT;
+ }
+
+
+ return $this;
+ } // setByDefault()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FeatureProd The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = FeatureProdTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\FeatureProd The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = FeatureProdTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\FeatureProd The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = FeatureProdTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FeatureProdTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureProdTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->product_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureProdTableMap::translateFieldName('FeatureId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->feature_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureProdTableMap::translateFieldName('FeatureAvId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->feature_av_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureProdTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->by_default = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FeatureProdTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : FeatureProdTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : FeatureProdTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = FeatureProdTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\FeatureProd object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) {
+ $this->aFeature = null;
+ }
+ if ($this->aFeatureAv !== null && $this->feature_av_id !== $this->aFeatureAv->getId()) {
+ $this->aFeatureAv = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FeatureProdTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildFeatureProdQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aProduct = null;
+ $this->aFeature = null;
+ $this->aFeatureAv = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see FeatureProd::setDeleted()
+ * @see FeatureProd::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureProdTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildFeatureProdQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureProdTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(FeatureProdTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(FeatureProdTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(FeatureProdTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FeatureProdTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
+ if ($this->aFeature !== null) {
+ if ($this->aFeature->isModified() || $this->aFeature->isNew()) {
+ $affectedRows += $this->aFeature->save($con);
+ }
+ $this->setFeature($this->aFeature);
+ }
+
+ if ($this->aFeatureAv !== null) {
+ if ($this->aFeatureAv->isModified() || $this->aFeatureAv->isNew()) {
+ $affectedRows += $this->aFeatureAv->save($con);
+ }
+ $this->setFeatureAv($this->aFeatureAv);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = FeatureProdTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureProdTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FeatureProdTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(FeatureProdTableMap::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'PRODUCT_ID';
+ }
+ if ($this->isColumnModified(FeatureProdTableMap::FEATURE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'FEATURE_ID';
+ }
+ if ($this->isColumnModified(FeatureProdTableMap::FEATURE_AV_ID)) {
+ $modifiedColumns[':p' . $index++] = 'FEATURE_AV_ID';
+ }
+ if ($this->isColumnModified(FeatureProdTableMap::BY_DEFAULT)) {
+ $modifiedColumns[':p' . $index++] = 'BY_DEFAULT';
+ }
+ if ($this->isColumnModified(FeatureProdTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(FeatureProdTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(FeatureProdTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO feature_prod (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'PRODUCT_ID':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case 'FEATURE_ID':
+ $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT);
+ break;
+ case 'FEATURE_AV_ID':
+ $stmt->bindValue($identifier, $this->feature_av_id, PDO::PARAM_INT);
+ break;
+ case 'BY_DEFAULT':
+ $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_STR);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FeatureProdTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getProductId();
+ break;
+ case 2:
+ return $this->getFeatureId();
+ break;
+ case 3:
+ return $this->getFeatureAvId();
+ break;
+ case 4:
+ return $this->getByDefault();
+ break;
+ case 5:
+ return $this->getPosition();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['FeatureProd'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['FeatureProd'][$this->getPrimaryKey()] = true;
+ $keys = FeatureProdTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getProductId(),
+ $keys[2] => $this->getFeatureId(),
+ $keys[3] => $this->getFeatureAvId(),
+ $keys[4] => $this->getByDefault(),
+ $keys[5] => $this->getPosition(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aFeature) {
+ $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aFeatureAv) {
+ $result['FeatureAv'] = $this->aFeatureAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FeatureProdTableMap::translateFieldName($name, $type, TableMap::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->setProductId($value);
+ break;
+ case 2:
+ $this->setFeatureId($value);
+ break;
+ case 3:
+ $this->setFeatureAvId($value);
+ break;
+ case 4:
+ $this->setByDefault($value);
+ break;
+ case 5:
+ $this->setPosition($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = FeatureProdTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setFeatureId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setFeatureAvId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setByDefault($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPosition($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * 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(FeatureProdTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(FeatureProdTableMap::ID)) $criteria->add(FeatureProdTableMap::ID, $this->id);
+ if ($this->isColumnModified(FeatureProdTableMap::PRODUCT_ID)) $criteria->add(FeatureProdTableMap::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(FeatureProdTableMap::FEATURE_ID)) $criteria->add(FeatureProdTableMap::FEATURE_ID, $this->feature_id);
+ if ($this->isColumnModified(FeatureProdTableMap::FEATURE_AV_ID)) $criteria->add(FeatureProdTableMap::FEATURE_AV_ID, $this->feature_av_id);
+ if ($this->isColumnModified(FeatureProdTableMap::BY_DEFAULT)) $criteria->add(FeatureProdTableMap::BY_DEFAULT, $this->by_default);
+ if ($this->isColumnModified(FeatureProdTableMap::POSITION)) $criteria->add(FeatureProdTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(FeatureProdTableMap::CREATED_AT)) $criteria->add(FeatureProdTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(FeatureProdTableMap::UPDATED_AT)) $criteria->add(FeatureProdTableMap::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(FeatureProdTableMap::DATABASE_NAME);
+ $criteria->add(FeatureProdTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\FeatureProd (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setFeatureId($this->getFeatureId());
+ $copyObj->setFeatureAvId($this->getFeatureAvId());
+ $copyObj->setByDefault($this->getByDefault());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\FeatureProd 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildProduct object.
+ *
+ * @param ChildProduct $v
+ * @return \Thelia\Model\FeatureProd The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(ChildProduct $v = null)
+ {
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
+ }
+
+ $this->aProduct = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildProduct object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFeatureProd($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildProduct object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildProduct The associated ChildProduct object.
+ * @throws PropelException
+ */
+ public function getProduct(ConnectionInterface $con = null)
+ {
+ if ($this->aProduct === null && ($this->product_id !== null)) {
+ $this->aProduct = ChildProductQuery::create()->findPk($this->product_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aProduct->addFeatureProds($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
+ /**
+ * Declares an association between this object and a ChildFeature object.
+ *
+ * @param ChildFeature $v
+ * @return \Thelia\Model\FeatureProd The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFeature(ChildFeature $v = null)
+ {
+ if ($v === null) {
+ $this->setFeatureId(NULL);
+ } else {
+ $this->setFeatureId($v->getId());
+ }
+
+ $this->aFeature = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildFeature object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFeatureProd($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildFeature object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildFeature The associated ChildFeature object.
+ * @throws PropelException
+ */
+ public function getFeature(ConnectionInterface $con = null)
+ {
+ if ($this->aFeature === null && ($this->feature_id !== null)) {
+ $this->aFeature = ChildFeatureQuery::create()->findPk($this->feature_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aFeature->addFeatureProds($this);
+ */
+ }
+
+ return $this->aFeature;
+ }
+
+ /**
+ * Declares an association between this object and a ChildFeatureAv object.
+ *
+ * @param ChildFeatureAv $v
+ * @return \Thelia\Model\FeatureProd The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFeatureAv(ChildFeatureAv $v = null)
+ {
+ if ($v === null) {
+ $this->setFeatureAvId(NULL);
+ } else {
+ $this->setFeatureAvId($v->getId());
+ }
+
+ $this->aFeatureAv = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildFeatureAv object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFeatureProd($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildFeatureAv object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildFeatureAv The associated ChildFeatureAv object.
+ * @throws PropelException
+ */
+ public function getFeatureAv(ConnectionInterface $con = null)
+ {
+ if ($this->aFeatureAv === null && ($this->feature_av_id !== null)) {
+ $this->aFeatureAv = ChildFeatureAvQuery::create()->findPk($this->feature_av_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aFeatureAv->addFeatureProds($this);
+ */
+ }
+
+ return $this->aFeatureAv;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->product_id = null;
+ $this->feature_id = null;
+ $this->feature_av_id = null;
+ $this->by_default = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aProduct = null;
+ $this->aFeature = null;
+ $this->aFeatureAv = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FeatureProdTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildFeatureProd The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = FeatureProdTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/FeatureProdQuery.php b/core/lib/Thelia/Model/Base/FeatureProdQuery.php
new file mode 100644
index 000000000..14f5a551b
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FeatureProdQuery.php
@@ -0,0 +1,963 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFeatureProd|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FeatureProdTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FeatureProdTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFeatureProd A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, PRODUCT_ID, FEATURE_ID, FEATURE_AV_ID, BY_DEFAULT, POSITION, CREATED_AT, UPDATED_AT FROM feature_prod WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildFeatureProd();
+ $obj->hydrate($row);
+ FeatureProdTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFeatureProd|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(FeatureProdTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(FeatureProdTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(FeatureProdTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(FeatureProdTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureProdTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(FeatureProdTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(FeatureProdTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureProdTableMap::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the feature_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFeatureId(1234); // WHERE feature_id = 1234
+ * $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34)
+ * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12
+ *
+ *
+ * @see filterByFeature()
+ *
+ * @param mixed $featureId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByFeatureId($featureId = null, $comparison = null)
+ {
+ if (is_array($featureId)) {
+ $useMinMax = false;
+ if (isset($featureId['min'])) {
+ $this->addUsingAlias(FeatureProdTableMap::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($featureId['max'])) {
+ $this->addUsingAlias(FeatureProdTableMap::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureProdTableMap::FEATURE_ID, $featureId, $comparison);
+ }
+
+ /**
+ * Filter the query on the feature_av_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFeatureAvId(1234); // WHERE feature_av_id = 1234
+ * $query->filterByFeatureAvId(array(12, 34)); // WHERE feature_av_id IN (12, 34)
+ * $query->filterByFeatureAvId(array('min' => 12)); // WHERE feature_av_id > 12
+ *
+ *
+ * @see filterByFeatureAv()
+ *
+ * @param mixed $featureAvId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByFeatureAvId($featureAvId = null, $comparison = null)
+ {
+ if (is_array($featureAvId)) {
+ $useMinMax = false;
+ if (isset($featureAvId['min'])) {
+ $this->addUsingAlias(FeatureProdTableMap::FEATURE_AV_ID, $featureAvId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($featureAvId['max'])) {
+ $this->addUsingAlias(FeatureProdTableMap::FEATURE_AV_ID, $featureAvId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureProdTableMap::FEATURE_AV_ID, $featureAvId, $comparison);
+ }
+
+ /**
+ * Filter the query on the by_default column
+ *
+ * Example usage:
+ *
+ * $query->filterByByDefault('fooValue'); // WHERE by_default = 'fooValue'
+ * $query->filterByByDefault('%fooValue%'); // WHERE by_default LIKE '%fooValue%'
+ *
+ *
+ * @param string $byDefault The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByByDefault($byDefault = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($byDefault)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $byDefault)) {
+ $byDefault = str_replace('*', '%', $byDefault);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureProdTableMap::BY_DEFAULT, $byDefault, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(FeatureProdTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(FeatureProdTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureProdTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(FeatureProdTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(FeatureProdTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureProdTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(FeatureProdTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(FeatureProdTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureProdTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Product object
+ *
+ * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByProduct($product, $comparison = null)
+ {
+ if ($product instanceof \Thelia\Model\Product) {
+ return $this
+ ->addUsingAlias(FeatureProdTableMap::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureProdTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Product relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Product');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Product');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Product relation Product object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
+ */
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Feature object
+ *
+ * @param \Thelia\Model\Feature|ObjectCollection $feature The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByFeature($feature, $comparison = null)
+ {
+ if ($feature instanceof \Thelia\Model\Feature) {
+ return $this
+ ->addUsingAlias(FeatureProdTableMap::FEATURE_ID, $feature->getId(), $comparison);
+ } elseif ($feature instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureProdTableMap::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFeature() only accepts arguments of type \Thelia\Model\Feature or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Feature relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function joinFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Feature');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Feature');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Feature relation Feature object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeature($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\FeatureAv object
+ *
+ * @param \Thelia\Model\FeatureAv|ObjectCollection $featureAv The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function filterByFeatureAv($featureAv, $comparison = null)
+ {
+ if ($featureAv instanceof \Thelia\Model\FeatureAv) {
+ return $this
+ ->addUsingAlias(FeatureProdTableMap::FEATURE_AV_ID, $featureAv->getId(), $comparison);
+ } elseif ($featureAv instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FeatureProdTableMap::FEATURE_AV_ID, $featureAv->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFeatureAv() only accepts arguments of type \Thelia\Model\FeatureAv or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureAv relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function joinFeatureAv($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureAv');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureAv');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureAv relation FeatureAv object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureAvQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureAvQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinFeatureAv($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildFeatureProd $featureProd Object to remove from the list of results
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function prune($featureProd = null)
+ {
+ if ($featureProd) {
+ $this->addUsingAlias(FeatureProdTableMap::ID, $featureProd->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the feature_prod table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureProdTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ FeatureProdTableMap::clearInstancePool();
+ FeatureProdTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildFeatureProd or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildFeatureProd object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureProdTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureProdTableMap::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->beginTransaction();
+
+
+ FeatureProdTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ FeatureProdTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(FeatureProdTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(FeatureProdTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(FeatureProdTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(FeatureProdTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(FeatureProdTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildFeatureProdQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(FeatureProdTableMap::CREATED_AT);
+ }
+
+} // FeatureProdQuery
diff --git a/core/lib/Thelia/Model/Base/FeatureQuery.php b/core/lib/Thelia/Model/Base/FeatureQuery.php
new file mode 100644
index 000000000..add0494aa
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FeatureQuery.php
@@ -0,0 +1,980 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFeature|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FeatureTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FeatureTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFeature A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, VISIBLE, POSITION, CREATED_AT, UPDATED_AT FROM feature WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildFeature();
+ $obj->hydrate($row);
+ FeatureTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFeature|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(FeatureTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(FeatureTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(FeatureTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(FeatureTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the visible column
+ *
+ * Example usage:
+ *
+ * $query->filterByVisible(1234); // WHERE visible = 1234
+ * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
+ * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
+ *
+ *
+ * @param mixed $visible The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function filterByVisible($visible = null, $comparison = null)
+ {
+ if (is_array($visible)) {
+ $useMinMax = false;
+ if (isset($visible['min'])) {
+ $this->addUsingAlias(FeatureTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(FeatureTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureTableMap::VISIBLE, $visible, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(FeatureTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(FeatureTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(FeatureTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(FeatureTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(FeatureTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(FeatureTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FeatureTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\FeatureAv object
+ *
+ * @param \Thelia\Model\FeatureAv|ObjectCollection $featureAv the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function filterByFeatureAv($featureAv, $comparison = null)
+ {
+ if ($featureAv instanceof \Thelia\Model\FeatureAv) {
+ return $this
+ ->addUsingAlias(FeatureTableMap::ID, $featureAv->getFeatureId(), $comparison);
+ } elseif ($featureAv instanceof ObjectCollection) {
+ return $this
+ ->useFeatureAvQuery()
+ ->filterByPrimaryKeys($featureAv->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureAv() only accepts arguments of type \Thelia\Model\FeatureAv or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureAv relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function joinFeatureAv($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureAv');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureAv');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureAv relation FeatureAv object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureAvQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeatureAv($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\FeatureProd object
+ *
+ * @param \Thelia\Model\FeatureProd|ObjectCollection $featureProd the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function filterByFeatureProd($featureProd, $comparison = null)
+ {
+ if ($featureProd instanceof \Thelia\Model\FeatureProd) {
+ return $this
+ ->addUsingAlias(FeatureTableMap::ID, $featureProd->getFeatureId(), $comparison);
+ } elseif ($featureProd instanceof ObjectCollection) {
+ return $this
+ ->useFeatureProdQuery()
+ ->filterByPrimaryKeys($featureProd->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureProd() only accepts arguments of type \Thelia\Model\FeatureProd or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureProd relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function joinFeatureProd($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureProd');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureProd');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureProd relation FeatureProd object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureProdQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureProdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeatureProd($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureProd', '\Thelia\Model\FeatureProdQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\FeatureCategory object
+ *
+ * @param \Thelia\Model\FeatureCategory|ObjectCollection $featureCategory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function filterByFeatureCategory($featureCategory, $comparison = null)
+ {
+ if ($featureCategory instanceof \Thelia\Model\FeatureCategory) {
+ return $this
+ ->addUsingAlias(FeatureTableMap::ID, $featureCategory->getFeatureId(), $comparison);
+ } elseif ($featureCategory instanceof ObjectCollection) {
+ return $this
+ ->useFeatureCategoryQuery()
+ ->filterByPrimaryKeys($featureCategory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureCategory() only accepts arguments of type \Thelia\Model\FeatureCategory or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureCategory relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function joinFeatureCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureCategory');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureCategory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureCategory relation FeatureCategory object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureCategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeatureCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureCategory', '\Thelia\Model\FeatureCategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\FeatureI18n object
+ *
+ * @param \Thelia\Model\FeatureI18n|ObjectCollection $featureI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function filterByFeatureI18n($featureI18n, $comparison = null)
+ {
+ if ($featureI18n instanceof \Thelia\Model\FeatureI18n) {
+ return $this
+ ->addUsingAlias(FeatureTableMap::ID, $featureI18n->getId(), $comparison);
+ } elseif ($featureI18n instanceof ObjectCollection) {
+ return $this
+ ->useFeatureI18nQuery()
+ ->filterByPrimaryKeys($featureI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureI18n() only accepts arguments of type \Thelia\Model\FeatureI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function joinFeatureI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureI18n relation FeatureI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinFeatureI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureI18n', '\Thelia\Model\FeatureI18nQuery');
+ }
+
+ /**
+ * Filter the query by a related Category object
+ * using the feature_category table as cross reference
+ *
+ * @param Category $category the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function filterByCategory($category, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useFeatureCategoryQuery()
+ ->filterByCategory($category, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildFeature $feature Object to remove from the list of results
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function prune($feature = null)
+ {
+ if ($feature) {
+ $this->addUsingAlias(FeatureTableMap::ID, $feature->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the feature table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ FeatureTableMap::clearInstancePool();
+ FeatureTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildFeature or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildFeature object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(FeatureTableMap::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->beginTransaction();
+
+
+ FeatureTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ FeatureTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(FeatureTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(FeatureTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(FeatureTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(FeatureTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(FeatureTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(FeatureTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'FeatureI18n';
+
+ return $this
+ ->joinFeatureI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildFeatureQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('FeatureI18n');
+ $this->with['FeatureI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildFeatureI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureI18n', '\Thelia\Model\FeatureI18nQuery');
+ }
+
+} // FeatureQuery
diff --git a/core/lib/Thelia/Model/Base/Folder.php b/core/lib/Thelia/Model/Base/Folder.php
new file mode 100644
index 000000000..a8bd93633
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Folder.php
@@ -0,0 +1,4327 @@
+version = 0;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\Folder object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Folder instance. If
+ * obj is an instance of Folder, delegates to
+ * equals(Folder). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Folder The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Folder The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [parent] column value.
+ *
+ * @return int
+ */
+ public function getParent()
+ {
+
+ return $this->parent;
+ }
+
+ /**
+ * Get the [link] column value.
+ *
+ * @return string
+ */
+ public function getLink()
+ {
+
+ return $this->link;
+ }
+
+ /**
+ * Get the [visible] column value.
+ *
+ * @return int
+ */
+ public function getVisible()
+ {
+
+ return $this->visible;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getVersionCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->version_created_at;
+ } else {
+ return $this->version_created_at !== null ? $this->version_created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FolderTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [parent] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function setParent($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->parent !== $v) {
+ $this->parent = $v;
+ $this->modifiedColumns[] = FolderTableMap::PARENT;
+ }
+
+
+ return $this;
+ } // setParent()
+
+ /**
+ * Set the value of [link] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function setLink($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->link !== $v) {
+ $this->link = $v;
+ $this->modifiedColumns[] = FolderTableMap::LINK;
+ }
+
+
+ return $this;
+ } // setLink()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function setVisible($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->visible !== $v) {
+ $this->visible = $v;
+ $this->modifiedColumns[] = FolderTableMap::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = FolderTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = FolderTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = FolderTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = FolderTableMap::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ if ($dt !== $this->version_created_at) {
+ $this->version_created_at = $dt;
+ $this->modifiedColumns[] = FolderTableMap::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = FolderTableMap::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->version !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FolderTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FolderTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->parent = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FolderTableMap::translateFieldName('Link', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->link = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FolderTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->visible = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FolderTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : FolderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : FolderTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : FolderTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : FolderTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version_created_by = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 10; // 10 = FolderTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Folder object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FolderTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildFolderQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collImages = null;
+
+ $this->collDocuments = null;
+
+ $this->collRewritings = null;
+
+ $this->collContentFolders = null;
+
+ $this->collFolderI18ns = null;
+
+ $this->collFolderVersions = null;
+
+ $this->collContents = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Folder::setDeleted()
+ * @see Folder::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildFolderQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ // versionable behavior
+ if ($this->isVersioningNecessary()) {
+ $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
+ if (!$this->isColumnModified(FolderTableMap::VERSION_CREATED_AT)) {
+ $this->setVersionCreatedAt(time());
+ }
+ $createVersion = true; // for postSave hook
+ }
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(FolderTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(FolderTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(FolderTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ // versionable behavior
+ if (isset($createVersion)) {
+ $this->addVersion($con);
+ }
+ FolderTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->contentsScheduledForDeletion !== null) {
+ if (!$this->contentsScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->contentsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($remotePk, $pk);
+ }
+
+ ContentFolderQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->contentsScheduledForDeletion = null;
+ }
+
+ foreach ($this->getContents() as $content) {
+ if ($content->isModified()) {
+ $content->save($con);
+ }
+ }
+ } elseif ($this->collContents) {
+ foreach ($this->collContents as $content) {
+ if ($content->isModified()) {
+ $content->save($con);
+ }
+ }
+ }
+
+ if ($this->imagesScheduledForDeletion !== null) {
+ if (!$this->imagesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ImageQuery::create()
+ ->filterByPrimaryKeys($this->imagesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->imagesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collImages !== null) {
+ foreach ($this->collImages as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->documentsScheduledForDeletion !== null) {
+ if (!$this->documentsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\DocumentQuery::create()
+ ->filterByPrimaryKeys($this->documentsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->documentsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collDocuments !== null) {
+ foreach ($this->collDocuments as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->rewritingsScheduledForDeletion !== null) {
+ if (!$this->rewritingsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\RewritingQuery::create()
+ ->filterByPrimaryKeys($this->rewritingsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->rewritingsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collRewritings !== null) {
+ foreach ($this->collRewritings as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->contentFoldersScheduledForDeletion !== null) {
+ if (!$this->contentFoldersScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ContentFolderQuery::create()
+ ->filterByPrimaryKeys($this->contentFoldersScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->contentFoldersScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collContentFolders !== null) {
+ foreach ($this->collContentFolders as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->folderI18nsScheduledForDeletion !== null) {
+ if (!$this->folderI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\FolderI18nQuery::create()
+ ->filterByPrimaryKeys($this->folderI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->folderI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collFolderI18ns !== null) {
+ foreach ($this->collFolderI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->folderVersionsScheduledForDeletion !== null) {
+ if (!$this->folderVersionsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\FolderVersionQuery::create()
+ ->filterByPrimaryKeys($this->folderVersionsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->folderVersionsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collFolderVersions !== null) {
+ foreach ($this->collFolderVersions as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = FolderTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . FolderTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FolderTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(FolderTableMap::PARENT)) {
+ $modifiedColumns[':p' . $index++] = 'PARENT';
+ }
+ if ($this->isColumnModified(FolderTableMap::LINK)) {
+ $modifiedColumns[':p' . $index++] = 'LINK';
+ }
+ if ($this->isColumnModified(FolderTableMap::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = 'VISIBLE';
+ }
+ if ($this->isColumnModified(FolderTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(FolderTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(FolderTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+ if ($this->isColumnModified(FolderTableMap::VERSION)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION';
+ }
+ if ($this->isColumnModified(FolderTableMap::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT';
+ }
+ if ($this->isColumnModified(FolderTableMap::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO folder (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'PARENT':
+ $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT);
+ break;
+ case 'LINK':
+ $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR);
+ break;
+ case 'VISIBLE':
+ $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case 'VERSION_CREATED_AT':
+ $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION_CREATED_BY':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FolderTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getParent();
+ break;
+ case 2:
+ return $this->getLink();
+ break;
+ case 3:
+ return $this->getVisible();
+ break;
+ case 4:
+ return $this->getPosition();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ case 7:
+ return $this->getVersion();
+ break;
+ case 8:
+ return $this->getVersionCreatedAt();
+ break;
+ case 9:
+ return $this->getVersionCreatedBy();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Folder'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Folder'][$this->getPrimaryKey()] = true;
+ $keys = FolderTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getParent(),
+ $keys[2] => $this->getLink(),
+ $keys[3] => $this->getVisible(),
+ $keys[4] => $this->getPosition(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ $keys[7] => $this->getVersion(),
+ $keys[8] => $this->getVersionCreatedAt(),
+ $keys[9] => $this->getVersionCreatedBy(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collImages) {
+ $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collDocuments) {
+ $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collRewritings) {
+ $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collContentFolders) {
+ $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFolderI18ns) {
+ $result['FolderI18ns'] = $this->collFolderI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFolderVersions) {
+ $result['FolderVersions'] = $this->collFolderVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FolderTableMap::translateFieldName($name, $type, TableMap::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->setParent($value);
+ break;
+ case 2:
+ $this->setLink($value);
+ break;
+ case 3:
+ $this->setVisible($value);
+ break;
+ case 4:
+ $this->setPosition($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ case 7:
+ $this->setVersion($value);
+ break;
+ case 8:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 9:
+ $this->setVersionCreatedBy($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = FolderTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]);
+ }
+
+ /**
+ * 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(FolderTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(FolderTableMap::ID)) $criteria->add(FolderTableMap::ID, $this->id);
+ if ($this->isColumnModified(FolderTableMap::PARENT)) $criteria->add(FolderTableMap::PARENT, $this->parent);
+ if ($this->isColumnModified(FolderTableMap::LINK)) $criteria->add(FolderTableMap::LINK, $this->link);
+ if ($this->isColumnModified(FolderTableMap::VISIBLE)) $criteria->add(FolderTableMap::VISIBLE, $this->visible);
+ if ($this->isColumnModified(FolderTableMap::POSITION)) $criteria->add(FolderTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(FolderTableMap::CREATED_AT)) $criteria->add(FolderTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(FolderTableMap::UPDATED_AT)) $criteria->add(FolderTableMap::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(FolderTableMap::VERSION)) $criteria->add(FolderTableMap::VERSION, $this->version);
+ if ($this->isColumnModified(FolderTableMap::VERSION_CREATED_AT)) $criteria->add(FolderTableMap::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(FolderTableMap::VERSION_CREATED_BY)) $criteria->add(FolderTableMap::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(FolderTableMap::DATABASE_NAME);
+ $criteria->add(FolderTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Folder (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setParent($this->getParent());
+ $copyObj->setLink($this->getLink());
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+
+ 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->getImages() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addImage($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getDocuments() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addDocument($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getRewritings() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addRewriting($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getContentFolders() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addContentFolder($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getFolderI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFolderI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getFolderVersions() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFolderVersion($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Folder 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('Image' == $relationName) {
+ return $this->initImages();
+ }
+ if ('Document' == $relationName) {
+ return $this->initDocuments();
+ }
+ if ('Rewriting' == $relationName) {
+ return $this->initRewritings();
+ }
+ if ('ContentFolder' == $relationName) {
+ return $this->initContentFolders();
+ }
+ if ('FolderI18n' == $relationName) {
+ return $this->initFolderI18ns();
+ }
+ if ('FolderVersion' == $relationName) {
+ return $this->initFolderVersions();
+ }
+ }
+
+ /**
+ * Clears out the collImages collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addImages()
+ */
+ public function clearImages()
+ {
+ $this->collImages = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collImages collection loaded partially.
+ */
+ public function resetPartialImages($v = true)
+ {
+ $this->collImagesPartial = $v;
+ }
+
+ /**
+ * Initializes the collImages collection.
+ *
+ * By default this just sets the collImages collection to an empty array (like clearcollImages());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initImages($overrideExisting = true)
+ {
+ if (null !== $this->collImages && !$overrideExisting) {
+ return;
+ }
+ $this->collImages = new ObjectCollection();
+ $this->collImages->setModel('\Thelia\Model\Image');
+ }
+
+ /**
+ * Gets an array of ChildImage objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildFolder is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildImage[] List of ChildImage objects
+ * @throws PropelException
+ */
+ public function getImages($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collImagesPartial && !$this->isNew();
+ if (null === $this->collImages || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collImages) {
+ // return empty collection
+ $this->initImages();
+ } else {
+ $collImages = ChildImageQuery::create(null, $criteria)
+ ->filterByFolder($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collImagesPartial && count($collImages)) {
+ $this->initImages(false);
+
+ foreach ($collImages as $obj) {
+ if (false == $this->collImages->contains($obj)) {
+ $this->collImages->append($obj);
+ }
+ }
+
+ $this->collImagesPartial = true;
+ }
+
+ $collImages->getInternalIterator()->rewind();
+
+ return $collImages;
+ }
+
+ if ($partial && $this->collImages) {
+ foreach ($this->collImages as $obj) {
+ if ($obj->isNew()) {
+ $collImages[] = $obj;
+ }
+ }
+ }
+
+ $this->collImages = $collImages;
+ $this->collImagesPartial = false;
+ }
+ }
+
+ return $this->collImages;
+ }
+
+ /**
+ * Sets a collection of Image objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $images A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function setImages(Collection $images, ConnectionInterface $con = null)
+ {
+ $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images);
+
+
+ $this->imagesScheduledForDeletion = $imagesToDelete;
+
+ foreach ($imagesToDelete as $imageRemoved) {
+ $imageRemoved->setFolder(null);
+ }
+
+ $this->collImages = null;
+ foreach ($images as $image) {
+ $this->addImage($image);
+ }
+
+ $this->collImages = $images;
+ $this->collImagesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Image objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Image objects.
+ * @throws PropelException
+ */
+ public function countImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collImagesPartial && !$this->isNew();
+ if (null === $this->collImages || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collImages) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getImages());
+ }
+
+ $query = ChildImageQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFolder($this)
+ ->count($con);
+ }
+
+ return count($this->collImages);
+ }
+
+ /**
+ * Method called to associate a ChildImage object to this object
+ * through the ChildImage foreign key attribute.
+ *
+ * @param ChildImage $l ChildImage
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function addImage(ChildImage $l)
+ {
+ if ($this->collImages === null) {
+ $this->initImages();
+ $this->collImagesPartial = true;
+ }
+
+ if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddImage($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Image $image The image object to add.
+ */
+ protected function doAddImage($image)
+ {
+ $this->collImages[]= $image;
+ $image->setFolder($this);
+ }
+
+ /**
+ * @param Image $image The image object to remove.
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function removeImage($image)
+ {
+ if ($this->getImages()->contains($image)) {
+ $this->collImages->remove($this->collImages->search($image));
+ if (null === $this->imagesScheduledForDeletion) {
+ $this->imagesScheduledForDeletion = clone $this->collImages;
+ $this->imagesScheduledForDeletion->clear();
+ }
+ $this->imagesScheduledForDeletion[]= $image;
+ $image->setFolder(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Folder is new, it will return
+ * an empty collection; or if this Folder has previously
+ * been saved, it will retrieve related Images 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 Folder.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildImage[] List of ChildImage objects
+ */
+ public function getImagesJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildImageQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getImages($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Folder is new, it will return
+ * an empty collection; or if this Folder has previously
+ * been saved, it will retrieve related Images 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 Folder.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildImage[] List of ChildImage objects
+ */
+ public function getImagesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildImageQuery::create(null, $criteria);
+ $query->joinWith('Category', $joinBehavior);
+
+ return $this->getImages($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Folder is new, it will return
+ * an empty collection; or if this Folder has previously
+ * been saved, it will retrieve related Images 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 Folder.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildImage[] List of ChildImage objects
+ */
+ public function getImagesJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildImageQuery::create(null, $criteria);
+ $query->joinWith('Content', $joinBehavior);
+
+ return $this->getImages($query, $con);
+ }
+
+ /**
+ * Clears out the collDocuments collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addDocuments()
+ */
+ public function clearDocuments()
+ {
+ $this->collDocuments = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collDocuments collection loaded partially.
+ */
+ public function resetPartialDocuments($v = true)
+ {
+ $this->collDocumentsPartial = $v;
+ }
+
+ /**
+ * Initializes the collDocuments collection.
+ *
+ * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initDocuments($overrideExisting = true)
+ {
+ if (null !== $this->collDocuments && !$overrideExisting) {
+ return;
+ }
+ $this->collDocuments = new ObjectCollection();
+ $this->collDocuments->setModel('\Thelia\Model\Document');
+ }
+
+ /**
+ * Gets an array of ChildDocument objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildFolder is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ * @throws PropelException
+ */
+ public function getDocuments($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collDocumentsPartial && !$this->isNew();
+ if (null === $this->collDocuments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocuments) {
+ // return empty collection
+ $this->initDocuments();
+ } else {
+ $collDocuments = ChildDocumentQuery::create(null, $criteria)
+ ->filterByFolder($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collDocumentsPartial && count($collDocuments)) {
+ $this->initDocuments(false);
+
+ foreach ($collDocuments as $obj) {
+ if (false == $this->collDocuments->contains($obj)) {
+ $this->collDocuments->append($obj);
+ }
+ }
+
+ $this->collDocumentsPartial = true;
+ }
+
+ $collDocuments->getInternalIterator()->rewind();
+
+ return $collDocuments;
+ }
+
+ if ($partial && $this->collDocuments) {
+ foreach ($this->collDocuments as $obj) {
+ if ($obj->isNew()) {
+ $collDocuments[] = $obj;
+ }
+ }
+ }
+
+ $this->collDocuments = $collDocuments;
+ $this->collDocumentsPartial = false;
+ }
+ }
+
+ return $this->collDocuments;
+ }
+
+ /**
+ * Sets a collection of Document objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $documents A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function setDocuments(Collection $documents, ConnectionInterface $con = null)
+ {
+ $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents);
+
+
+ $this->documentsScheduledForDeletion = $documentsToDelete;
+
+ foreach ($documentsToDelete as $documentRemoved) {
+ $documentRemoved->setFolder(null);
+ }
+
+ $this->collDocuments = null;
+ foreach ($documents as $document) {
+ $this->addDocument($document);
+ }
+
+ $this->collDocuments = $documents;
+ $this->collDocumentsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Document objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Document objects.
+ * @throws PropelException
+ */
+ public function countDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collDocumentsPartial && !$this->isNew();
+ if (null === $this->collDocuments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocuments) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getDocuments());
+ }
+
+ $query = ChildDocumentQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFolder($this)
+ ->count($con);
+ }
+
+ return count($this->collDocuments);
+ }
+
+ /**
+ * Method called to associate a ChildDocument object to this object
+ * through the ChildDocument foreign key attribute.
+ *
+ * @param ChildDocument $l ChildDocument
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function addDocument(ChildDocument $l)
+ {
+ if ($this->collDocuments === null) {
+ $this->initDocuments();
+ $this->collDocumentsPartial = true;
+ }
+
+ if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddDocument($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Document $document The document object to add.
+ */
+ protected function doAddDocument($document)
+ {
+ $this->collDocuments[]= $document;
+ $document->setFolder($this);
+ }
+
+ /**
+ * @param Document $document The document object to remove.
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function removeDocument($document)
+ {
+ if ($this->getDocuments()->contains($document)) {
+ $this->collDocuments->remove($this->collDocuments->search($document));
+ if (null === $this->documentsScheduledForDeletion) {
+ $this->documentsScheduledForDeletion = clone $this->collDocuments;
+ $this->documentsScheduledForDeletion->clear();
+ }
+ $this->documentsScheduledForDeletion[]= $document;
+ $document->setFolder(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Folder is new, it will return
+ * an empty collection; or if this Folder has previously
+ * been saved, it will retrieve related Documents 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 Folder.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ */
+ public function getDocumentsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildDocumentQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Folder is new, it will return
+ * an empty collection; or if this Folder has previously
+ * been saved, it will retrieve related Documents 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 Folder.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ */
+ public function getDocumentsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildDocumentQuery::create(null, $criteria);
+ $query->joinWith('Category', $joinBehavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Folder is new, it will return
+ * an empty collection; or if this Folder has previously
+ * been saved, it will retrieve related Documents 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 Folder.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ */
+ public function getDocumentsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildDocumentQuery::create(null, $criteria);
+ $query->joinWith('Content', $joinBehavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+ /**
+ * Clears out the collRewritings collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addRewritings()
+ */
+ public function clearRewritings()
+ {
+ $this->collRewritings = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collRewritings collection loaded partially.
+ */
+ public function resetPartialRewritings($v = true)
+ {
+ $this->collRewritingsPartial = $v;
+ }
+
+ /**
+ * Initializes the collRewritings collection.
+ *
+ * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initRewritings($overrideExisting = true)
+ {
+ if (null !== $this->collRewritings && !$overrideExisting) {
+ return;
+ }
+ $this->collRewritings = new ObjectCollection();
+ $this->collRewritings->setModel('\Thelia\Model\Rewriting');
+ }
+
+ /**
+ * Gets an array of ChildRewriting objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildFolder is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ * @throws PropelException
+ */
+ public function getRewritings($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ // return empty collection
+ $this->initRewritings();
+ } else {
+ $collRewritings = ChildRewritingQuery::create(null, $criteria)
+ ->filterByFolder($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collRewritingsPartial && count($collRewritings)) {
+ $this->initRewritings(false);
+
+ foreach ($collRewritings as $obj) {
+ if (false == $this->collRewritings->contains($obj)) {
+ $this->collRewritings->append($obj);
+ }
+ }
+
+ $this->collRewritingsPartial = true;
+ }
+
+ $collRewritings->getInternalIterator()->rewind();
+
+ return $collRewritings;
+ }
+
+ if ($partial && $this->collRewritings) {
+ foreach ($this->collRewritings as $obj) {
+ if ($obj->isNew()) {
+ $collRewritings[] = $obj;
+ }
+ }
+ }
+
+ $this->collRewritings = $collRewritings;
+ $this->collRewritingsPartial = false;
+ }
+ }
+
+ return $this->collRewritings;
+ }
+
+ /**
+ * Sets a collection of Rewriting objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $rewritings A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function setRewritings(Collection $rewritings, ConnectionInterface $con = null)
+ {
+ $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings);
+
+
+ $this->rewritingsScheduledForDeletion = $rewritingsToDelete;
+
+ foreach ($rewritingsToDelete as $rewritingRemoved) {
+ $rewritingRemoved->setFolder(null);
+ }
+
+ $this->collRewritings = null;
+ foreach ($rewritings as $rewriting) {
+ $this->addRewriting($rewriting);
+ }
+
+ $this->collRewritings = $rewritings;
+ $this->collRewritingsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Rewriting objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Rewriting objects.
+ * @throws PropelException
+ */
+ public function countRewritings(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getRewritings());
+ }
+
+ $query = ChildRewritingQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFolder($this)
+ ->count($con);
+ }
+
+ return count($this->collRewritings);
+ }
+
+ /**
+ * Method called to associate a ChildRewriting object to this object
+ * through the ChildRewriting foreign key attribute.
+ *
+ * @param ChildRewriting $l ChildRewriting
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function addRewriting(ChildRewriting $l)
+ {
+ if ($this->collRewritings === null) {
+ $this->initRewritings();
+ $this->collRewritingsPartial = true;
+ }
+
+ if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddRewriting($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Rewriting $rewriting The rewriting object to add.
+ */
+ protected function doAddRewriting($rewriting)
+ {
+ $this->collRewritings[]= $rewriting;
+ $rewriting->setFolder($this);
+ }
+
+ /**
+ * @param Rewriting $rewriting The rewriting object to remove.
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function removeRewriting($rewriting)
+ {
+ if ($this->getRewritings()->contains($rewriting)) {
+ $this->collRewritings->remove($this->collRewritings->search($rewriting));
+ if (null === $this->rewritingsScheduledForDeletion) {
+ $this->rewritingsScheduledForDeletion = clone $this->collRewritings;
+ $this->rewritingsScheduledForDeletion->clear();
+ }
+ $this->rewritingsScheduledForDeletion[]= $rewriting;
+ $rewriting->setFolder(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Folder is new, it will return
+ * an empty collection; or if this Folder has previously
+ * been saved, it will retrieve related Rewritings 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 Folder.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ */
+ public function getRewritingsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildRewritingQuery::create(null, $criteria);
+ $query->joinWith('Product', $joinBehavior);
+
+ return $this->getRewritings($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Folder is new, it will return
+ * an empty collection; or if this Folder has previously
+ * been saved, it will retrieve related Rewritings 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 Folder.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ */
+ public function getRewritingsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildRewritingQuery::create(null, $criteria);
+ $query->joinWith('Category', $joinBehavior);
+
+ return $this->getRewritings($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Folder is new, it will return
+ * an empty collection; or if this Folder has previously
+ * been saved, it will retrieve related Rewritings 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 Folder.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ */
+ public function getRewritingsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildRewritingQuery::create(null, $criteria);
+ $query->joinWith('Content', $joinBehavior);
+
+ return $this->getRewritings($query, $con);
+ }
+
+ /**
+ * Clears out the collContentFolders collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addContentFolders()
+ */
+ public function clearContentFolders()
+ {
+ $this->collContentFolders = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collContentFolders collection loaded partially.
+ */
+ public function resetPartialContentFolders($v = true)
+ {
+ $this->collContentFoldersPartial = $v;
+ }
+
+ /**
+ * Initializes the collContentFolders collection.
+ *
+ * By default this just sets the collContentFolders collection to an empty array (like clearcollContentFolders());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initContentFolders($overrideExisting = true)
+ {
+ if (null !== $this->collContentFolders && !$overrideExisting) {
+ return;
+ }
+ $this->collContentFolders = new ObjectCollection();
+ $this->collContentFolders->setModel('\Thelia\Model\ContentFolder');
+ }
+
+ /**
+ * Gets an array of ChildContentFolder objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildFolder is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildContentFolder[] List of ChildContentFolder objects
+ * @throws PropelException
+ */
+ public function getContentFolders($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collContentFoldersPartial && !$this->isNew();
+ if (null === $this->collContentFolders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentFolders) {
+ // return empty collection
+ $this->initContentFolders();
+ } else {
+ $collContentFolders = ChildContentFolderQuery::create(null, $criteria)
+ ->filterByFolder($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collContentFoldersPartial && count($collContentFolders)) {
+ $this->initContentFolders(false);
+
+ foreach ($collContentFolders as $obj) {
+ if (false == $this->collContentFolders->contains($obj)) {
+ $this->collContentFolders->append($obj);
+ }
+ }
+
+ $this->collContentFoldersPartial = true;
+ }
+
+ $collContentFolders->getInternalIterator()->rewind();
+
+ return $collContentFolders;
+ }
+
+ if ($partial && $this->collContentFolders) {
+ foreach ($this->collContentFolders as $obj) {
+ if ($obj->isNew()) {
+ $collContentFolders[] = $obj;
+ }
+ }
+ }
+
+ $this->collContentFolders = $collContentFolders;
+ $this->collContentFoldersPartial = false;
+ }
+ }
+
+ return $this->collContentFolders;
+ }
+
+ /**
+ * Sets a collection of ContentFolder objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $contentFolders A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function setContentFolders(Collection $contentFolders, ConnectionInterface $con = null)
+ {
+ $contentFoldersToDelete = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->contentFoldersScheduledForDeletion = clone $contentFoldersToDelete;
+
+ foreach ($contentFoldersToDelete as $contentFolderRemoved) {
+ $contentFolderRemoved->setFolder(null);
+ }
+
+ $this->collContentFolders = null;
+ foreach ($contentFolders as $contentFolder) {
+ $this->addContentFolder($contentFolder);
+ }
+
+ $this->collContentFolders = $contentFolders;
+ $this->collContentFoldersPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ContentFolder objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ContentFolder objects.
+ * @throws PropelException
+ */
+ public function countContentFolders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collContentFoldersPartial && !$this->isNew();
+ if (null === $this->collContentFolders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentFolders) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getContentFolders());
+ }
+
+ $query = ChildContentFolderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFolder($this)
+ ->count($con);
+ }
+
+ return count($this->collContentFolders);
+ }
+
+ /**
+ * Method called to associate a ChildContentFolder object to this object
+ * through the ChildContentFolder foreign key attribute.
+ *
+ * @param ChildContentFolder $l ChildContentFolder
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function addContentFolder(ChildContentFolder $l)
+ {
+ if ($this->collContentFolders === null) {
+ $this->initContentFolders();
+ $this->collContentFoldersPartial = true;
+ }
+
+ if (!in_array($l, $this->collContentFolders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddContentFolder($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ContentFolder $contentFolder The contentFolder object to add.
+ */
+ protected function doAddContentFolder($contentFolder)
+ {
+ $this->collContentFolders[]= $contentFolder;
+ $contentFolder->setFolder($this);
+ }
+
+ /**
+ * @param ContentFolder $contentFolder The contentFolder object to remove.
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function removeContentFolder($contentFolder)
+ {
+ if ($this->getContentFolders()->contains($contentFolder)) {
+ $this->collContentFolders->remove($this->collContentFolders->search($contentFolder));
+ if (null === $this->contentFoldersScheduledForDeletion) {
+ $this->contentFoldersScheduledForDeletion = clone $this->collContentFolders;
+ $this->contentFoldersScheduledForDeletion->clear();
+ }
+ $this->contentFoldersScheduledForDeletion[]= clone $contentFolder;
+ $contentFolder->setFolder(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Folder is new, it will return
+ * an empty collection; or if this Folder has previously
+ * been saved, it will retrieve related ContentFolders 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 Folder.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildContentFolder[] List of ChildContentFolder objects
+ */
+ public function getContentFoldersJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildContentFolderQuery::create(null, $criteria);
+ $query->joinWith('Content', $joinBehavior);
+
+ return $this->getContentFolders($query, $con);
+ }
+
+ /**
+ * Clears out the collFolderI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addFolderI18ns()
+ */
+ public function clearFolderI18ns()
+ {
+ $this->collFolderI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collFolderI18ns collection loaded partially.
+ */
+ public function resetPartialFolderI18ns($v = true)
+ {
+ $this->collFolderI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collFolderI18ns collection.
+ *
+ * By default this just sets the collFolderI18ns collection to an empty array (like clearcollFolderI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initFolderI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collFolderI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collFolderI18ns = new ObjectCollection();
+ $this->collFolderI18ns->setModel('\Thelia\Model\FolderI18n');
+ }
+
+ /**
+ * Gets an array of ChildFolderI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildFolder is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildFolderI18n[] List of ChildFolderI18n objects
+ * @throws PropelException
+ */
+ public function getFolderI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFolderI18nsPartial && !$this->isNew();
+ if (null === $this->collFolderI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFolderI18ns) {
+ // return empty collection
+ $this->initFolderI18ns();
+ } else {
+ $collFolderI18ns = ChildFolderI18nQuery::create(null, $criteria)
+ ->filterByFolder($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collFolderI18nsPartial && count($collFolderI18ns)) {
+ $this->initFolderI18ns(false);
+
+ foreach ($collFolderI18ns as $obj) {
+ if (false == $this->collFolderI18ns->contains($obj)) {
+ $this->collFolderI18ns->append($obj);
+ }
+ }
+
+ $this->collFolderI18nsPartial = true;
+ }
+
+ $collFolderI18ns->getInternalIterator()->rewind();
+
+ return $collFolderI18ns;
+ }
+
+ if ($partial && $this->collFolderI18ns) {
+ foreach ($this->collFolderI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collFolderI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collFolderI18ns = $collFolderI18ns;
+ $this->collFolderI18nsPartial = false;
+ }
+ }
+
+ return $this->collFolderI18ns;
+ }
+
+ /**
+ * Sets a collection of FolderI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $folderI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function setFolderI18ns(Collection $folderI18ns, ConnectionInterface $con = null)
+ {
+ $folderI18nsToDelete = $this->getFolderI18ns(new Criteria(), $con)->diff($folderI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->folderI18nsScheduledForDeletion = clone $folderI18nsToDelete;
+
+ foreach ($folderI18nsToDelete as $folderI18nRemoved) {
+ $folderI18nRemoved->setFolder(null);
+ }
+
+ $this->collFolderI18ns = null;
+ foreach ($folderI18ns as $folderI18n) {
+ $this->addFolderI18n($folderI18n);
+ }
+
+ $this->collFolderI18ns = $folderI18ns;
+ $this->collFolderI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related FolderI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related FolderI18n objects.
+ * @throws PropelException
+ */
+ public function countFolderI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFolderI18nsPartial && !$this->isNew();
+ if (null === $this->collFolderI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFolderI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getFolderI18ns());
+ }
+
+ $query = ChildFolderI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFolder($this)
+ ->count($con);
+ }
+
+ return count($this->collFolderI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildFolderI18n object to this object
+ * through the ChildFolderI18n foreign key attribute.
+ *
+ * @param ChildFolderI18n $l ChildFolderI18n
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function addFolderI18n(ChildFolderI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collFolderI18ns === null) {
+ $this->initFolderI18ns();
+ $this->collFolderI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collFolderI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddFolderI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param FolderI18n $folderI18n The folderI18n object to add.
+ */
+ protected function doAddFolderI18n($folderI18n)
+ {
+ $this->collFolderI18ns[]= $folderI18n;
+ $folderI18n->setFolder($this);
+ }
+
+ /**
+ * @param FolderI18n $folderI18n The folderI18n object to remove.
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function removeFolderI18n($folderI18n)
+ {
+ if ($this->getFolderI18ns()->contains($folderI18n)) {
+ $this->collFolderI18ns->remove($this->collFolderI18ns->search($folderI18n));
+ if (null === $this->folderI18nsScheduledForDeletion) {
+ $this->folderI18nsScheduledForDeletion = clone $this->collFolderI18ns;
+ $this->folderI18nsScheduledForDeletion->clear();
+ }
+ $this->folderI18nsScheduledForDeletion[]= clone $folderI18n;
+ $folderI18n->setFolder(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collFolderVersions collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addFolderVersions()
+ */
+ public function clearFolderVersions()
+ {
+ $this->collFolderVersions = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collFolderVersions collection loaded partially.
+ */
+ public function resetPartialFolderVersions($v = true)
+ {
+ $this->collFolderVersionsPartial = $v;
+ }
+
+ /**
+ * Initializes the collFolderVersions collection.
+ *
+ * By default this just sets the collFolderVersions collection to an empty array (like clearcollFolderVersions());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initFolderVersions($overrideExisting = true)
+ {
+ if (null !== $this->collFolderVersions && !$overrideExisting) {
+ return;
+ }
+ $this->collFolderVersions = new ObjectCollection();
+ $this->collFolderVersions->setModel('\Thelia\Model\FolderVersion');
+ }
+
+ /**
+ * Gets an array of ChildFolderVersion objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildFolder is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildFolderVersion[] List of ChildFolderVersion objects
+ * @throws PropelException
+ */
+ public function getFolderVersions($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFolderVersionsPartial && !$this->isNew();
+ if (null === $this->collFolderVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFolderVersions) {
+ // return empty collection
+ $this->initFolderVersions();
+ } else {
+ $collFolderVersions = ChildFolderVersionQuery::create(null, $criteria)
+ ->filterByFolder($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collFolderVersionsPartial && count($collFolderVersions)) {
+ $this->initFolderVersions(false);
+
+ foreach ($collFolderVersions as $obj) {
+ if (false == $this->collFolderVersions->contains($obj)) {
+ $this->collFolderVersions->append($obj);
+ }
+ }
+
+ $this->collFolderVersionsPartial = true;
+ }
+
+ $collFolderVersions->getInternalIterator()->rewind();
+
+ return $collFolderVersions;
+ }
+
+ if ($partial && $this->collFolderVersions) {
+ foreach ($this->collFolderVersions as $obj) {
+ if ($obj->isNew()) {
+ $collFolderVersions[] = $obj;
+ }
+ }
+ }
+
+ $this->collFolderVersions = $collFolderVersions;
+ $this->collFolderVersionsPartial = false;
+ }
+ }
+
+ return $this->collFolderVersions;
+ }
+
+ /**
+ * Sets a collection of FolderVersion objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $folderVersions A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function setFolderVersions(Collection $folderVersions, ConnectionInterface $con = null)
+ {
+ $folderVersionsToDelete = $this->getFolderVersions(new Criteria(), $con)->diff($folderVersions);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->folderVersionsScheduledForDeletion = clone $folderVersionsToDelete;
+
+ foreach ($folderVersionsToDelete as $folderVersionRemoved) {
+ $folderVersionRemoved->setFolder(null);
+ }
+
+ $this->collFolderVersions = null;
+ foreach ($folderVersions as $folderVersion) {
+ $this->addFolderVersion($folderVersion);
+ }
+
+ $this->collFolderVersions = $folderVersions;
+ $this->collFolderVersionsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related FolderVersion objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related FolderVersion objects.
+ * @throws PropelException
+ */
+ public function countFolderVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFolderVersionsPartial && !$this->isNew();
+ if (null === $this->collFolderVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFolderVersions) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getFolderVersions());
+ }
+
+ $query = ChildFolderVersionQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFolder($this)
+ ->count($con);
+ }
+
+ return count($this->collFolderVersions);
+ }
+
+ /**
+ * Method called to associate a ChildFolderVersion object to this object
+ * through the ChildFolderVersion foreign key attribute.
+ *
+ * @param ChildFolderVersion $l ChildFolderVersion
+ * @return \Thelia\Model\Folder The current object (for fluent API support)
+ */
+ public function addFolderVersion(ChildFolderVersion $l)
+ {
+ if ($this->collFolderVersions === null) {
+ $this->initFolderVersions();
+ $this->collFolderVersionsPartial = true;
+ }
+
+ if (!in_array($l, $this->collFolderVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddFolderVersion($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param FolderVersion $folderVersion The folderVersion object to add.
+ */
+ protected function doAddFolderVersion($folderVersion)
+ {
+ $this->collFolderVersions[]= $folderVersion;
+ $folderVersion->setFolder($this);
+ }
+
+ /**
+ * @param FolderVersion $folderVersion The folderVersion object to remove.
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function removeFolderVersion($folderVersion)
+ {
+ if ($this->getFolderVersions()->contains($folderVersion)) {
+ $this->collFolderVersions->remove($this->collFolderVersions->search($folderVersion));
+ if (null === $this->folderVersionsScheduledForDeletion) {
+ $this->folderVersionsScheduledForDeletion = clone $this->collFolderVersions;
+ $this->folderVersionsScheduledForDeletion->clear();
+ }
+ $this->folderVersionsScheduledForDeletion[]= clone $folderVersion;
+ $folderVersion->setFolder(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collContents collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addContents()
+ */
+ public function clearContents()
+ {
+ $this->collContents = null; // important to set this to NULL since that means it is uninitialized
+ $this->collContentsPartial = null;
+ }
+
+ /**
+ * Initializes the collContents collection.
+ *
+ * By default this just sets the collContents collection to an empty collection (like clearContents());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initContents()
+ {
+ $this->collContents = new ObjectCollection();
+ $this->collContents->setModel('\Thelia\Model\Content');
+ }
+
+ /**
+ * Gets a collection of ChildContent objects related by a many-to-many relationship
+ * to the current object by way of the content_folder cross-reference table.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildFolder is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return ObjectCollection|ChildContent[] List of ChildContent objects
+ */
+ public function getContents($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collContents || null !== $criteria) {
+ if ($this->isNew() && null === $this->collContents) {
+ // return empty collection
+ $this->initContents();
+ } else {
+ $collContents = ChildContentQuery::create(null, $criteria)
+ ->filterByFolder($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collContents;
+ }
+ $this->collContents = $collContents;
+ }
+ }
+
+ return $this->collContents;
+ }
+
+ /**
+ * Sets a collection of Content objects related by a many-to-many relationship
+ * to the current object by way of the content_folder cross-reference table.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $contents A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function setContents(Collection $contents, ConnectionInterface $con = null)
+ {
+ $this->clearContents();
+ $currentContents = $this->getContents();
+
+ $this->contentsScheduledForDeletion = $currentContents->diff($contents);
+
+ foreach ($contents as $content) {
+ if (!$currentContents->contains($content)) {
+ $this->doAddContent($content);
+ }
+ }
+
+ $this->collContents = $contents;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildContent objects related by a many-to-many relationship
+ * to the current object by way of the content_folder cross-reference table.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param boolean $distinct Set to true to force count distinct
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return int the number of related ChildContent objects
+ */
+ public function countContents($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collContents || null !== $criteria) {
+ if ($this->isNew() && null === $this->collContents) {
+ return 0;
+ } else {
+ $query = ChildContentQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByFolder($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collContents);
+ }
+ }
+
+ /**
+ * Associate a ChildContent object to this object
+ * through the content_folder cross reference table.
+ *
+ * @param ChildContent $content The ChildContentFolder object to relate
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function addContent(ChildContent $content)
+ {
+ if ($this->collContents === null) {
+ $this->initContents();
+ }
+
+ if (!$this->collContents->contains($content)) { // only add it if the **same** object is not already associated
+ $this->doAddContent($content);
+ $this->collContents[] = $content;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Content $content The content object to add.
+ */
+ protected function doAddContent($content)
+ {
+ $contentFolder = new ChildContentFolder();
+ $contentFolder->setContent($content);
+ $this->addContentFolder($contentFolder);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$content->getFolders()->contains($this)) {
+ $foreignCollection = $content->getFolders();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildContent object to this object
+ * through the content_folder cross reference table.
+ *
+ * @param ChildContent $content The ChildContentFolder object to relate
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function removeContent(ChildContent $content)
+ {
+ if ($this->getContents()->contains($content)) {
+ $this->collContents->remove($this->collContents->search($content));
+
+ if (null === $this->contentsScheduledForDeletion) {
+ $this->contentsScheduledForDeletion = clone $this->collContents;
+ $this->contentsScheduledForDeletion->clear();
+ }
+
+ $this->contentsScheduledForDeletion[] = $content;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->parent = null;
+ $this->link = null;
+ $this->visible = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collImages) {
+ foreach ($this->collImages as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collDocuments) {
+ foreach ($this->collDocuments as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collRewritings) {
+ foreach ($this->collRewritings as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collContentFolders) {
+ foreach ($this->collContentFolders as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collFolderI18ns) {
+ foreach ($this->collFolderI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collFolderVersions) {
+ foreach ($this->collFolderVersions as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collContents) {
+ foreach ($this->collContents as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collImages instanceof Collection) {
+ $this->collImages->clearIterator();
+ }
+ $this->collImages = null;
+ if ($this->collDocuments instanceof Collection) {
+ $this->collDocuments->clearIterator();
+ }
+ $this->collDocuments = null;
+ if ($this->collRewritings instanceof Collection) {
+ $this->collRewritings->clearIterator();
+ }
+ $this->collRewritings = null;
+ if ($this->collContentFolders instanceof Collection) {
+ $this->collContentFolders->clearIterator();
+ }
+ $this->collContentFolders = null;
+ if ($this->collFolderI18ns instanceof Collection) {
+ $this->collFolderI18ns->clearIterator();
+ }
+ $this->collFolderI18ns = null;
+ if ($this->collFolderVersions instanceof Collection) {
+ $this->collFolderVersions->clearIterator();
+ }
+ $this->collFolderVersions = null;
+ if ($this->collContents instanceof Collection) {
+ $this->collContents->clearIterator();
+ }
+ $this->collContents = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FolderTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = FolderTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFolderI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collFolderI18ns) {
+ foreach ($this->collFolderI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildFolderI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildFolderI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addFolderI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildFolderI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collFolderI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collFolderI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFolderI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FolderI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FolderI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FolderI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FolderI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ // versionable behavior
+
+ /**
+ * Enforce a new Version of this object upon next save.
+ *
+ * @return \Thelia\Model\Folder
+ */
+ public function enforceVersioning()
+ {
+ $this->enforceVersion = true;
+
+ return $this;
+ }
+
+ /**
+ * Checks whether the current state must be recorded as a version
+ *
+ * @return boolean
+ */
+ public function isVersioningNecessary($con = null)
+ {
+ if ($this->alreadyInSave) {
+ return false;
+ }
+
+ if ($this->enforceVersion) {
+ return true;
+ }
+
+ if (ChildFolderQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Creates a version of the current object and saves it.
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ChildFolderVersion A version object
+ */
+ public function addVersion($con = null)
+ {
+ $this->enforceVersion = false;
+
+ $version = new ChildFolderVersion();
+ $version->setId($this->getId());
+ $version->setParent($this->getParent());
+ $version->setLink($this->getLink());
+ $version->setVisible($this->getVisible());
+ $version->setPosition($this->getPosition());
+ $version->setCreatedAt($this->getCreatedAt());
+ $version->setUpdatedAt($this->getUpdatedAt());
+ $version->setVersion($this->getVersion());
+ $version->setVersionCreatedAt($this->getVersionCreatedAt());
+ $version->setVersionCreatedBy($this->getVersionCreatedBy());
+ $version->setFolder($this);
+ $version->save($con);
+
+ return $version;
+ }
+
+ /**
+ * Sets the properties of the current object to the value they had at a specific version
+ *
+ * @param integer $versionNumber The version number to read
+ * @param ConnectionInterface $con The connection to use
+ *
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function toVersion($versionNumber, $con = null)
+ {
+ $version = $this->getOneVersion($versionNumber, $con);
+ if (!$version) {
+ throw new PropelException(sprintf('No ChildFolder object found with version %d', $version));
+ }
+ $this->populateFromVersion($version, $con);
+
+ return $this;
+ }
+
+ /**
+ * Sets the properties of the current object to the value they had at a specific version
+ *
+ * @param ChildFolderVersion $version The version object to use
+ * @param ConnectionInterface $con the connection to use
+ * @param array $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects.
+ *
+ * @return ChildFolder The current object (for fluent API support)
+ */
+ public function populateFromVersion($version, $con = null, &$loadedObjects = array())
+ {
+ $loadedObjects['ChildFolder'][$version->getId()][$version->getVersion()] = $this;
+ $this->setId($version->getId());
+ $this->setParent($version->getParent());
+ $this->setLink($version->getLink());
+ $this->setVisible($version->getVisible());
+ $this->setPosition($version->getPosition());
+ $this->setCreatedAt($version->getCreatedAt());
+ $this->setUpdatedAt($version->getUpdatedAt());
+ $this->setVersion($version->getVersion());
+ $this->setVersionCreatedAt($version->getVersionCreatedAt());
+ $this->setVersionCreatedBy($version->getVersionCreatedBy());
+
+ return $this;
+ }
+
+ /**
+ * Gets the latest persisted version number for the current object
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return integer
+ */
+ public function getLastVersionNumber($con = null)
+ {
+ $v = ChildFolderVersionQuery::create()
+ ->filterByFolder($this)
+ ->orderByVersion('desc')
+ ->findOne($con);
+ if (!$v) {
+ return 0;
+ }
+
+ return $v->getVersion();
+ }
+
+ /**
+ * Checks whether the current object is the latest one
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return Boolean
+ */
+ public function isLastVersion($con = null)
+ {
+ return $this->getLastVersionNumber($con) == $this->getVersion();
+ }
+
+ /**
+ * Retrieves a version object for this entity and a version number
+ *
+ * @param integer $versionNumber The version number to read
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ChildFolderVersion A version object
+ */
+ public function getOneVersion($versionNumber, $con = null)
+ {
+ return ChildFolderVersionQuery::create()
+ ->filterByFolder($this)
+ ->filterByVersion($versionNumber)
+ ->findOne($con);
+ }
+
+ /**
+ * Gets all the versions of this object, in incremental order
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ObjectCollection A list of ChildFolderVersion objects
+ */
+ public function getAllVersions($con = null)
+ {
+ $criteria = new Criteria();
+ $criteria->addAscendingOrderByColumn(FolderVersionTableMap::VERSION);
+
+ return $this->getFolderVersions($criteria, $con);
+ }
+
+ /**
+ * Compares the current object with another of its version.
+ *
+ * print_r($book->compareVersion(1));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $versionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param ConnectionInterface $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->toArray();
+ $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Compares two versions of the current object.
+ *
+ * print_r($book->compareVersions(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $fromVersionNumber
+ * @param integer $toVersionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param ConnectionInterface $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
+ $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Computes the diff between two versions.
+ *
+ * print_r($book->computeDiff(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param array $fromVersion An array representing the original version.
+ * @param array $toVersion An array representing the destination version.
+ * @param string $keys Main key used for the result diff (versions|columns).
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
+ {
+ $fromVersionNumber = $fromVersion['Version'];
+ $toVersionNumber = $toVersion['Version'];
+ $ignoredColumns = array_merge(array(
+ 'Version',
+ 'VersionCreatedAt',
+ 'VersionCreatedBy',
+ ), $ignoredColumns);
+ $diff = array();
+ foreach ($fromVersion as $key => $value) {
+ if (in_array($key, $ignoredColumns)) {
+ continue;
+ }
+ if ($toVersion[$key] != $value) {
+ switch ($keys) {
+ case 'versions':
+ $diff[$fromVersionNumber][$key] = $value;
+ $diff[$toVersionNumber][$key] = $toVersion[$key];
+ break;
+ default:
+ $diff[$key] = array(
+ $fromVersionNumber => $value,
+ $toVersionNumber => $toVersion[$key],
+ );
+ break;
+ }
+ }
+ }
+
+ return $diff;
+ }
+ /**
+ * retrieve the last $number versions.
+ *
+ * @param Integer $number the number of record to return.
+ * @return PropelCollection|array \Thelia\Model\FolderVersion[] List of \Thelia\Model\FolderVersion objects
+ */
+ public function getLastVersions($number = 10, $criteria = null, $con = null)
+ {
+ $criteria = ChildFolderVersionQuery::create(null, $criteria);
+ $criteria->addDescendingOrderByColumn(FolderVersionTableMap::VERSION);
+ $criteria->limit($number);
+
+ return $this->getFolderVersions($criteria, $con);
+ }
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/FolderI18n.php b/core/lib/Thelia/Model/Base/FolderI18n.php
new file mode 100644
index 000000000..35e69d6a6
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FolderI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\FolderI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another FolderI18n instance. If
+ * obj is an instance of FolderI18n, delegates to
+ * equals(FolderI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return FolderI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return FolderI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FolderI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FolderI18nTableMap::ID;
+ }
+
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FolderI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = FolderI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FolderI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = FolderI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FolderI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = FolderI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FolderI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = FolderI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FolderI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = FolderI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FolderI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FolderI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FolderI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FolderI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FolderI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = FolderI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\FolderI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aFolder !== null && $this->id !== $this->aFolder->getId()) {
+ $this->aFolder = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FolderI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildFolderI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aFolder = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see FolderI18n::setDeleted()
+ * @see FolderI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildFolderI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FolderI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aFolder !== null) {
+ if ($this->aFolder->isModified() || $this->aFolder->isNew()) {
+ $affectedRows += $this->aFolder->save($con);
+ }
+ $this->setFolder($this->aFolder);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FolderI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(FolderI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(FolderI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(FolderI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(FolderI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(FolderI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO folder_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FolderI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['FolderI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['FolderI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = FolderI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FolderI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = FolderI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(FolderI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(FolderI18nTableMap::ID)) $criteria->add(FolderI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(FolderI18nTableMap::LOCALE)) $criteria->add(FolderI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(FolderI18nTableMap::TITLE)) $criteria->add(FolderI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(FolderI18nTableMap::DESCRIPTION)) $criteria->add(FolderI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(FolderI18nTableMap::CHAPO)) $criteria->add(FolderI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(FolderI18nTableMap::POSTSCRIPTUM)) $criteria->add(FolderI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(FolderI18nTableMap::DATABASE_NAME);
+ $criteria->add(FolderI18nTableMap::ID, $this->id);
+ $criteria->add(FolderI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\FolderI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\FolderI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildFolder object.
+ *
+ * @param ChildFolder $v
+ * @return \Thelia\Model\FolderI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFolder(ChildFolder $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aFolder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildFolder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFolderI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildFolder object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildFolder The associated ChildFolder object.
+ * @throws PropelException
+ */
+ public function getFolder(ConnectionInterface $con = null)
+ {
+ if ($this->aFolder === null && ($this->id !== null)) {
+ $this->aFolder = ChildFolderQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aFolder->addFolderI18ns($this);
+ */
+ }
+
+ return $this->aFolder;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aFolder = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FolderI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/FolderI18nQuery.php b/core/lib/Thelia/Model/Base/FolderI18nQuery.php
new file mode 100644
index 000000000..bc1e5adf4
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FolderI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFolderI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FolderI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FolderI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFolderI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM folder_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildFolderI18n();
+ $obj->hydrate($row);
+ FolderI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFolderI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildFolderI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(FolderI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(FolderI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildFolderI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(FolderI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(FolderI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByFolder()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(FolderI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(FolderI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Folder object
+ *
+ * @param \Thelia\Model\Folder|ObjectCollection $folder The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderI18nQuery The current query, for fluid interface
+ */
+ public function filterByFolder($folder, $comparison = null)
+ {
+ if ($folder instanceof \Thelia\Model\Folder) {
+ return $this
+ ->addUsingAlias(FolderI18nTableMap::ID, $folder->getId(), $comparison);
+ } elseif ($folder instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FolderI18nTableMap::ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Folder relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFolderI18nQuery The current query, for fluid interface
+ */
+ public function joinFolder($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Folder');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Folder');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Folder relation Folder object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query
+ */
+ public function useFolderQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinFolder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildFolderI18n $folderI18n Object to remove from the list of results
+ *
+ * @return ChildFolderI18nQuery The current query, for fluid interface
+ */
+ public function prune($folderI18n = null)
+ {
+ if ($folderI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(FolderI18nTableMap::ID), $folderI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(FolderI18nTableMap::LOCALE), $folderI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the folder_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ FolderI18nTableMap::clearInstancePool();
+ FolderI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildFolderI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildFolderI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderI18nTableMap::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->beginTransaction();
+
+
+ FolderI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ FolderI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // FolderI18nQuery
diff --git a/core/lib/Thelia/Model/Base/FolderQuery.php b/core/lib/Thelia/Model/Base/FolderQuery.php
new file mode 100644
index 000000000..f7d84819d
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FolderQuery.php
@@ -0,0 +1,1372 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFolder|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FolderTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FolderTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFolder A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, PARENT, LINK, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM folder WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildFolder();
+ $obj->hydrate($row);
+ FolderTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFolder|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(FolderTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(FolderTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(FolderTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(FolderTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the parent column
+ *
+ * Example usage:
+ *
+ * $query->filterByParent(1234); // WHERE parent = 1234
+ * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34)
+ * $query->filterByParent(array('min' => 12)); // WHERE parent > 12
+ *
+ *
+ * @param mixed $parent The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByParent($parent = null, $comparison = null)
+ {
+ if (is_array($parent)) {
+ $useMinMax = false;
+ if (isset($parent['min'])) {
+ $this->addUsingAlias(FolderTableMap::PARENT, $parent['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($parent['max'])) {
+ $this->addUsingAlias(FolderTableMap::PARENT, $parent['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderTableMap::PARENT, $parent, $comparison);
+ }
+
+ /**
+ * Filter the query on the link column
+ *
+ * Example usage:
+ *
+ * $query->filterByLink('fooValue'); // WHERE link = 'fooValue'
+ * $query->filterByLink('%fooValue%'); // WHERE link LIKE '%fooValue%'
+ *
+ *
+ * @param string $link The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByLink($link = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($link)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $link)) {
+ $link = str_replace('*', '%', $link);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderTableMap::LINK, $link, $comparison);
+ }
+
+ /**
+ * Filter the query on the visible column
+ *
+ * Example usage:
+ *
+ * $query->filterByVisible(1234); // WHERE visible = 1234
+ * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
+ * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
+ *
+ *
+ * @param mixed $visible The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByVisible($visible = null, $comparison = null)
+ {
+ if (is_array($visible)) {
+ $useMinMax = false;
+ if (isset($visible['min'])) {
+ $this->addUsingAlias(FolderTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(FolderTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderTableMap::VISIBLE, $visible, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(FolderTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(FolderTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(FolderTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(FolderTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(FolderTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(FolderTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(FolderTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(FolderTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderTableMap::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(FolderTableMap::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(FolderTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Image object
+ *
+ * @param \Thelia\Model\Image|ObjectCollection $image the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByImage($image, $comparison = null)
+ {
+ if ($image instanceof \Thelia\Model\Image) {
+ return $this
+ ->addUsingAlias(FolderTableMap::ID, $image->getFolderId(), $comparison);
+ } elseif ($image instanceof ObjectCollection) {
+ return $this
+ ->useImageQuery()
+ ->filterByPrimaryKeys($image->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Image relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Image');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Image');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Image relation Image object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
+ */
+ public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinImage($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Document object
+ *
+ * @param \Thelia\Model\Document|ObjectCollection $document the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByDocument($document, $comparison = null)
+ {
+ if ($document instanceof \Thelia\Model\Document) {
+ return $this
+ ->addUsingAlias(FolderTableMap::ID, $document->getFolderId(), $comparison);
+ } elseif ($document instanceof ObjectCollection) {
+ return $this
+ ->useDocumentQuery()
+ ->filterByPrimaryKeys($document->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Document relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Document');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Document');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Document relation Document object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query
+ */
+ public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinDocument($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Rewriting object
+ *
+ * @param \Thelia\Model\Rewriting|ObjectCollection $rewriting the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByRewriting($rewriting, $comparison = null)
+ {
+ if ($rewriting instanceof \Thelia\Model\Rewriting) {
+ return $this
+ ->addUsingAlias(FolderTableMap::ID, $rewriting->getFolderId(), $comparison);
+ } elseif ($rewriting instanceof ObjectCollection) {
+ return $this
+ ->useRewritingQuery()
+ ->filterByPrimaryKeys($rewriting->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByRewriting() only accepts arguments of type \Thelia\Model\Rewriting or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Rewriting relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Rewriting');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Rewriting');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Rewriting relation Rewriting object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query
+ */
+ public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinRewriting($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ContentFolder object
+ *
+ * @param \Thelia\Model\ContentFolder|ObjectCollection $contentFolder the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByContentFolder($contentFolder, $comparison = null)
+ {
+ if ($contentFolder instanceof \Thelia\Model\ContentFolder) {
+ return $this
+ ->addUsingAlias(FolderTableMap::ID, $contentFolder->getFolderId(), $comparison);
+ } elseif ($contentFolder instanceof ObjectCollection) {
+ return $this
+ ->useContentFolderQuery()
+ ->filterByPrimaryKeys($contentFolder->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByContentFolder() only accepts arguments of type \Thelia\Model\ContentFolder or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ContentFolder relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function joinContentFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ContentFolder');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ContentFolder');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ContentFolder relation ContentFolder object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentFolderQuery A secondary query class using the current class as primary query
+ */
+ public function useContentFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinContentFolder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentFolder', '\Thelia\Model\ContentFolderQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\FolderI18n object
+ *
+ * @param \Thelia\Model\FolderI18n|ObjectCollection $folderI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByFolderI18n($folderI18n, $comparison = null)
+ {
+ if ($folderI18n instanceof \Thelia\Model\FolderI18n) {
+ return $this
+ ->addUsingAlias(FolderTableMap::ID, $folderI18n->getId(), $comparison);
+ } elseif ($folderI18n instanceof ObjectCollection) {
+ return $this
+ ->useFolderI18nQuery()
+ ->filterByPrimaryKeys($folderI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFolderI18n() only accepts arguments of type \Thelia\Model\FolderI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FolderI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function joinFolderI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FolderI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FolderI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FolderI18n relation FolderI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FolderI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useFolderI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinFolderI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FolderI18n', '\Thelia\Model\FolderI18nQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\FolderVersion object
+ *
+ * @param \Thelia\Model\FolderVersion|ObjectCollection $folderVersion the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByFolderVersion($folderVersion, $comparison = null)
+ {
+ if ($folderVersion instanceof \Thelia\Model\FolderVersion) {
+ return $this
+ ->addUsingAlias(FolderTableMap::ID, $folderVersion->getId(), $comparison);
+ } elseif ($folderVersion instanceof ObjectCollection) {
+ return $this
+ ->useFolderVersionQuery()
+ ->filterByPrimaryKeys($folderVersion->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFolderVersion() only accepts arguments of type \Thelia\Model\FolderVersion or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FolderVersion relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function joinFolderVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FolderVersion');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FolderVersion');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FolderVersion relation FolderVersion object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FolderVersionQuery A secondary query class using the current class as primary query
+ */
+ public function useFolderVersionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFolderVersion($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FolderVersion', '\Thelia\Model\FolderVersionQuery');
+ }
+
+ /**
+ * Filter the query by a related Content object
+ * using the content_folder table as cross reference
+ *
+ * @param Content $content the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function filterByContent($content, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useContentFolderQuery()
+ ->filterByContent($content, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildFolder $folder Object to remove from the list of results
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function prune($folder = null)
+ {
+ if ($folder) {
+ $this->addUsingAlias(FolderTableMap::ID, $folder->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the folder table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ FolderTableMap::clearInstancePool();
+ FolderTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildFolder or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildFolder object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderTableMap::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->beginTransaction();
+
+
+ FolderTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ FolderTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(FolderTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(FolderTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(FolderTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(FolderTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(FolderTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(FolderTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'FolderI18n';
+
+ return $this
+ ->joinFolderI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildFolderQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('FolderI18n');
+ $this->with['FolderI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildFolderI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FolderI18n', '\Thelia\Model\FolderI18nQuery');
+ }
+
+ // versionable behavior
+
+ /**
+ * Checks whether versioning is enabled
+ *
+ * @return boolean
+ */
+ static public function isVersioningEnabled()
+ {
+ return self::$isVersioningEnabled;
+ }
+
+ /**
+ * Enables versioning
+ */
+ static public function enableVersioning()
+ {
+ self::$isVersioningEnabled = true;
+ }
+
+ /**
+ * Disables versioning
+ */
+ static public function disableVersioning()
+ {
+ self::$isVersioningEnabled = false;
+ }
+
+} // FolderQuery
diff --git a/core/lib/Thelia/Model/Base/FolderVersion.php b/core/lib/Thelia/Model/Base/FolderVersion.php
new file mode 100644
index 000000000..609d41d9d
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FolderVersion.php
@@ -0,0 +1,1709 @@
+version = 0;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\FolderVersion object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another FolderVersion instance. If
+ * obj is an instance of FolderVersion, delegates to
+ * equals(FolderVersion). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return FolderVersion The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return FolderVersion The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [parent] column value.
+ *
+ * @return int
+ */
+ public function getParent()
+ {
+
+ return $this->parent;
+ }
+
+ /**
+ * Get the [link] column value.
+ *
+ * @return string
+ */
+ public function getLink()
+ {
+
+ return $this->link;
+ }
+
+ /**
+ * Get the [visible] column value.
+ *
+ * @return int
+ */
+ public function getVisible()
+ {
+
+ return $this->visible;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getVersionCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->version_created_at;
+ } else {
+ return $this->version_created_at !== null ? $this->version_created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FolderVersion The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = FolderVersionTableMap::ID;
+ }
+
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [parent] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FolderVersion The current object (for fluent API support)
+ */
+ public function setParent($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->parent !== $v) {
+ $this->parent = $v;
+ $this->modifiedColumns[] = FolderVersionTableMap::PARENT;
+ }
+
+
+ return $this;
+ } // setParent()
+
+ /**
+ * Set the value of [link] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FolderVersion The current object (for fluent API support)
+ */
+ public function setLink($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->link !== $v) {
+ $this->link = $v;
+ $this->modifiedColumns[] = FolderVersionTableMap::LINK;
+ }
+
+
+ return $this;
+ } // setLink()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FolderVersion The current object (for fluent API support)
+ */
+ public function setVisible($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->visible !== $v) {
+ $this->visible = $v;
+ $this->modifiedColumns[] = FolderVersionTableMap::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FolderVersion The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = FolderVersionTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\FolderVersion The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = FolderVersionTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\FolderVersion The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = FolderVersionTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\FolderVersion The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = FolderVersionTableMap::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\FolderVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ if ($dt !== $this->version_created_at) {
+ $this->version_created_at = $dt;
+ $this->modifiedColumns[] = FolderVersionTableMap::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\FolderVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = FolderVersionTableMap::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->version !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FolderVersionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FolderVersionTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->parent = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FolderVersionTableMap::translateFieldName('Link', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->link = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FolderVersionTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->visible = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FolderVersionTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : FolderVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : FolderVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : FolderVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : FolderVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version_created_by = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 10; // 10 = FolderVersionTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\FolderVersion object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aFolder !== null && $this->id !== $this->aFolder->getId()) {
+ $this->aFolder = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FolderVersionTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildFolderVersionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aFolder = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see FolderVersion::setDeleted()
+ * @see FolderVersion::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderVersionTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildFolderVersionQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderVersionTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ FolderVersionTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aFolder !== null) {
+ if ($this->aFolder->isModified() || $this->aFolder->isNew()) {
+ $affectedRows += $this->aFolder->save($con);
+ }
+ $this->setFolder($this->aFolder);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(FolderVersionTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(FolderVersionTableMap::PARENT)) {
+ $modifiedColumns[':p' . $index++] = 'PARENT';
+ }
+ if ($this->isColumnModified(FolderVersionTableMap::LINK)) {
+ $modifiedColumns[':p' . $index++] = 'LINK';
+ }
+ if ($this->isColumnModified(FolderVersionTableMap::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = 'VISIBLE';
+ }
+ if ($this->isColumnModified(FolderVersionTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(FolderVersionTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(FolderVersionTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+ if ($this->isColumnModified(FolderVersionTableMap::VERSION)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION';
+ }
+ if ($this->isColumnModified(FolderVersionTableMap::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT';
+ }
+ if ($this->isColumnModified(FolderVersionTableMap::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO folder_version (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'PARENT':
+ $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT);
+ break;
+ case 'LINK':
+ $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR);
+ break;
+ case 'VISIBLE':
+ $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case 'VERSION_CREATED_AT':
+ $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION_CREATED_BY':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FolderVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getParent();
+ break;
+ case 2:
+ return $this->getLink();
+ break;
+ case 3:
+ return $this->getVisible();
+ break;
+ case 4:
+ return $this->getPosition();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ return $this->getUpdatedAt();
+ break;
+ case 7:
+ return $this->getVersion();
+ break;
+ case 8:
+ return $this->getVersionCreatedAt();
+ break;
+ case 9:
+ return $this->getVersionCreatedBy();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['FolderVersion'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['FolderVersion'][serialize($this->getPrimaryKey())] = true;
+ $keys = FolderVersionTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getParent(),
+ $keys[2] => $this->getLink(),
+ $keys[3] => $this->getVisible(),
+ $keys[4] => $this->getPosition(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ $keys[7] => $this->getVersion(),
+ $keys[8] => $this->getVersionCreatedAt(),
+ $keys[9] => $this->getVersionCreatedBy(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = FolderVersionTableMap::translateFieldName($name, $type, TableMap::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->setParent($value);
+ break;
+ case 2:
+ $this->setLink($value);
+ break;
+ case 3:
+ $this->setVisible($value);
+ break;
+ case 4:
+ $this->setPosition($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $this->setUpdatedAt($value);
+ break;
+ case 7:
+ $this->setVersion($value);
+ break;
+ case 8:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 9:
+ $this->setVersionCreatedBy($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = FolderVersionTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersion($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedAt($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setVersionCreatedBy($arr[$keys[9]]);
+ }
+
+ /**
+ * 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(FolderVersionTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(FolderVersionTableMap::ID)) $criteria->add(FolderVersionTableMap::ID, $this->id);
+ if ($this->isColumnModified(FolderVersionTableMap::PARENT)) $criteria->add(FolderVersionTableMap::PARENT, $this->parent);
+ if ($this->isColumnModified(FolderVersionTableMap::LINK)) $criteria->add(FolderVersionTableMap::LINK, $this->link);
+ if ($this->isColumnModified(FolderVersionTableMap::VISIBLE)) $criteria->add(FolderVersionTableMap::VISIBLE, $this->visible);
+ if ($this->isColumnModified(FolderVersionTableMap::POSITION)) $criteria->add(FolderVersionTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(FolderVersionTableMap::CREATED_AT)) $criteria->add(FolderVersionTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(FolderVersionTableMap::UPDATED_AT)) $criteria->add(FolderVersionTableMap::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(FolderVersionTableMap::VERSION)) $criteria->add(FolderVersionTableMap::VERSION, $this->version);
+ if ($this->isColumnModified(FolderVersionTableMap::VERSION_CREATED_AT)) $criteria->add(FolderVersionTableMap::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(FolderVersionTableMap::VERSION_CREATED_BY)) $criteria->add(FolderVersionTableMap::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(FolderVersionTableMap::DATABASE_NAME);
+ $criteria->add(FolderVersionTableMap::ID, $this->id);
+ $criteria->add(FolderVersionTableMap::VERSION, $this->version);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getVersion();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setVersion($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getVersion());
+ }
+
+ /**
+ * 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 \Thelia\Model\FolderVersion (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setParent($this->getParent());
+ $copyObj->setLink($this->getLink());
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\FolderVersion 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildFolder object.
+ *
+ * @param ChildFolder $v
+ * @return \Thelia\Model\FolderVersion The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFolder(ChildFolder $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aFolder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildFolder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addFolderVersion($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildFolder object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildFolder The associated ChildFolder object.
+ * @throws PropelException
+ */
+ public function getFolder(ConnectionInterface $con = null)
+ {
+ if ($this->aFolder === null && ($this->id !== null)) {
+ $this->aFolder = ChildFolderQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aFolder->addFolderVersions($this);
+ */
+ }
+
+ return $this->aFolder;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->parent = null;
+ $this->link = null;
+ $this->visible = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aFolder = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(FolderVersionTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/FolderVersionQuery.php b/core/lib/Thelia/Model/Base/FolderVersionQuery.php
new file mode 100644
index 000000000..8cf9ac440
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/FolderVersionQuery.php
@@ -0,0 +1,829 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $version] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildFolderVersion|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = FolderVersionTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(FolderVersionTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFolderVersion A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, PARENT, LINK, VISIBLE, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM folder_version WHERE ID = :p0 AND VERSION = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildFolderVersion();
+ $obj->hydrate($row);
+ FolderVersionTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildFolderVersion|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(FolderVersionTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(FolderVersionTableMap::VERSION, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(FolderVersionTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(FolderVersionTableMap::VERSION, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByFolder()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(FolderVersionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(FolderVersionTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the parent column
+ *
+ * Example usage:
+ *
+ * $query->filterByParent(1234); // WHERE parent = 1234
+ * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34)
+ * $query->filterByParent(array('min' => 12)); // WHERE parent > 12
+ *
+ *
+ * @param mixed $parent The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByParent($parent = null, $comparison = null)
+ {
+ if (is_array($parent)) {
+ $useMinMax = false;
+ if (isset($parent['min'])) {
+ $this->addUsingAlias(FolderVersionTableMap::PARENT, $parent['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($parent['max'])) {
+ $this->addUsingAlias(FolderVersionTableMap::PARENT, $parent['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionTableMap::PARENT, $parent, $comparison);
+ }
+
+ /**
+ * Filter the query on the link column
+ *
+ * Example usage:
+ *
+ * $query->filterByLink('fooValue'); // WHERE link = 'fooValue'
+ * $query->filterByLink('%fooValue%'); // WHERE link LIKE '%fooValue%'
+ *
+ *
+ * @param string $link The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByLink($link = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($link)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $link)) {
+ $link = str_replace('*', '%', $link);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionTableMap::LINK, $link, $comparison);
+ }
+
+ /**
+ * Filter the query on the visible column
+ *
+ * Example usage:
+ *
+ * $query->filterByVisible(1234); // WHERE visible = 1234
+ * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
+ * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
+ *
+ *
+ * @param mixed $visible The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByVisible($visible = null, $comparison = null)
+ {
+ if (is_array($visible)) {
+ $useMinMax = false;
+ if (isset($visible['min'])) {
+ $this->addUsingAlias(FolderVersionTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(FolderVersionTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionTableMap::VISIBLE, $visible, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(FolderVersionTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(FolderVersionTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(FolderVersionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(FolderVersionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(FolderVersionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(FolderVersionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(FolderVersionTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(FolderVersionTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionTableMap::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(FolderVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(FolderVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(FolderVersionTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Folder object
+ *
+ * @param \Thelia\Model\Folder|ObjectCollection $folder The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function filterByFolder($folder, $comparison = null)
+ {
+ if ($folder instanceof \Thelia\Model\Folder) {
+ return $this
+ ->addUsingAlias(FolderVersionTableMap::ID, $folder->getId(), $comparison);
+ } elseif ($folder instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(FolderVersionTableMap::ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Folder relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function joinFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Folder');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Folder');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Folder relation Folder object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query
+ */
+ public function useFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFolder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildFolderVersion $folderVersion Object to remove from the list of results
+ *
+ * @return ChildFolderVersionQuery The current query, for fluid interface
+ */
+ public function prune($folderVersion = null)
+ {
+ if ($folderVersion) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(FolderVersionTableMap::ID), $folderVersion->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(FolderVersionTableMap::VERSION), $folderVersion->getVersion(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the folder_version table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderVersionTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ FolderVersionTableMap::clearInstancePool();
+ FolderVersionTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildFolderVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildFolderVersion object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderVersionTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(FolderVersionTableMap::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->beginTransaction();
+
+
+ FolderVersionTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ FolderVersionTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // FolderVersionQuery
diff --git a/core/lib/Thelia/Model/Base/Group.php b/core/lib/Thelia/Model/Base/Group.php
new file mode 100644
index 000000000..6b66d5f39
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Group.php
@@ -0,0 +1,3155 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Group instance. If
+ * obj is an instance of Group, delegates to
+ * equals(Group). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Group The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Group The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Group The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = GroupTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Group The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = GroupTableMap::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Group The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = GroupTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Group The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = GroupTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : GroupTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : GroupTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->code = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : GroupTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : GroupTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = GroupTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Group object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(GroupTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildGroupQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collAdminGroups = null;
+
+ $this->collGroupResources = null;
+
+ $this->collGroupModules = null;
+
+ $this->collGroupI18ns = null;
+
+ $this->collAdmins = null;
+ $this->collResources = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Group::setDeleted()
+ * @see Group::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildGroupQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(GroupTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(GroupTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(GroupTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ GroupTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->adminsScheduledForDeletion !== null) {
+ if (!$this->adminsScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->adminsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($pk, $remotePk);
+ }
+
+ AdminGroupQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->adminsScheduledForDeletion = null;
+ }
+
+ foreach ($this->getAdmins() as $admin) {
+ if ($admin->isModified()) {
+ $admin->save($con);
+ }
+ }
+ } elseif ($this->collAdmins) {
+ foreach ($this->collAdmins as $admin) {
+ if ($admin->isModified()) {
+ $admin->save($con);
+ }
+ }
+ }
+
+ if ($this->resourcesScheduledForDeletion !== null) {
+ if (!$this->resourcesScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->resourcesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($pk, $remotePk);
+ }
+
+ GroupResourceQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->resourcesScheduledForDeletion = null;
+ }
+
+ foreach ($this->getResources() as $resource) {
+ if ($resource->isModified()) {
+ $resource->save($con);
+ }
+ }
+ } elseif ($this->collResources) {
+ foreach ($this->collResources as $resource) {
+ if ($resource->isModified()) {
+ $resource->save($con);
+ }
+ }
+ }
+
+ if ($this->adminGroupsScheduledForDeletion !== null) {
+ if (!$this->adminGroupsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\AdminGroupQuery::create()
+ ->filterByPrimaryKeys($this->adminGroupsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->adminGroupsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAdminGroups !== null) {
+ foreach ($this->collAdminGroups as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->groupResourcesScheduledForDeletion !== null) {
+ if (!$this->groupResourcesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\GroupResourceQuery::create()
+ ->filterByPrimaryKeys($this->groupResourcesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->groupResourcesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collGroupResources !== null) {
+ foreach ($this->collGroupResources as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->groupModulesScheduledForDeletion !== null) {
+ if (!$this->groupModulesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\GroupModuleQuery::create()
+ ->filterByPrimaryKeys($this->groupModulesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->groupModulesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collGroupModules !== null) {
+ foreach ($this->collGroupModules as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->groupI18nsScheduledForDeletion !== null) {
+ if (!$this->groupI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\GroupI18nQuery::create()
+ ->filterByPrimaryKeys($this->groupI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->groupI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collGroupI18ns !== null) {
+ foreach ($this->collGroupI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = GroupTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(GroupTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(GroupTableMap::CODE)) {
+ $modifiedColumns[':p' . $index++] = 'CODE';
+ }
+ if ($this->isColumnModified(GroupTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(GroupTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO group (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'CODE':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = GroupTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getCode();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Group'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Group'][$this->getPrimaryKey()] = true;
+ $keys = GroupTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collAdminGroups) {
+ $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collGroupResources) {
+ $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collGroupModules) {
+ $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collGroupI18ns) {
+ $result['GroupI18ns'] = $this->collGroupI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = GroupTableMap::translateFieldName($name, $type, TableMap::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->setCode($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = GroupTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * 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(GroupTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(GroupTableMap::ID)) $criteria->add(GroupTableMap::ID, $this->id);
+ if ($this->isColumnModified(GroupTableMap::CODE)) $criteria->add(GroupTableMap::CODE, $this->code);
+ if ($this->isColumnModified(GroupTableMap::CREATED_AT)) $criteria->add(GroupTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(GroupTableMap::UPDATED_AT)) $criteria->add(GroupTableMap::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(GroupTableMap::DATABASE_NAME);
+ $criteria->add(GroupTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Group (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getAdminGroups() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAdminGroup($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getGroupResources() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addGroupResource($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getGroupModules() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addGroupModule($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getGroupI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addGroupI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Group 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('AdminGroup' == $relationName) {
+ return $this->initAdminGroups();
+ }
+ if ('GroupResource' == $relationName) {
+ return $this->initGroupResources();
+ }
+ if ('GroupModule' == $relationName) {
+ return $this->initGroupModules();
+ }
+ if ('GroupI18n' == $relationName) {
+ return $this->initGroupI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collAdminGroups collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAdminGroups()
+ */
+ public function clearAdminGroups()
+ {
+ $this->collAdminGroups = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collAdminGroups collection loaded partially.
+ */
+ public function resetPartialAdminGroups($v = true)
+ {
+ $this->collAdminGroupsPartial = $v;
+ }
+
+ /**
+ * Initializes the collAdminGroups collection.
+ *
+ * By default this just sets the collAdminGroups collection to an empty array (like clearcollAdminGroups());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAdminGroups($overrideExisting = true)
+ {
+ if (null !== $this->collAdminGroups && !$overrideExisting) {
+ return;
+ }
+ $this->collAdminGroups = new ObjectCollection();
+ $this->collAdminGroups->setModel('\Thelia\Model\AdminGroup');
+ }
+
+ /**
+ * Gets an array of ChildAdminGroup objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildGroup is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildAdminGroup[] List of ChildAdminGroup objects
+ * @throws PropelException
+ */
+ public function getAdminGroups($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAdminGroupsPartial && !$this->isNew();
+ if (null === $this->collAdminGroups || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAdminGroups) {
+ // return empty collection
+ $this->initAdminGroups();
+ } else {
+ $collAdminGroups = ChildAdminGroupQuery::create(null, $criteria)
+ ->filterByGroup($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collAdminGroupsPartial && count($collAdminGroups)) {
+ $this->initAdminGroups(false);
+
+ foreach ($collAdminGroups as $obj) {
+ if (false == $this->collAdminGroups->contains($obj)) {
+ $this->collAdminGroups->append($obj);
+ }
+ }
+
+ $this->collAdminGroupsPartial = true;
+ }
+
+ $collAdminGroups->getInternalIterator()->rewind();
+
+ return $collAdminGroups;
+ }
+
+ if ($partial && $this->collAdminGroups) {
+ foreach ($this->collAdminGroups as $obj) {
+ if ($obj->isNew()) {
+ $collAdminGroups[] = $obj;
+ }
+ }
+ }
+
+ $this->collAdminGroups = $collAdminGroups;
+ $this->collAdminGroupsPartial = false;
+ }
+ }
+
+ return $this->collAdminGroups;
+ }
+
+ /**
+ * Sets a collection of AdminGroup objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $adminGroups A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function setAdminGroups(Collection $adminGroups, ConnectionInterface $con = null)
+ {
+ $adminGroupsToDelete = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->adminGroupsScheduledForDeletion = clone $adminGroupsToDelete;
+
+ foreach ($adminGroupsToDelete as $adminGroupRemoved) {
+ $adminGroupRemoved->setGroup(null);
+ }
+
+ $this->collAdminGroups = null;
+ foreach ($adminGroups as $adminGroup) {
+ $this->addAdminGroup($adminGroup);
+ }
+
+ $this->collAdminGroups = $adminGroups;
+ $this->collAdminGroupsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related AdminGroup objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related AdminGroup objects.
+ * @throws PropelException
+ */
+ public function countAdminGroups(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAdminGroupsPartial && !$this->isNew();
+ if (null === $this->collAdminGroups || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAdminGroups) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getAdminGroups());
+ }
+
+ $query = ChildAdminGroupQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByGroup($this)
+ ->count($con);
+ }
+
+ return count($this->collAdminGroups);
+ }
+
+ /**
+ * Method called to associate a ChildAdminGroup object to this object
+ * through the ChildAdminGroup foreign key attribute.
+ *
+ * @param ChildAdminGroup $l ChildAdminGroup
+ * @return \Thelia\Model\Group The current object (for fluent API support)
+ */
+ public function addAdminGroup(ChildAdminGroup $l)
+ {
+ if ($this->collAdminGroups === null) {
+ $this->initAdminGroups();
+ $this->collAdminGroupsPartial = true;
+ }
+
+ if (!in_array($l, $this->collAdminGroups->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddAdminGroup($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AdminGroup $adminGroup The adminGroup object to add.
+ */
+ protected function doAddAdminGroup($adminGroup)
+ {
+ $this->collAdminGroups[]= $adminGroup;
+ $adminGroup->setGroup($this);
+ }
+
+ /**
+ * @param AdminGroup $adminGroup The adminGroup object to remove.
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function removeAdminGroup($adminGroup)
+ {
+ if ($this->getAdminGroups()->contains($adminGroup)) {
+ $this->collAdminGroups->remove($this->collAdminGroups->search($adminGroup));
+ if (null === $this->adminGroupsScheduledForDeletion) {
+ $this->adminGroupsScheduledForDeletion = clone $this->collAdminGroups;
+ $this->adminGroupsScheduledForDeletion->clear();
+ }
+ $this->adminGroupsScheduledForDeletion[]= clone $adminGroup;
+ $adminGroup->setGroup(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Group is new, it will return
+ * an empty collection; or if this Group has previously
+ * been saved, it will retrieve related AdminGroups 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 Group.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildAdminGroup[] List of ChildAdminGroup objects
+ */
+ public function getAdminGroupsJoinAdmin($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildAdminGroupQuery::create(null, $criteria);
+ $query->joinWith('Admin', $joinBehavior);
+
+ return $this->getAdminGroups($query, $con);
+ }
+
+ /**
+ * Clears out the collGroupResources collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addGroupResources()
+ */
+ public function clearGroupResources()
+ {
+ $this->collGroupResources = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collGroupResources collection loaded partially.
+ */
+ public function resetPartialGroupResources($v = true)
+ {
+ $this->collGroupResourcesPartial = $v;
+ }
+
+ /**
+ * Initializes the collGroupResources collection.
+ *
+ * By default this just sets the collGroupResources collection to an empty array (like clearcollGroupResources());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initGroupResources($overrideExisting = true)
+ {
+ if (null !== $this->collGroupResources && !$overrideExisting) {
+ return;
+ }
+ $this->collGroupResources = new ObjectCollection();
+ $this->collGroupResources->setModel('\Thelia\Model\GroupResource');
+ }
+
+ /**
+ * Gets an array of ChildGroupResource objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildGroup is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildGroupResource[] List of ChildGroupResource objects
+ * @throws PropelException
+ */
+ public function getGroupResources($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collGroupResourcesPartial && !$this->isNew();
+ if (null === $this->collGroupResources || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupResources) {
+ // return empty collection
+ $this->initGroupResources();
+ } else {
+ $collGroupResources = ChildGroupResourceQuery::create(null, $criteria)
+ ->filterByGroup($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collGroupResourcesPartial && count($collGroupResources)) {
+ $this->initGroupResources(false);
+
+ foreach ($collGroupResources as $obj) {
+ if (false == $this->collGroupResources->contains($obj)) {
+ $this->collGroupResources->append($obj);
+ }
+ }
+
+ $this->collGroupResourcesPartial = true;
+ }
+
+ $collGroupResources->getInternalIterator()->rewind();
+
+ return $collGroupResources;
+ }
+
+ if ($partial && $this->collGroupResources) {
+ foreach ($this->collGroupResources as $obj) {
+ if ($obj->isNew()) {
+ $collGroupResources[] = $obj;
+ }
+ }
+ }
+
+ $this->collGroupResources = $collGroupResources;
+ $this->collGroupResourcesPartial = false;
+ }
+ }
+
+ return $this->collGroupResources;
+ }
+
+ /**
+ * Sets a collection of GroupResource objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $groupResources A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function setGroupResources(Collection $groupResources, ConnectionInterface $con = null)
+ {
+ $groupResourcesToDelete = $this->getGroupResources(new Criteria(), $con)->diff($groupResources);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->groupResourcesScheduledForDeletion = clone $groupResourcesToDelete;
+
+ foreach ($groupResourcesToDelete as $groupResourceRemoved) {
+ $groupResourceRemoved->setGroup(null);
+ }
+
+ $this->collGroupResources = null;
+ foreach ($groupResources as $groupResource) {
+ $this->addGroupResource($groupResource);
+ }
+
+ $this->collGroupResources = $groupResources;
+ $this->collGroupResourcesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related GroupResource objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related GroupResource objects.
+ * @throws PropelException
+ */
+ public function countGroupResources(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collGroupResourcesPartial && !$this->isNew();
+ if (null === $this->collGroupResources || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupResources) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getGroupResources());
+ }
+
+ $query = ChildGroupResourceQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByGroup($this)
+ ->count($con);
+ }
+
+ return count($this->collGroupResources);
+ }
+
+ /**
+ * Method called to associate a ChildGroupResource object to this object
+ * through the ChildGroupResource foreign key attribute.
+ *
+ * @param ChildGroupResource $l ChildGroupResource
+ * @return \Thelia\Model\Group The current object (for fluent API support)
+ */
+ public function addGroupResource(ChildGroupResource $l)
+ {
+ if ($this->collGroupResources === null) {
+ $this->initGroupResources();
+ $this->collGroupResourcesPartial = true;
+ }
+
+ if (!in_array($l, $this->collGroupResources->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddGroupResource($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param GroupResource $groupResource The groupResource object to add.
+ */
+ protected function doAddGroupResource($groupResource)
+ {
+ $this->collGroupResources[]= $groupResource;
+ $groupResource->setGroup($this);
+ }
+
+ /**
+ * @param GroupResource $groupResource The groupResource object to remove.
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function removeGroupResource($groupResource)
+ {
+ if ($this->getGroupResources()->contains($groupResource)) {
+ $this->collGroupResources->remove($this->collGroupResources->search($groupResource));
+ if (null === $this->groupResourcesScheduledForDeletion) {
+ $this->groupResourcesScheduledForDeletion = clone $this->collGroupResources;
+ $this->groupResourcesScheduledForDeletion->clear();
+ }
+ $this->groupResourcesScheduledForDeletion[]= clone $groupResource;
+ $groupResource->setGroup(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Group is new, it will return
+ * an empty collection; or if this Group has previously
+ * been saved, it will retrieve related GroupResources 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 Group.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildGroupResource[] List of ChildGroupResource objects
+ */
+ public function getGroupResourcesJoinResource($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildGroupResourceQuery::create(null, $criteria);
+ $query->joinWith('Resource', $joinBehavior);
+
+ return $this->getGroupResources($query, $con);
+ }
+
+ /**
+ * Clears out the collGroupModules collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addGroupModules()
+ */
+ public function clearGroupModules()
+ {
+ $this->collGroupModules = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collGroupModules collection loaded partially.
+ */
+ public function resetPartialGroupModules($v = true)
+ {
+ $this->collGroupModulesPartial = $v;
+ }
+
+ /**
+ * Initializes the collGroupModules collection.
+ *
+ * By default this just sets the collGroupModules collection to an empty array (like clearcollGroupModules());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initGroupModules($overrideExisting = true)
+ {
+ if (null !== $this->collGroupModules && !$overrideExisting) {
+ return;
+ }
+ $this->collGroupModules = new ObjectCollection();
+ $this->collGroupModules->setModel('\Thelia\Model\GroupModule');
+ }
+
+ /**
+ * Gets an array of ChildGroupModule objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildGroup is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildGroupModule[] List of ChildGroupModule objects
+ * @throws PropelException
+ */
+ public function getGroupModules($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collGroupModulesPartial && !$this->isNew();
+ if (null === $this->collGroupModules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupModules) {
+ // return empty collection
+ $this->initGroupModules();
+ } else {
+ $collGroupModules = ChildGroupModuleQuery::create(null, $criteria)
+ ->filterByGroup($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collGroupModulesPartial && count($collGroupModules)) {
+ $this->initGroupModules(false);
+
+ foreach ($collGroupModules as $obj) {
+ if (false == $this->collGroupModules->contains($obj)) {
+ $this->collGroupModules->append($obj);
+ }
+ }
+
+ $this->collGroupModulesPartial = true;
+ }
+
+ $collGroupModules->getInternalIterator()->rewind();
+
+ return $collGroupModules;
+ }
+
+ if ($partial && $this->collGroupModules) {
+ foreach ($this->collGroupModules as $obj) {
+ if ($obj->isNew()) {
+ $collGroupModules[] = $obj;
+ }
+ }
+ }
+
+ $this->collGroupModules = $collGroupModules;
+ $this->collGroupModulesPartial = false;
+ }
+ }
+
+ return $this->collGroupModules;
+ }
+
+ /**
+ * Sets a collection of GroupModule objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $groupModules A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function setGroupModules(Collection $groupModules, ConnectionInterface $con = null)
+ {
+ $groupModulesToDelete = $this->getGroupModules(new Criteria(), $con)->diff($groupModules);
+
+
+ $this->groupModulesScheduledForDeletion = $groupModulesToDelete;
+
+ foreach ($groupModulesToDelete as $groupModuleRemoved) {
+ $groupModuleRemoved->setGroup(null);
+ }
+
+ $this->collGroupModules = null;
+ foreach ($groupModules as $groupModule) {
+ $this->addGroupModule($groupModule);
+ }
+
+ $this->collGroupModules = $groupModules;
+ $this->collGroupModulesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related GroupModule objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related GroupModule objects.
+ * @throws PropelException
+ */
+ public function countGroupModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collGroupModulesPartial && !$this->isNew();
+ if (null === $this->collGroupModules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupModules) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getGroupModules());
+ }
+
+ $query = ChildGroupModuleQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByGroup($this)
+ ->count($con);
+ }
+
+ return count($this->collGroupModules);
+ }
+
+ /**
+ * Method called to associate a ChildGroupModule object to this object
+ * through the ChildGroupModule foreign key attribute.
+ *
+ * @param ChildGroupModule $l ChildGroupModule
+ * @return \Thelia\Model\Group The current object (for fluent API support)
+ */
+ public function addGroupModule(ChildGroupModule $l)
+ {
+ if ($this->collGroupModules === null) {
+ $this->initGroupModules();
+ $this->collGroupModulesPartial = true;
+ }
+
+ if (!in_array($l, $this->collGroupModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddGroupModule($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param GroupModule $groupModule The groupModule object to add.
+ */
+ protected function doAddGroupModule($groupModule)
+ {
+ $this->collGroupModules[]= $groupModule;
+ $groupModule->setGroup($this);
+ }
+
+ /**
+ * @param GroupModule $groupModule The groupModule object to remove.
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function removeGroupModule($groupModule)
+ {
+ if ($this->getGroupModules()->contains($groupModule)) {
+ $this->collGroupModules->remove($this->collGroupModules->search($groupModule));
+ if (null === $this->groupModulesScheduledForDeletion) {
+ $this->groupModulesScheduledForDeletion = clone $this->collGroupModules;
+ $this->groupModulesScheduledForDeletion->clear();
+ }
+ $this->groupModulesScheduledForDeletion[]= clone $groupModule;
+ $groupModule->setGroup(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Group is new, it will return
+ * an empty collection; or if this Group has previously
+ * been saved, it will retrieve related GroupModules 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 Group.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildGroupModule[] List of ChildGroupModule objects
+ */
+ public function getGroupModulesJoinModule($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildGroupModuleQuery::create(null, $criteria);
+ $query->joinWith('Module', $joinBehavior);
+
+ return $this->getGroupModules($query, $con);
+ }
+
+ /**
+ * Clears out the collGroupI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addGroupI18ns()
+ */
+ public function clearGroupI18ns()
+ {
+ $this->collGroupI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collGroupI18ns collection loaded partially.
+ */
+ public function resetPartialGroupI18ns($v = true)
+ {
+ $this->collGroupI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collGroupI18ns collection.
+ *
+ * By default this just sets the collGroupI18ns collection to an empty array (like clearcollGroupI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initGroupI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collGroupI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collGroupI18ns = new ObjectCollection();
+ $this->collGroupI18ns->setModel('\Thelia\Model\GroupI18n');
+ }
+
+ /**
+ * Gets an array of ChildGroupI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildGroup is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildGroupI18n[] List of ChildGroupI18n objects
+ * @throws PropelException
+ */
+ public function getGroupI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collGroupI18nsPartial && !$this->isNew();
+ if (null === $this->collGroupI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupI18ns) {
+ // return empty collection
+ $this->initGroupI18ns();
+ } else {
+ $collGroupI18ns = ChildGroupI18nQuery::create(null, $criteria)
+ ->filterByGroup($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collGroupI18nsPartial && count($collGroupI18ns)) {
+ $this->initGroupI18ns(false);
+
+ foreach ($collGroupI18ns as $obj) {
+ if (false == $this->collGroupI18ns->contains($obj)) {
+ $this->collGroupI18ns->append($obj);
+ }
+ }
+
+ $this->collGroupI18nsPartial = true;
+ }
+
+ $collGroupI18ns->getInternalIterator()->rewind();
+
+ return $collGroupI18ns;
+ }
+
+ if ($partial && $this->collGroupI18ns) {
+ foreach ($this->collGroupI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collGroupI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collGroupI18ns = $collGroupI18ns;
+ $this->collGroupI18nsPartial = false;
+ }
+ }
+
+ return $this->collGroupI18ns;
+ }
+
+ /**
+ * Sets a collection of GroupI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $groupI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function setGroupI18ns(Collection $groupI18ns, ConnectionInterface $con = null)
+ {
+ $groupI18nsToDelete = $this->getGroupI18ns(new Criteria(), $con)->diff($groupI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->groupI18nsScheduledForDeletion = clone $groupI18nsToDelete;
+
+ foreach ($groupI18nsToDelete as $groupI18nRemoved) {
+ $groupI18nRemoved->setGroup(null);
+ }
+
+ $this->collGroupI18ns = null;
+ foreach ($groupI18ns as $groupI18n) {
+ $this->addGroupI18n($groupI18n);
+ }
+
+ $this->collGroupI18ns = $groupI18ns;
+ $this->collGroupI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related GroupI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related GroupI18n objects.
+ * @throws PropelException
+ */
+ public function countGroupI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collGroupI18nsPartial && !$this->isNew();
+ if (null === $this->collGroupI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getGroupI18ns());
+ }
+
+ $query = ChildGroupI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByGroup($this)
+ ->count($con);
+ }
+
+ return count($this->collGroupI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildGroupI18n object to this object
+ * through the ChildGroupI18n foreign key attribute.
+ *
+ * @param ChildGroupI18n $l ChildGroupI18n
+ * @return \Thelia\Model\Group The current object (for fluent API support)
+ */
+ public function addGroupI18n(ChildGroupI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collGroupI18ns === null) {
+ $this->initGroupI18ns();
+ $this->collGroupI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collGroupI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddGroupI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param GroupI18n $groupI18n The groupI18n object to add.
+ */
+ protected function doAddGroupI18n($groupI18n)
+ {
+ $this->collGroupI18ns[]= $groupI18n;
+ $groupI18n->setGroup($this);
+ }
+
+ /**
+ * @param GroupI18n $groupI18n The groupI18n object to remove.
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function removeGroupI18n($groupI18n)
+ {
+ if ($this->getGroupI18ns()->contains($groupI18n)) {
+ $this->collGroupI18ns->remove($this->collGroupI18ns->search($groupI18n));
+ if (null === $this->groupI18nsScheduledForDeletion) {
+ $this->groupI18nsScheduledForDeletion = clone $this->collGroupI18ns;
+ $this->groupI18nsScheduledForDeletion->clear();
+ }
+ $this->groupI18nsScheduledForDeletion[]= clone $groupI18n;
+ $groupI18n->setGroup(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collAdmins collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAdmins()
+ */
+ public function clearAdmins()
+ {
+ $this->collAdmins = null; // important to set this to NULL since that means it is uninitialized
+ $this->collAdminsPartial = null;
+ }
+
+ /**
+ * Initializes the collAdmins collection.
+ *
+ * By default this just sets the collAdmins collection to an empty collection (like clearAdmins());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initAdmins()
+ {
+ $this->collAdmins = new ObjectCollection();
+ $this->collAdmins->setModel('\Thelia\Model\Admin');
+ }
+
+ /**
+ * Gets a collection of ChildAdmin objects related by a many-to-many relationship
+ * to the current object by way of the admin_group cross-reference table.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildGroup is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return ObjectCollection|ChildAdmin[] List of ChildAdmin objects
+ */
+ public function getAdmins($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collAdmins || null !== $criteria) {
+ if ($this->isNew() && null === $this->collAdmins) {
+ // return empty collection
+ $this->initAdmins();
+ } else {
+ $collAdmins = ChildAdminQuery::create(null, $criteria)
+ ->filterByGroup($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collAdmins;
+ }
+ $this->collAdmins = $collAdmins;
+ }
+ }
+
+ return $this->collAdmins;
+ }
+
+ /**
+ * Sets a collection of Admin objects related by a many-to-many relationship
+ * to the current object by way of the admin_group cross-reference table.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $admins A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function setAdmins(Collection $admins, ConnectionInterface $con = null)
+ {
+ $this->clearAdmins();
+ $currentAdmins = $this->getAdmins();
+
+ $this->adminsScheduledForDeletion = $currentAdmins->diff($admins);
+
+ foreach ($admins as $admin) {
+ if (!$currentAdmins->contains($admin)) {
+ $this->doAddAdmin($admin);
+ }
+ }
+
+ $this->collAdmins = $admins;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildAdmin objects related by a many-to-many relationship
+ * to the current object by way of the admin_group cross-reference table.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param boolean $distinct Set to true to force count distinct
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return int the number of related ChildAdmin objects
+ */
+ public function countAdmins($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collAdmins || null !== $criteria) {
+ if ($this->isNew() && null === $this->collAdmins) {
+ return 0;
+ } else {
+ $query = ChildAdminQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByGroup($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collAdmins);
+ }
+ }
+
+ /**
+ * Associate a ChildAdmin object to this object
+ * through the admin_group cross reference table.
+ *
+ * @param ChildAdmin $admin The ChildAdminGroup object to relate
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function addAdmin(ChildAdmin $admin)
+ {
+ if ($this->collAdmins === null) {
+ $this->initAdmins();
+ }
+
+ if (!$this->collAdmins->contains($admin)) { // only add it if the **same** object is not already associated
+ $this->doAddAdmin($admin);
+ $this->collAdmins[] = $admin;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Admin $admin The admin object to add.
+ */
+ protected function doAddAdmin($admin)
+ {
+ $adminGroup = new ChildAdminGroup();
+ $adminGroup->setAdmin($admin);
+ $this->addAdminGroup($adminGroup);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$admin->getGroups()->contains($this)) {
+ $foreignCollection = $admin->getGroups();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildAdmin object to this object
+ * through the admin_group cross reference table.
+ *
+ * @param ChildAdmin $admin The ChildAdminGroup object to relate
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function removeAdmin(ChildAdmin $admin)
+ {
+ if ($this->getAdmins()->contains($admin)) {
+ $this->collAdmins->remove($this->collAdmins->search($admin));
+
+ if (null === $this->adminsScheduledForDeletion) {
+ $this->adminsScheduledForDeletion = clone $this->collAdmins;
+ $this->adminsScheduledForDeletion->clear();
+ }
+
+ $this->adminsScheduledForDeletion[] = $admin;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collResources collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addResources()
+ */
+ public function clearResources()
+ {
+ $this->collResources = null; // important to set this to NULL since that means it is uninitialized
+ $this->collResourcesPartial = null;
+ }
+
+ /**
+ * Initializes the collResources collection.
+ *
+ * By default this just sets the collResources collection to an empty collection (like clearResources());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initResources()
+ {
+ $this->collResources = new ObjectCollection();
+ $this->collResources->setModel('\Thelia\Model\Resource');
+ }
+
+ /**
+ * Gets a collection of ChildResource objects related by a many-to-many relationship
+ * to the current object by way of the group_resource cross-reference table.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildGroup is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return ObjectCollection|ChildResource[] List of ChildResource objects
+ */
+ public function getResources($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collResources || null !== $criteria) {
+ if ($this->isNew() && null === $this->collResources) {
+ // return empty collection
+ $this->initResources();
+ } else {
+ $collResources = ChildResourceQuery::create(null, $criteria)
+ ->filterByGroup($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collResources;
+ }
+ $this->collResources = $collResources;
+ }
+ }
+
+ return $this->collResources;
+ }
+
+ /**
+ * Sets a collection of Resource objects related by a many-to-many relationship
+ * to the current object by way of the group_resource cross-reference table.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $resources A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function setResources(Collection $resources, ConnectionInterface $con = null)
+ {
+ $this->clearResources();
+ $currentResources = $this->getResources();
+
+ $this->resourcesScheduledForDeletion = $currentResources->diff($resources);
+
+ foreach ($resources as $resource) {
+ if (!$currentResources->contains($resource)) {
+ $this->doAddResource($resource);
+ }
+ }
+
+ $this->collResources = $resources;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildResource objects related by a many-to-many relationship
+ * to the current object by way of the group_resource cross-reference table.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param boolean $distinct Set to true to force count distinct
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return int the number of related ChildResource objects
+ */
+ public function countResources($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collResources || null !== $criteria) {
+ if ($this->isNew() && null === $this->collResources) {
+ return 0;
+ } else {
+ $query = ChildResourceQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByGroup($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collResources);
+ }
+ }
+
+ /**
+ * Associate a ChildResource object to this object
+ * through the group_resource cross reference table.
+ *
+ * @param ChildResource $resource The ChildGroupResource object to relate
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function addResource(ChildResource $resource)
+ {
+ if ($this->collResources === null) {
+ $this->initResources();
+ }
+
+ if (!$this->collResources->contains($resource)) { // only add it if the **same** object is not already associated
+ $this->doAddResource($resource);
+ $this->collResources[] = $resource;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Resource $resource The resource object to add.
+ */
+ protected function doAddResource($resource)
+ {
+ $groupResource = new ChildGroupResource();
+ $groupResource->setResource($resource);
+ $this->addGroupResource($groupResource);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$resource->getGroups()->contains($this)) {
+ $foreignCollection = $resource->getGroups();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildResource object to this object
+ * through the group_resource cross reference table.
+ *
+ * @param ChildResource $resource The ChildGroupResource object to relate
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function removeResource(ChildResource $resource)
+ {
+ if ($this->getResources()->contains($resource)) {
+ $this->collResources->remove($this->collResources->search($resource));
+
+ if (null === $this->resourcesScheduledForDeletion) {
+ $this->resourcesScheduledForDeletion = clone $this->collResources;
+ $this->resourcesScheduledForDeletion->clear();
+ }
+
+ $this->resourcesScheduledForDeletion[] = $resource;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collAdminGroups) {
+ foreach ($this->collAdminGroups as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collGroupResources) {
+ foreach ($this->collGroupResources as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collGroupModules) {
+ foreach ($this->collGroupModules as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collGroupI18ns) {
+ foreach ($this->collGroupI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAdmins) {
+ foreach ($this->collAdmins as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collResources) {
+ foreach ($this->collResources as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collAdminGroups instanceof Collection) {
+ $this->collAdminGroups->clearIterator();
+ }
+ $this->collAdminGroups = null;
+ if ($this->collGroupResources instanceof Collection) {
+ $this->collGroupResources->clearIterator();
+ }
+ $this->collGroupResources = null;
+ if ($this->collGroupModules instanceof Collection) {
+ $this->collGroupModules->clearIterator();
+ }
+ $this->collGroupModules = null;
+ if ($this->collGroupI18ns instanceof Collection) {
+ $this->collGroupI18ns->clearIterator();
+ }
+ $this->collGroupI18ns = null;
+ if ($this->collAdmins instanceof Collection) {
+ $this->collAdmins->clearIterator();
+ }
+ $this->collAdmins = null;
+ if ($this->collResources instanceof Collection) {
+ $this->collResources->clearIterator();
+ }
+ $this->collResources = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(GroupTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = GroupTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildGroupI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collGroupI18ns) {
+ foreach ($this->collGroupI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildGroupI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildGroupI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addGroupI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildGroup The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildGroupI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collGroupI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collGroupI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildGroupI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\GroupI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\GroupI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\GroupI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\GroupI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/GroupI18n.php b/core/lib/Thelia/Model/Base/GroupI18n.php
new file mode 100644
index 000000000..de90d8863
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/GroupI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\GroupI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another GroupI18n instance. If
+ * obj is an instance of GroupI18n, delegates to
+ * equals(GroupI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return GroupI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return GroupI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\GroupI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = GroupI18nTableMap::ID;
+ }
+
+ if ($this->aGroup !== null && $this->aGroup->getId() !== $v) {
+ $this->aGroup = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\GroupI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = GroupI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\GroupI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = GroupI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\GroupI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = GroupI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\GroupI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = GroupI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\GroupI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = GroupI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : GroupI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : GroupI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : GroupI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : GroupI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : GroupI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : GroupI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = GroupI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\GroupI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aGroup !== null && $this->id !== $this->aGroup->getId()) {
+ $this->aGroup = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(GroupI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildGroupI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aGroup = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see GroupI18n::setDeleted()
+ * @see GroupI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildGroupI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ GroupI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aGroup !== null) {
+ if ($this->aGroup->isModified() || $this->aGroup->isNew()) {
+ $affectedRows += $this->aGroup->save($con);
+ }
+ $this->setGroup($this->aGroup);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(GroupI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(GroupI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(GroupI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(GroupI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(GroupI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(GroupI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO group_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = GroupI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['GroupI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['GroupI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = GroupI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aGroup) {
+ $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = GroupI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = GroupI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(GroupI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(GroupI18nTableMap::ID)) $criteria->add(GroupI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(GroupI18nTableMap::LOCALE)) $criteria->add(GroupI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(GroupI18nTableMap::TITLE)) $criteria->add(GroupI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(GroupI18nTableMap::DESCRIPTION)) $criteria->add(GroupI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(GroupI18nTableMap::CHAPO)) $criteria->add(GroupI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(GroupI18nTableMap::POSTSCRIPTUM)) $criteria->add(GroupI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(GroupI18nTableMap::DATABASE_NAME);
+ $criteria->add(GroupI18nTableMap::ID, $this->id);
+ $criteria->add(GroupI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\GroupI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\GroupI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildGroup object.
+ *
+ * @param ChildGroup $v
+ * @return \Thelia\Model\GroupI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setGroup(ChildGroup $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aGroup = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildGroup object, it will not be re-added.
+ if ($v !== null) {
+ $v->addGroupI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildGroup object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildGroup The associated ChildGroup object.
+ * @throws PropelException
+ */
+ public function getGroup(ConnectionInterface $con = null)
+ {
+ if ($this->aGroup === null && ($this->id !== null)) {
+ $this->aGroup = ChildGroupQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aGroup->addGroupI18ns($this);
+ */
+ }
+
+ return $this->aGroup;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aGroup = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(GroupI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/GroupI18nQuery.php b/core/lib/Thelia/Model/Base/GroupI18nQuery.php
new file mode 100644
index 000000000..8dc7b44ec
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/GroupI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildGroupI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = GroupI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(GroupI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildGroupI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM group_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildGroupI18n();
+ $obj->hydrate($row);
+ GroupI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildGroupI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildGroupI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(GroupI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(GroupI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildGroupI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(GroupI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(GroupI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByGroup()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(GroupI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(GroupI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(GroupI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(GroupI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(GroupI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(GroupI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(GroupI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Group object
+ *
+ * @param \Thelia\Model\Group|ObjectCollection $group The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupI18nQuery The current query, for fluid interface
+ */
+ public function filterByGroup($group, $comparison = null)
+ {
+ if ($group instanceof \Thelia\Model\Group) {
+ return $this
+ ->addUsingAlias(GroupI18nTableMap::ID, $group->getId(), $comparison);
+ } elseif ($group instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(GroupI18nTableMap::ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByGroup() only accepts arguments of type \Thelia\Model\Group or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Group relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildGroupI18nQuery The current query, for fluid interface
+ */
+ public function joinGroup($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Group');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Group');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Group relation Group object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\GroupQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinGroup($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildGroupI18n $groupI18n Object to remove from the list of results
+ *
+ * @return ChildGroupI18nQuery The current query, for fluid interface
+ */
+ public function prune($groupI18n = null)
+ {
+ if ($groupI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(GroupI18nTableMap::ID), $groupI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(GroupI18nTableMap::LOCALE), $groupI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the group_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ GroupI18nTableMap::clearInstancePool();
+ GroupI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildGroupI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildGroupI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupI18nTableMap::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->beginTransaction();
+
+
+ GroupI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ GroupI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // GroupI18nQuery
diff --git a/core/lib/Thelia/Model/Base/GroupModule.php b/core/lib/Thelia/Model/Base/GroupModule.php
new file mode 100644
index 000000000..620ca9c91
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/GroupModule.php
@@ -0,0 +1,1572 @@
+access = 0;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\GroupModule object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another GroupModule instance. If
+ * obj is an instance of GroupModule, delegates to
+ * equals(GroupModule). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return GroupModule The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return GroupModule The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [group_id] column value.
+ *
+ * @return int
+ */
+ public function getGroupId()
+ {
+
+ return $this->group_id;
+ }
+
+ /**
+ * Get the [module_id] column value.
+ *
+ * @return int
+ */
+ public function getModuleId()
+ {
+
+ return $this->module_id;
+ }
+
+ /**
+ * Get the [access] column value.
+ *
+ * @return int
+ */
+ public function getAccess()
+ {
+
+ return $this->access;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\GroupModule The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = GroupModuleTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [group_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\GroupModule The current object (for fluent API support)
+ */
+ public function setGroupId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->group_id !== $v) {
+ $this->group_id = $v;
+ $this->modifiedColumns[] = GroupModuleTableMap::GROUP_ID;
+ }
+
+ if ($this->aGroup !== null && $this->aGroup->getId() !== $v) {
+ $this->aGroup = null;
+ }
+
+
+ return $this;
+ } // setGroupId()
+
+ /**
+ * Set the value of [module_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\GroupModule The current object (for fluent API support)
+ */
+ public function setModuleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->module_id !== $v) {
+ $this->module_id = $v;
+ $this->modifiedColumns[] = GroupModuleTableMap::MODULE_ID;
+ }
+
+ if ($this->aModule !== null && $this->aModule->getId() !== $v) {
+ $this->aModule = null;
+ }
+
+
+ return $this;
+ } // setModuleId()
+
+ /**
+ * Set the value of [access] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\GroupModule The current object (for fluent API support)
+ */
+ public function setAccess($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->access !== $v) {
+ $this->access = $v;
+ $this->modifiedColumns[] = GroupModuleTableMap::ACCESS;
+ }
+
+
+ return $this;
+ } // setAccess()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\GroupModule The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = GroupModuleTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\GroupModule The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = GroupModuleTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->access !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : GroupModuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : GroupModuleTableMap::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->group_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : GroupModuleTableMap::translateFieldName('ModuleId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->module_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : GroupModuleTableMap::translateFieldName('Access', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->access = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : GroupModuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : GroupModuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = GroupModuleTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\GroupModule object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aGroup !== null && $this->group_id !== $this->aGroup->getId()) {
+ $this->aGroup = null;
+ }
+ if ($this->aModule !== null && $this->module_id !== $this->aModule->getId()) {
+ $this->aModule = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(GroupModuleTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildGroupModuleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aGroup = null;
+ $this->aModule = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see GroupModule::setDeleted()
+ * @see GroupModule::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildGroupModuleQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(GroupModuleTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(GroupModuleTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(GroupModuleTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ GroupModuleTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aGroup !== null) {
+ if ($this->aGroup->isModified() || $this->aGroup->isNew()) {
+ $affectedRows += $this->aGroup->save($con);
+ }
+ $this->setGroup($this->aGroup);
+ }
+
+ if ($this->aModule !== null) {
+ if ($this->aModule->isModified() || $this->aModule->isNew()) {
+ $affectedRows += $this->aModule->save($con);
+ }
+ $this->setModule($this->aModule);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = GroupModuleTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupModuleTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(GroupModuleTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(GroupModuleTableMap::GROUP_ID)) {
+ $modifiedColumns[':p' . $index++] = 'GROUP_ID';
+ }
+ if ($this->isColumnModified(GroupModuleTableMap::MODULE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'MODULE_ID';
+ }
+ if ($this->isColumnModified(GroupModuleTableMap::ACCESS)) {
+ $modifiedColumns[':p' . $index++] = 'ACCESS';
+ }
+ if ($this->isColumnModified(GroupModuleTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(GroupModuleTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO group_module (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'GROUP_ID':
+ $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT);
+ break;
+ case 'MODULE_ID':
+ $stmt->bindValue($identifier, $this->module_id, PDO::PARAM_INT);
+ break;
+ case 'ACCESS':
+ $stmt->bindValue($identifier, $this->access, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = GroupModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getGroupId();
+ break;
+ case 2:
+ return $this->getModuleId();
+ break;
+ case 3:
+ return $this->getAccess();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['GroupModule'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['GroupModule'][$this->getPrimaryKey()] = true;
+ $keys = GroupModuleTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getGroupId(),
+ $keys[2] => $this->getModuleId(),
+ $keys[3] => $this->getAccess(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aGroup) {
+ $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aModule) {
+ $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = GroupModuleTableMap::translateFieldName($name, $type, TableMap::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->setGroupId($value);
+ break;
+ case 2:
+ $this->setModuleId($value);
+ break;
+ case 3:
+ $this->setAccess($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = GroupModuleTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setModuleId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setAccess($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(GroupModuleTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(GroupModuleTableMap::ID)) $criteria->add(GroupModuleTableMap::ID, $this->id);
+ if ($this->isColumnModified(GroupModuleTableMap::GROUP_ID)) $criteria->add(GroupModuleTableMap::GROUP_ID, $this->group_id);
+ if ($this->isColumnModified(GroupModuleTableMap::MODULE_ID)) $criteria->add(GroupModuleTableMap::MODULE_ID, $this->module_id);
+ if ($this->isColumnModified(GroupModuleTableMap::ACCESS)) $criteria->add(GroupModuleTableMap::ACCESS, $this->access);
+ if ($this->isColumnModified(GroupModuleTableMap::CREATED_AT)) $criteria->add(GroupModuleTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(GroupModuleTableMap::UPDATED_AT)) $criteria->add(GroupModuleTableMap::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(GroupModuleTableMap::DATABASE_NAME);
+ $criteria->add(GroupModuleTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\GroupModule (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setGroupId($this->getGroupId());
+ $copyObj->setModuleId($this->getModuleId());
+ $copyObj->setAccess($this->getAccess());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\GroupModule 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildGroup object.
+ *
+ * @param ChildGroup $v
+ * @return \Thelia\Model\GroupModule The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setGroup(ChildGroup $v = null)
+ {
+ if ($v === null) {
+ $this->setGroupId(NULL);
+ } else {
+ $this->setGroupId($v->getId());
+ }
+
+ $this->aGroup = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildGroup object, it will not be re-added.
+ if ($v !== null) {
+ $v->addGroupModule($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildGroup object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildGroup The associated ChildGroup object.
+ * @throws PropelException
+ */
+ public function getGroup(ConnectionInterface $con = null)
+ {
+ if ($this->aGroup === null && ($this->group_id !== null)) {
+ $this->aGroup = ChildGroupQuery::create()->findPk($this->group_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aGroup->addGroupModules($this);
+ */
+ }
+
+ return $this->aGroup;
+ }
+
+ /**
+ * Declares an association between this object and a ChildModule object.
+ *
+ * @param ChildModule $v
+ * @return \Thelia\Model\GroupModule The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setModule(ChildModule $v = null)
+ {
+ if ($v === null) {
+ $this->setModuleId(NULL);
+ } else {
+ $this->setModuleId($v->getId());
+ }
+
+ $this->aModule = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildModule object, it will not be re-added.
+ if ($v !== null) {
+ $v->addGroupModule($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildModule object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildModule The associated ChildModule object.
+ * @throws PropelException
+ */
+ public function getModule(ConnectionInterface $con = null)
+ {
+ if ($this->aModule === null && ($this->module_id !== null)) {
+ $this->aModule = ChildModuleQuery::create()->findPk($this->module_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aModule->addGroupModules($this);
+ */
+ }
+
+ return $this->aModule;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->group_id = null;
+ $this->module_id = null;
+ $this->access = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aGroup = null;
+ $this->aModule = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(GroupModuleTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildGroupModule The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = GroupModuleTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/GroupModuleQuery.php b/core/lib/Thelia/Model/Base/GroupModuleQuery.php
new file mode 100644
index 000000000..531342ec9
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/GroupModuleQuery.php
@@ -0,0 +1,804 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildGroupModule|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = GroupModuleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(GroupModuleTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildGroupModule A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, GROUP_ID, MODULE_ID, ACCESS, CREATED_AT, UPDATED_AT FROM group_module WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildGroupModule();
+ $obj->hydrate($row);
+ GroupModuleTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildGroupModule|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(GroupModuleTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(GroupModuleTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(GroupModuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(GroupModuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupModuleTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the group_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByGroupId(1234); // WHERE group_id = 1234
+ * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34)
+ * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12
+ *
+ *
+ * @see filterByGroup()
+ *
+ * @param mixed $groupId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByGroupId($groupId = null, $comparison = null)
+ {
+ if (is_array($groupId)) {
+ $useMinMax = false;
+ if (isset($groupId['min'])) {
+ $this->addUsingAlias(GroupModuleTableMap::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($groupId['max'])) {
+ $this->addUsingAlias(GroupModuleTableMap::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupModuleTableMap::GROUP_ID, $groupId, $comparison);
+ }
+
+ /**
+ * Filter the query on the module_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByModuleId(1234); // WHERE module_id = 1234
+ * $query->filterByModuleId(array(12, 34)); // WHERE module_id IN (12, 34)
+ * $query->filterByModuleId(array('min' => 12)); // WHERE module_id > 12
+ *
+ *
+ * @see filterByModule()
+ *
+ * @param mixed $moduleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByModuleId($moduleId = null, $comparison = null)
+ {
+ if (is_array($moduleId)) {
+ $useMinMax = false;
+ if (isset($moduleId['min'])) {
+ $this->addUsingAlias(GroupModuleTableMap::MODULE_ID, $moduleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($moduleId['max'])) {
+ $this->addUsingAlias(GroupModuleTableMap::MODULE_ID, $moduleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupModuleTableMap::MODULE_ID, $moduleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the access column
+ *
+ * Example usage:
+ *
+ * $query->filterByAccess(1234); // WHERE access = 1234
+ * $query->filterByAccess(array(12, 34)); // WHERE access IN (12, 34)
+ * $query->filterByAccess(array('min' => 12)); // WHERE access > 12
+ *
+ *
+ * @param mixed $access The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByAccess($access = null, $comparison = null)
+ {
+ if (is_array($access)) {
+ $useMinMax = false;
+ if (isset($access['min'])) {
+ $this->addUsingAlias(GroupModuleTableMap::ACCESS, $access['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($access['max'])) {
+ $this->addUsingAlias(GroupModuleTableMap::ACCESS, $access['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupModuleTableMap::ACCESS, $access, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(GroupModuleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(GroupModuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupModuleTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(GroupModuleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(GroupModuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupModuleTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Group object
+ *
+ * @param \Thelia\Model\Group|ObjectCollection $group The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByGroup($group, $comparison = null)
+ {
+ if ($group instanceof \Thelia\Model\Group) {
+ return $this
+ ->addUsingAlias(GroupModuleTableMap::GROUP_ID, $group->getId(), $comparison);
+ } elseif ($group instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(GroupModuleTableMap::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByGroup() only accepts arguments of type \Thelia\Model\Group or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Group relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Group');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Group');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Group relation Group object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\GroupQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinGroup($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Module object
+ *
+ * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function filterByModule($module, $comparison = null)
+ {
+ if ($module instanceof \Thelia\Model\Module) {
+ return $this
+ ->addUsingAlias(GroupModuleTableMap::MODULE_ID, $module->getId(), $comparison);
+ } elseif ($module instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(GroupModuleTableMap::MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Module relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function joinModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Module');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Module');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Module relation Module object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query
+ */
+ public function useModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinModule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildGroupModule $groupModule Object to remove from the list of results
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function prune($groupModule = null)
+ {
+ if ($groupModule) {
+ $this->addUsingAlias(GroupModuleTableMap::ID, $groupModule->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the group_module table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ GroupModuleTableMap::clearInstancePool();
+ GroupModuleTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildGroupModule or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildGroupModule object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupModuleTableMap::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->beginTransaction();
+
+
+ GroupModuleTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ GroupModuleTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(GroupModuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(GroupModuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(GroupModuleTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(GroupModuleTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(GroupModuleTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildGroupModuleQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(GroupModuleTableMap::CREATED_AT);
+ }
+
+} // GroupModuleQuery
diff --git a/core/lib/Thelia/Model/Base/GroupQuery.php b/core/lib/Thelia/Model/Base/GroupQuery.php
new file mode 100644
index 000000000..8ca963848
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/GroupQuery.php
@@ -0,0 +1,940 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildGroup|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = GroupTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(GroupTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildGroup A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CODE, CREATED_AT, UPDATED_AT FROM group WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildGroup();
+ $obj->hydrate($row);
+ GroupTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildGroup|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(GroupTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(GroupTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(GroupTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(GroupTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(GroupTableMap::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(GroupTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(GroupTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(GroupTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(GroupTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\AdminGroup object
+ *
+ * @param \Thelia\Model\AdminGroup|ObjectCollection $adminGroup the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function filterByAdminGroup($adminGroup, $comparison = null)
+ {
+ if ($adminGroup instanceof \Thelia\Model\AdminGroup) {
+ return $this
+ ->addUsingAlias(GroupTableMap::ID, $adminGroup->getGroupId(), $comparison);
+ } elseif ($adminGroup instanceof ObjectCollection) {
+ return $this
+ ->useAdminGroupQuery()
+ ->filterByPrimaryKeys($adminGroup->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAdminGroup() only accepts arguments of type \Thelia\Model\AdminGroup or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AdminGroup relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function joinAdminGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AdminGroup');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AdminGroup');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AdminGroup relation AdminGroup object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AdminGroupQuery A secondary query class using the current class as primary query
+ */
+ public function useAdminGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAdminGroup($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AdminGroup', '\Thelia\Model\AdminGroupQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\GroupResource object
+ *
+ * @param \Thelia\Model\GroupResource|ObjectCollection $groupResource the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function filterByGroupResource($groupResource, $comparison = null)
+ {
+ if ($groupResource instanceof \Thelia\Model\GroupResource) {
+ return $this
+ ->addUsingAlias(GroupTableMap::ID, $groupResource->getGroupId(), $comparison);
+ } elseif ($groupResource instanceof ObjectCollection) {
+ return $this
+ ->useGroupResourceQuery()
+ ->filterByPrimaryKeys($groupResource->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByGroupResource() only accepts arguments of type \Thelia\Model\GroupResource or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the GroupResource relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function joinGroupResource($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('GroupResource');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'GroupResource');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the GroupResource relation GroupResource object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\GroupResourceQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinGroupResource($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'GroupResource', '\Thelia\Model\GroupResourceQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\GroupModule object
+ *
+ * @param \Thelia\Model\GroupModule|ObjectCollection $groupModule the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function filterByGroupModule($groupModule, $comparison = null)
+ {
+ if ($groupModule instanceof \Thelia\Model\GroupModule) {
+ return $this
+ ->addUsingAlias(GroupTableMap::ID, $groupModule->getGroupId(), $comparison);
+ } elseif ($groupModule instanceof ObjectCollection) {
+ return $this
+ ->useGroupModuleQuery()
+ ->filterByPrimaryKeys($groupModule->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByGroupModule() only accepts arguments of type \Thelia\Model\GroupModule or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the GroupModule relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function joinGroupModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('GroupModule');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'GroupModule');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the GroupModule relation GroupModule object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\GroupModuleQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinGroupModule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'GroupModule', '\Thelia\Model\GroupModuleQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\GroupI18n object
+ *
+ * @param \Thelia\Model\GroupI18n|ObjectCollection $groupI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function filterByGroupI18n($groupI18n, $comparison = null)
+ {
+ if ($groupI18n instanceof \Thelia\Model\GroupI18n) {
+ return $this
+ ->addUsingAlias(GroupTableMap::ID, $groupI18n->getId(), $comparison);
+ } elseif ($groupI18n instanceof ObjectCollection) {
+ return $this
+ ->useGroupI18nQuery()
+ ->filterByPrimaryKeys($groupI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByGroupI18n() only accepts arguments of type \Thelia\Model\GroupI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the GroupI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function joinGroupI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('GroupI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'GroupI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the GroupI18n relation GroupI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\GroupI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinGroupI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'GroupI18n', '\Thelia\Model\GroupI18nQuery');
+ }
+
+ /**
+ * Filter the query by a related Admin object
+ * using the admin_group table as cross reference
+ *
+ * @param Admin $admin the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function filterByAdmin($admin, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useAdminGroupQuery()
+ ->filterByAdmin($admin, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Filter the query by a related Resource object
+ * using the group_resource table as cross reference
+ *
+ * @param Resource $resource the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function filterByResource($resource, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useGroupResourceQuery()
+ ->filterByResource($resource, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildGroup $group Object to remove from the list of results
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function prune($group = null)
+ {
+ if ($group) {
+ $this->addUsingAlias(GroupTableMap::ID, $group->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the group table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ GroupTableMap::clearInstancePool();
+ GroupTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildGroup or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildGroup object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupTableMap::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->beginTransaction();
+
+
+ GroupTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ GroupTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(GroupTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(GroupTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(GroupTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(GroupTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(GroupTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(GroupTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'GroupI18n';
+
+ return $this
+ ->joinGroupI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildGroupQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('GroupI18n');
+ $this->with['GroupI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildGroupI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'GroupI18n', '\Thelia\Model\GroupI18nQuery');
+ }
+
+} // GroupQuery
diff --git a/core/lib/Thelia/Model/Base/GroupResource.php b/core/lib/Thelia/Model/Base/GroupResource.php
new file mode 100644
index 000000000..84d6006b0
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/GroupResource.php
@@ -0,0 +1,1646 @@
+read = 0;
+ $this->write = 0;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\GroupResource object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another GroupResource instance. If
+ * obj is an instance of GroupResource, delegates to
+ * equals(GroupResource). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return GroupResource The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return GroupResource The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [group_id] column value.
+ *
+ * @return int
+ */
+ public function getGroupId()
+ {
+
+ return $this->group_id;
+ }
+
+ /**
+ * Get the [resource_id] column value.
+ *
+ * @return int
+ */
+ public function getResourceId()
+ {
+
+ return $this->resource_id;
+ }
+
+ /**
+ * Get the [read] column value.
+ *
+ * @return int
+ */
+ public function getRead()
+ {
+
+ return $this->read;
+ }
+
+ /**
+ * Get the [write] column value.
+ *
+ * @return int
+ */
+ public function getWrite()
+ {
+
+ return $this->write;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\GroupResource The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = GroupResourceTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [group_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\GroupResource The current object (for fluent API support)
+ */
+ public function setGroupId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->group_id !== $v) {
+ $this->group_id = $v;
+ $this->modifiedColumns[] = GroupResourceTableMap::GROUP_ID;
+ }
+
+ if ($this->aGroup !== null && $this->aGroup->getId() !== $v) {
+ $this->aGroup = null;
+ }
+
+
+ return $this;
+ } // setGroupId()
+
+ /**
+ * Set the value of [resource_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\GroupResource The current object (for fluent API support)
+ */
+ public function setResourceId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->resource_id !== $v) {
+ $this->resource_id = $v;
+ $this->modifiedColumns[] = GroupResourceTableMap::RESOURCE_ID;
+ }
+
+ if ($this->aResource !== null && $this->aResource->getId() !== $v) {
+ $this->aResource = null;
+ }
+
+
+ return $this;
+ } // setResourceId()
+
+ /**
+ * Set the value of [read] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\GroupResource The current object (for fluent API support)
+ */
+ public function setRead($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->read !== $v) {
+ $this->read = $v;
+ $this->modifiedColumns[] = GroupResourceTableMap::READ;
+ }
+
+
+ return $this;
+ } // setRead()
+
+ /**
+ * Set the value of [write] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\GroupResource The current object (for fluent API support)
+ */
+ public function setWrite($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->write !== $v) {
+ $this->write = $v;
+ $this->modifiedColumns[] = GroupResourceTableMap::WRITE;
+ }
+
+
+ return $this;
+ } // setWrite()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\GroupResource The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = GroupResourceTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\GroupResource The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = GroupResourceTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->read !== 0) {
+ return false;
+ }
+
+ if ($this->write !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : GroupResourceTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : GroupResourceTableMap::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->group_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : GroupResourceTableMap::translateFieldName('ResourceId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->resource_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : GroupResourceTableMap::translateFieldName('Read', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->read = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : GroupResourceTableMap::translateFieldName('Write', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->write = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : GroupResourceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : GroupResourceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = GroupResourceTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\GroupResource object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aGroup !== null && $this->group_id !== $this->aGroup->getId()) {
+ $this->aGroup = null;
+ }
+ if ($this->aResource !== null && $this->resource_id !== $this->aResource->getId()) {
+ $this->aResource = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(GroupResourceTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildGroupResourceQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aGroup = null;
+ $this->aResource = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see GroupResource::setDeleted()
+ * @see GroupResource::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildGroupResourceQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(GroupResourceTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(GroupResourceTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(GroupResourceTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ GroupResourceTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aGroup !== null) {
+ if ($this->aGroup->isModified() || $this->aGroup->isNew()) {
+ $affectedRows += $this->aGroup->save($con);
+ }
+ $this->setGroup($this->aGroup);
+ }
+
+ if ($this->aResource !== null) {
+ if ($this->aResource->isModified() || $this->aResource->isNew()) {
+ $affectedRows += $this->aResource->save($con);
+ }
+ $this->setResource($this->aResource);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = GroupResourceTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupResourceTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(GroupResourceTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(GroupResourceTableMap::GROUP_ID)) {
+ $modifiedColumns[':p' . $index++] = 'GROUP_ID';
+ }
+ if ($this->isColumnModified(GroupResourceTableMap::RESOURCE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'RESOURCE_ID';
+ }
+ if ($this->isColumnModified(GroupResourceTableMap::READ)) {
+ $modifiedColumns[':p' . $index++] = 'READ';
+ }
+ if ($this->isColumnModified(GroupResourceTableMap::WRITE)) {
+ $modifiedColumns[':p' . $index++] = 'WRITE';
+ }
+ if ($this->isColumnModified(GroupResourceTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(GroupResourceTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO group_resource (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'GROUP_ID':
+ $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT);
+ break;
+ case 'RESOURCE_ID':
+ $stmt->bindValue($identifier, $this->resource_id, PDO::PARAM_INT);
+ break;
+ case 'READ':
+ $stmt->bindValue($identifier, $this->read, PDO::PARAM_INT);
+ break;
+ case 'WRITE':
+ $stmt->bindValue($identifier, $this->write, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = GroupResourceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getGroupId();
+ break;
+ case 2:
+ return $this->getResourceId();
+ break;
+ case 3:
+ return $this->getRead();
+ break;
+ case 4:
+ return $this->getWrite();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['GroupResource'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['GroupResource'][serialize($this->getPrimaryKey())] = true;
+ $keys = GroupResourceTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getGroupId(),
+ $keys[2] => $this->getResourceId(),
+ $keys[3] => $this->getRead(),
+ $keys[4] => $this->getWrite(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aGroup) {
+ $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aResource) {
+ $result['Resource'] = $this->aResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = GroupResourceTableMap::translateFieldName($name, $type, TableMap::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->setGroupId($value);
+ break;
+ case 2:
+ $this->setResourceId($value);
+ break;
+ case 3:
+ $this->setRead($value);
+ break;
+ case 4:
+ $this->setWrite($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = GroupResourceTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setResourceId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setRead($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setWrite($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * 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(GroupResourceTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(GroupResourceTableMap::ID)) $criteria->add(GroupResourceTableMap::ID, $this->id);
+ if ($this->isColumnModified(GroupResourceTableMap::GROUP_ID)) $criteria->add(GroupResourceTableMap::GROUP_ID, $this->group_id);
+ if ($this->isColumnModified(GroupResourceTableMap::RESOURCE_ID)) $criteria->add(GroupResourceTableMap::RESOURCE_ID, $this->resource_id);
+ if ($this->isColumnModified(GroupResourceTableMap::READ)) $criteria->add(GroupResourceTableMap::READ, $this->read);
+ if ($this->isColumnModified(GroupResourceTableMap::WRITE)) $criteria->add(GroupResourceTableMap::WRITE, $this->write);
+ if ($this->isColumnModified(GroupResourceTableMap::CREATED_AT)) $criteria->add(GroupResourceTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(GroupResourceTableMap::UPDATED_AT)) $criteria->add(GroupResourceTableMap::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(GroupResourceTableMap::DATABASE_NAME);
+ $criteria->add(GroupResourceTableMap::ID, $this->id);
+ $criteria->add(GroupResourceTableMap::GROUP_ID, $this->group_id);
+ $criteria->add(GroupResourceTableMap::RESOURCE_ID, $this->resource_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getGroupId();
+ $pks[2] = $this->getResourceId();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setGroupId($keys[1]);
+ $this->setResourceId($keys[2]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getGroupId()) && (null === $this->getResourceId());
+ }
+
+ /**
+ * 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 \Thelia\Model\GroupResource (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setGroupId($this->getGroupId());
+ $copyObj->setResourceId($this->getResourceId());
+ $copyObj->setRead($this->getRead());
+ $copyObj->setWrite($this->getWrite());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\GroupResource 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildGroup object.
+ *
+ * @param ChildGroup $v
+ * @return \Thelia\Model\GroupResource The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setGroup(ChildGroup $v = null)
+ {
+ if ($v === null) {
+ $this->setGroupId(NULL);
+ } else {
+ $this->setGroupId($v->getId());
+ }
+
+ $this->aGroup = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildGroup object, it will not be re-added.
+ if ($v !== null) {
+ $v->addGroupResource($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildGroup object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildGroup The associated ChildGroup object.
+ * @throws PropelException
+ */
+ public function getGroup(ConnectionInterface $con = null)
+ {
+ if ($this->aGroup === null && ($this->group_id !== null)) {
+ $this->aGroup = ChildGroupQuery::create()->findPk($this->group_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aGroup->addGroupResources($this);
+ */
+ }
+
+ return $this->aGroup;
+ }
+
+ /**
+ * Declares an association between this object and a ChildResource object.
+ *
+ * @param ChildResource $v
+ * @return \Thelia\Model\GroupResource The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setResource(ChildResource $v = null)
+ {
+ if ($v === null) {
+ $this->setResourceId(NULL);
+ } else {
+ $this->setResourceId($v->getId());
+ }
+
+ $this->aResource = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildResource object, it will not be re-added.
+ if ($v !== null) {
+ $v->addGroupResource($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildResource object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildResource The associated ChildResource object.
+ * @throws PropelException
+ */
+ public function getResource(ConnectionInterface $con = null)
+ {
+ if ($this->aResource === null && ($this->resource_id !== null)) {
+ $this->aResource = ChildResourceQuery::create()->findPk($this->resource_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aResource->addGroupResources($this);
+ */
+ }
+
+ return $this->aResource;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->group_id = null;
+ $this->resource_id = null;
+ $this->read = null;
+ $this->write = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aGroup = null;
+ $this->aResource = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(GroupResourceTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildGroupResource The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = GroupResourceTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/GroupResourceQuery.php b/core/lib/Thelia/Model/Base/GroupResourceQuery.php
new file mode 100644
index 000000000..e57894707
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/GroupResourceQuery.php
@@ -0,0 +1,868 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34, 56), $con);
+ *
+ *
+ * @param array[$id, $group_id, $resource_id] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildGroupResource|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = GroupResourceTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(GroupResourceTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildGroupResource A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, GROUP_ID, RESOURCE_ID, READ, WRITE, CREATED_AT, UPDATED_AT FROM group_resource WHERE ID = :p0 AND GROUP_ID = :p1 AND RESOURCE_ID = :p2';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
+ $stmt->bindValue(':p2', $key[2], PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildGroupResource();
+ $obj->hydrate($row);
+ GroupResourceTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildGroupResource|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(GroupResourceTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(GroupResourceTableMap::GROUP_ID, $key[1], Criteria::EQUAL);
+ $this->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $key[2], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(GroupResourceTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(GroupResourceTableMap::GROUP_ID, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $cton2 = $this->getNewCriterion(GroupResourceTableMap::RESOURCE_ID, $key[2], Criteria::EQUAL);
+ $cton0->addAnd($cton2);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(GroupResourceTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(GroupResourceTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupResourceTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the group_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByGroupId(1234); // WHERE group_id = 1234
+ * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34)
+ * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12
+ *
+ *
+ * @see filterByGroup()
+ *
+ * @param mixed $groupId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByGroupId($groupId = null, $comparison = null)
+ {
+ if (is_array($groupId)) {
+ $useMinMax = false;
+ if (isset($groupId['min'])) {
+ $this->addUsingAlias(GroupResourceTableMap::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($groupId['max'])) {
+ $this->addUsingAlias(GroupResourceTableMap::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupResourceTableMap::GROUP_ID, $groupId, $comparison);
+ }
+
+ /**
+ * Filter the query on the resource_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByResourceId(1234); // WHERE resource_id = 1234
+ * $query->filterByResourceId(array(12, 34)); // WHERE resource_id IN (12, 34)
+ * $query->filterByResourceId(array('min' => 12)); // WHERE resource_id > 12
+ *
+ *
+ * @see filterByResource()
+ *
+ * @param mixed $resourceId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByResourceId($resourceId = null, $comparison = null)
+ {
+ if (is_array($resourceId)) {
+ $useMinMax = false;
+ if (isset($resourceId['min'])) {
+ $this->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resourceId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($resourceId['max'])) {
+ $this->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resourceId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resourceId, $comparison);
+ }
+
+ /**
+ * Filter the query on the read column
+ *
+ * Example usage:
+ *
+ * $query->filterByRead(1234); // WHERE read = 1234
+ * $query->filterByRead(array(12, 34)); // WHERE read IN (12, 34)
+ * $query->filterByRead(array('min' => 12)); // WHERE read > 12
+ *
+ *
+ * @param mixed $read The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByRead($read = null, $comparison = null)
+ {
+ if (is_array($read)) {
+ $useMinMax = false;
+ if (isset($read['min'])) {
+ $this->addUsingAlias(GroupResourceTableMap::READ, $read['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($read['max'])) {
+ $this->addUsingAlias(GroupResourceTableMap::READ, $read['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupResourceTableMap::READ, $read, $comparison);
+ }
+
+ /**
+ * Filter the query on the write column
+ *
+ * Example usage:
+ *
+ * $query->filterByWrite(1234); // WHERE write = 1234
+ * $query->filterByWrite(array(12, 34)); // WHERE write IN (12, 34)
+ * $query->filterByWrite(array('min' => 12)); // WHERE write > 12
+ *
+ *
+ * @param mixed $write The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByWrite($write = null, $comparison = null)
+ {
+ if (is_array($write)) {
+ $useMinMax = false;
+ if (isset($write['min'])) {
+ $this->addUsingAlias(GroupResourceTableMap::WRITE, $write['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($write['max'])) {
+ $this->addUsingAlias(GroupResourceTableMap::WRITE, $write['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupResourceTableMap::WRITE, $write, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(GroupResourceTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(GroupResourceTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupResourceTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(GroupResourceTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(GroupResourceTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(GroupResourceTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Group object
+ *
+ * @param \Thelia\Model\Group|ObjectCollection $group The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByGroup($group, $comparison = null)
+ {
+ if ($group instanceof \Thelia\Model\Group) {
+ return $this
+ ->addUsingAlias(GroupResourceTableMap::GROUP_ID, $group->getId(), $comparison);
+ } elseif ($group instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(GroupResourceTableMap::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByGroup() only accepts arguments of type \Thelia\Model\Group or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Group relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Group');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Group');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Group relation Group object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\GroupQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinGroup($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Resource object
+ *
+ * @param \Thelia\Model\Resource|ObjectCollection $resource The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function filterByResource($resource, $comparison = null)
+ {
+ if ($resource instanceof \Thelia\Model\Resource) {
+ return $this
+ ->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resource->getId(), $comparison);
+ } elseif ($resource instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByResource() only accepts arguments of type \Thelia\Model\Resource or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Resource relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function joinResource($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Resource');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Resource');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Resource relation Resource object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ResourceQuery A secondary query class using the current class as primary query
+ */
+ public function useResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinResource($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Resource', '\Thelia\Model\ResourceQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildGroupResource $groupResource Object to remove from the list of results
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function prune($groupResource = null)
+ {
+ if ($groupResource) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(GroupResourceTableMap::ID), $groupResource->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(GroupResourceTableMap::GROUP_ID), $groupResource->getGroupId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond2', $this->getAliasedColName(GroupResourceTableMap::RESOURCE_ID), $groupResource->getResourceId(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the group_resource table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ GroupResourceTableMap::clearInstancePool();
+ GroupResourceTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildGroupResource or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildGroupResource object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(GroupResourceTableMap::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->beginTransaction();
+
+
+ GroupResourceTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ GroupResourceTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(GroupResourceTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(GroupResourceTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(GroupResourceTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(GroupResourceTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(GroupResourceTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildGroupResourceQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(GroupResourceTableMap::CREATED_AT);
+ }
+
+} // GroupResourceQuery
diff --git a/core/lib/Thelia/Model/Base/Image.php b/core/lib/Thelia/Model/Base/Image.php
new file mode 100644
index 000000000..50538aa1a
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Image.php
@@ -0,0 +1,2395 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Image instance. If
+ * obj is an instance of Image, delegates to
+ * equals(Image). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Image The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Image The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+
+ return $this->category_id;
+ }
+
+ /**
+ * Get the [folder_id] column value.
+ *
+ * @return int
+ */
+ public function getFolderId()
+ {
+
+ return $this->folder_id;
+ }
+
+ /**
+ * Get the [content_id] column value.
+ *
+ * @return int
+ */
+ public function getContentId()
+ {
+
+ return $this->content_id;
+ }
+
+ /**
+ * Get the [file] column value.
+ *
+ * @return string
+ */
+ public function getFile()
+ {
+
+ return $this->file;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Image The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ImageTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Image The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = ImageTableMap::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Image The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = ImageTableMap::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Set the value of [folder_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Image The current object (for fluent API support)
+ */
+ public function setFolderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->folder_id !== $v) {
+ $this->folder_id = $v;
+ $this->modifiedColumns[] = ImageTableMap::FOLDER_ID;
+ }
+
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
+
+ return $this;
+ } // setFolderId()
+
+ /**
+ * Set the value of [content_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Image The current object (for fluent API support)
+ */
+ public function setContentId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->content_id !== $v) {
+ $this->content_id = $v;
+ $this->modifiedColumns[] = ImageTableMap::CONTENT_ID;
+ }
+
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
+
+ return $this;
+ } // setContentId()
+
+ /**
+ * Set the value of [file] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Image The current object (for fluent API support)
+ */
+ public function setFile($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->file !== $v) {
+ $this->file = $v;
+ $this->modifiedColumns[] = ImageTableMap::FILE;
+ }
+
+
+ return $this;
+ } // setFile()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Image The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = ImageTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Image The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = ImageTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Image The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = ImageTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ImageTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ImageTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->product_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ImageTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->category_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ImageTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->folder_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ImageTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->content_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ImageTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->file = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ImageTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ImageTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ImageTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 9; // 9 = ImageTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Image object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) {
+ $this->aFolder = null;
+ }
+ if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) {
+ $this->aContent = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ImageTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildImageQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aContent = null;
+ $this->aFolder = null;
+ $this->collImageI18ns = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Image::setDeleted()
+ * @see Image::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildImageQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(ImageTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(ImageTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(ImageTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ImageTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->aContent !== null) {
+ if ($this->aContent->isModified() || $this->aContent->isNew()) {
+ $affectedRows += $this->aContent->save($con);
+ }
+ $this->setContent($this->aContent);
+ }
+
+ if ($this->aFolder !== null) {
+ if ($this->aFolder->isModified() || $this->aFolder->isNew()) {
+ $affectedRows += $this->aFolder->save($con);
+ }
+ $this->setFolder($this->aFolder);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->imageI18nsScheduledForDeletion !== null) {
+ if (!$this->imageI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ImageI18nQuery::create()
+ ->filterByPrimaryKeys($this->imageI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->imageI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collImageI18ns !== null) {
+ foreach ($this->collImageI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ImageTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ImageTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ImageTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ImageTableMap::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'PRODUCT_ID';
+ }
+ if ($this->isColumnModified(ImageTableMap::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CATEGORY_ID';
+ }
+ if ($this->isColumnModified(ImageTableMap::FOLDER_ID)) {
+ $modifiedColumns[':p' . $index++] = 'FOLDER_ID';
+ }
+ if ($this->isColumnModified(ImageTableMap::CONTENT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CONTENT_ID';
+ }
+ if ($this->isColumnModified(ImageTableMap::FILE)) {
+ $modifiedColumns[':p' . $index++] = 'FILE';
+ }
+ if ($this->isColumnModified(ImageTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(ImageTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(ImageTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO image (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'PRODUCT_ID':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case 'CATEGORY_ID':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ case 'FOLDER_ID':
+ $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT);
+ break;
+ case 'CONTENT_ID':
+ $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT);
+ break;
+ case 'FILE':
+ $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getProductId();
+ break;
+ case 2:
+ return $this->getCategoryId();
+ break;
+ case 3:
+ return $this->getFolderId();
+ break;
+ case 4:
+ return $this->getContentId();
+ break;
+ case 5:
+ return $this->getFile();
+ break;
+ case 6:
+ return $this->getPosition();
+ break;
+ case 7:
+ return $this->getCreatedAt();
+ break;
+ case 8:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Image'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Image'][$this->getPrimaryKey()] = true;
+ $keys = ImageTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getProductId(),
+ $keys[2] => $this->getCategoryId(),
+ $keys[3] => $this->getFolderId(),
+ $keys[4] => $this->getContentId(),
+ $keys[5] => $this->getFile(),
+ $keys[6] => $this->getPosition(),
+ $keys[7] => $this->getCreatedAt(),
+ $keys[8] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collImageI18ns) {
+ $result['ImageI18ns'] = $this->collImageI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ImageTableMap::translateFieldName($name, $type, TableMap::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->setProductId($value);
+ break;
+ case 2:
+ $this->setCategoryId($value);
+ break;
+ case 3:
+ $this->setFolderId($value);
+ break;
+ case 4:
+ $this->setContentId($value);
+ break;
+ case 5:
+ $this->setFile($value);
+ break;
+ case 6:
+ $this->setPosition($value);
+ break;
+ case 7:
+ $this->setCreatedAt($value);
+ break;
+ case 8:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ImageTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCategoryId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setFolderId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setContentId($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setFile($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setPosition($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
+ }
+
+ /**
+ * 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(ImageTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ImageTableMap::ID)) $criteria->add(ImageTableMap::ID, $this->id);
+ if ($this->isColumnModified(ImageTableMap::PRODUCT_ID)) $criteria->add(ImageTableMap::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(ImageTableMap::CATEGORY_ID)) $criteria->add(ImageTableMap::CATEGORY_ID, $this->category_id);
+ if ($this->isColumnModified(ImageTableMap::FOLDER_ID)) $criteria->add(ImageTableMap::FOLDER_ID, $this->folder_id);
+ if ($this->isColumnModified(ImageTableMap::CONTENT_ID)) $criteria->add(ImageTableMap::CONTENT_ID, $this->content_id);
+ if ($this->isColumnModified(ImageTableMap::FILE)) $criteria->add(ImageTableMap::FILE, $this->file);
+ if ($this->isColumnModified(ImageTableMap::POSITION)) $criteria->add(ImageTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(ImageTableMap::CREATED_AT)) $criteria->add(ImageTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ImageTableMap::UPDATED_AT)) $criteria->add(ImageTableMap::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(ImageTableMap::DATABASE_NAME);
+ $criteria->add(ImageTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Image (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setCategoryId($this->getCategoryId());
+ $copyObj->setFolderId($this->getFolderId());
+ $copyObj->setContentId($this->getContentId());
+ $copyObj->setFile($this->getFile());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getImageI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addImageI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Image 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildProduct object.
+ *
+ * @param ChildProduct $v
+ * @return \Thelia\Model\Image The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(ChildProduct $v = null)
+ {
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
+ }
+
+ $this->aProduct = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildProduct object, it will not be re-added.
+ if ($v !== null) {
+ $v->addImage($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildProduct object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildProduct The associated ChildProduct object.
+ * @throws PropelException
+ */
+ public function getProduct(ConnectionInterface $con = null)
+ {
+ if ($this->aProduct === null && ($this->product_id !== null)) {
+ $this->aProduct = ChildProductQuery::create()->findPk($this->product_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aProduct->addImages($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCategory object.
+ *
+ * @param ChildCategory $v
+ * @return \Thelia\Model\Image The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCategory(ChildCategory $v = null)
+ {
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
+ }
+
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCategory object, it will not be re-added.
+ if ($v !== null) {
+ $v->addImage($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCategory object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCategory The associated ChildCategory object.
+ * @throws PropelException
+ */
+ public function getCategory(ConnectionInterface $con = null)
+ {
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCategory->addImages($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Declares an association between this object and a ChildContent object.
+ *
+ * @param ChildContent $v
+ * @return \Thelia\Model\Image The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setContent(ChildContent $v = null)
+ {
+ if ($v === null) {
+ $this->setContentId(NULL);
+ } else {
+ $this->setContentId($v->getId());
+ }
+
+ $this->aContent = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildContent object, it will not be re-added.
+ if ($v !== null) {
+ $v->addImage($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildContent object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildContent The associated ChildContent object.
+ * @throws PropelException
+ */
+ public function getContent(ConnectionInterface $con = null)
+ {
+ if ($this->aContent === null && ($this->content_id !== null)) {
+ $this->aContent = ChildContentQuery::create()->findPk($this->content_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aContent->addImages($this);
+ */
+ }
+
+ return $this->aContent;
+ }
+
+ /**
+ * Declares an association between this object and a ChildFolder object.
+ *
+ * @param ChildFolder $v
+ * @return \Thelia\Model\Image The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFolder(ChildFolder $v = null)
+ {
+ if ($v === null) {
+ $this->setFolderId(NULL);
+ } else {
+ $this->setFolderId($v->getId());
+ }
+
+ $this->aFolder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildFolder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addImage($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildFolder object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildFolder The associated ChildFolder object.
+ * @throws PropelException
+ */
+ public function getFolder(ConnectionInterface $con = null)
+ {
+ if ($this->aFolder === null && ($this->folder_id !== null)) {
+ $this->aFolder = ChildFolderQuery::create()->findPk($this->folder_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aFolder->addImages($this);
+ */
+ }
+
+ return $this->aFolder;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('ImageI18n' == $relationName) {
+ return $this->initImageI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collImageI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addImageI18ns()
+ */
+ public function clearImageI18ns()
+ {
+ $this->collImageI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collImageI18ns collection loaded partially.
+ */
+ public function resetPartialImageI18ns($v = true)
+ {
+ $this->collImageI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collImageI18ns collection.
+ *
+ * By default this just sets the collImageI18ns collection to an empty array (like clearcollImageI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initImageI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collImageI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collImageI18ns = new ObjectCollection();
+ $this->collImageI18ns->setModel('\Thelia\Model\ImageI18n');
+ }
+
+ /**
+ * Gets an array of ChildImageI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildImage is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildImageI18n[] List of ChildImageI18n objects
+ * @throws PropelException
+ */
+ public function getImageI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collImageI18nsPartial && !$this->isNew();
+ if (null === $this->collImageI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collImageI18ns) {
+ // return empty collection
+ $this->initImageI18ns();
+ } else {
+ $collImageI18ns = ChildImageI18nQuery::create(null, $criteria)
+ ->filterByImage($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collImageI18nsPartial && count($collImageI18ns)) {
+ $this->initImageI18ns(false);
+
+ foreach ($collImageI18ns as $obj) {
+ if (false == $this->collImageI18ns->contains($obj)) {
+ $this->collImageI18ns->append($obj);
+ }
+ }
+
+ $this->collImageI18nsPartial = true;
+ }
+
+ $collImageI18ns->getInternalIterator()->rewind();
+
+ return $collImageI18ns;
+ }
+
+ if ($partial && $this->collImageI18ns) {
+ foreach ($this->collImageI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collImageI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collImageI18ns = $collImageI18ns;
+ $this->collImageI18nsPartial = false;
+ }
+ }
+
+ return $this->collImageI18ns;
+ }
+
+ /**
+ * Sets a collection of ImageI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $imageI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildImage The current object (for fluent API support)
+ */
+ public function setImageI18ns(Collection $imageI18ns, ConnectionInterface $con = null)
+ {
+ $imageI18nsToDelete = $this->getImageI18ns(new Criteria(), $con)->diff($imageI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->imageI18nsScheduledForDeletion = clone $imageI18nsToDelete;
+
+ foreach ($imageI18nsToDelete as $imageI18nRemoved) {
+ $imageI18nRemoved->setImage(null);
+ }
+
+ $this->collImageI18ns = null;
+ foreach ($imageI18ns as $imageI18n) {
+ $this->addImageI18n($imageI18n);
+ }
+
+ $this->collImageI18ns = $imageI18ns;
+ $this->collImageI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ImageI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ImageI18n objects.
+ * @throws PropelException
+ */
+ public function countImageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collImageI18nsPartial && !$this->isNew();
+ if (null === $this->collImageI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collImageI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getImageI18ns());
+ }
+
+ $query = ChildImageI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByImage($this)
+ ->count($con);
+ }
+
+ return count($this->collImageI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildImageI18n object to this object
+ * through the ChildImageI18n foreign key attribute.
+ *
+ * @param ChildImageI18n $l ChildImageI18n
+ * @return \Thelia\Model\Image The current object (for fluent API support)
+ */
+ public function addImageI18n(ChildImageI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collImageI18ns === null) {
+ $this->initImageI18ns();
+ $this->collImageI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collImageI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddImageI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ImageI18n $imageI18n The imageI18n object to add.
+ */
+ protected function doAddImageI18n($imageI18n)
+ {
+ $this->collImageI18ns[]= $imageI18n;
+ $imageI18n->setImage($this);
+ }
+
+ /**
+ * @param ImageI18n $imageI18n The imageI18n object to remove.
+ * @return ChildImage The current object (for fluent API support)
+ */
+ public function removeImageI18n($imageI18n)
+ {
+ if ($this->getImageI18ns()->contains($imageI18n)) {
+ $this->collImageI18ns->remove($this->collImageI18ns->search($imageI18n));
+ if (null === $this->imageI18nsScheduledForDeletion) {
+ $this->imageI18nsScheduledForDeletion = clone $this->collImageI18ns;
+ $this->imageI18nsScheduledForDeletion->clear();
+ }
+ $this->imageI18nsScheduledForDeletion[]= clone $imageI18n;
+ $imageI18n->setImage(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->product_id = null;
+ $this->category_id = null;
+ $this->folder_id = null;
+ $this->content_id = null;
+ $this->file = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collImageI18ns) {
+ foreach ($this->collImageI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collImageI18ns instanceof Collection) {
+ $this->collImageI18ns->clearIterator();
+ }
+ $this->collImageI18ns = null;
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aContent = null;
+ $this->aFolder = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ImageTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildImage The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = ImageTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildImage The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildImageI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collImageI18ns) {
+ foreach ($this->collImageI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildImageI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildImageI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addImageI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildImage The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildImageI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collImageI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collImageI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildImageI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ImageI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ImageI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ImageI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ImageI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ImageI18n.php b/core/lib/Thelia/Model/Base/ImageI18n.php
new file mode 100644
index 000000000..324f939e9
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ImageI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\ImageI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another ImageI18n instance. If
+ * obj is an instance of ImageI18n, delegates to
+ * equals(ImageI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return ImageI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return ImageI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ImageI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ImageI18nTableMap::ID;
+ }
+
+ if ($this->aImage !== null && $this->aImage->getId() !== $v) {
+ $this->aImage = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ImageI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = ImageI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ImageI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = ImageI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ImageI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = ImageI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ImageI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = ImageI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ImageI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = ImageI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ImageI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ImageI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ImageI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ImageI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ImageI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ImageI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = ImageI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\ImageI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aImage !== null && $this->id !== $this->aImage->getId()) {
+ $this->aImage = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ImageI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildImageI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aImage = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see ImageI18n::setDeleted()
+ * @see ImageI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildImageI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ImageI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aImage !== null) {
+ if ($this->aImage->isModified() || $this->aImage->isNew()) {
+ $affectedRows += $this->aImage->save($con);
+ }
+ $this->setImage($this->aImage);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ImageI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ImageI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(ImageI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(ImageI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(ImageI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(ImageI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO image_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ImageI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ImageI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = ImageI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aImage) {
+ $result['Image'] = $this->aImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ImageI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ImageI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(ImageI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ImageI18nTableMap::ID)) $criteria->add(ImageI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(ImageI18nTableMap::LOCALE)) $criteria->add(ImageI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(ImageI18nTableMap::TITLE)) $criteria->add(ImageI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(ImageI18nTableMap::DESCRIPTION)) $criteria->add(ImageI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(ImageI18nTableMap::CHAPO)) $criteria->add(ImageI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(ImageI18nTableMap::POSTSCRIPTUM)) $criteria->add(ImageI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(ImageI18nTableMap::DATABASE_NAME);
+ $criteria->add(ImageI18nTableMap::ID, $this->id);
+ $criteria->add(ImageI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\ImageI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\ImageI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildImage object.
+ *
+ * @param ChildImage $v
+ * @return \Thelia\Model\ImageI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setImage(ChildImage $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aImage = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildImage object, it will not be re-added.
+ if ($v !== null) {
+ $v->addImageI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildImage object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildImage The associated ChildImage object.
+ * @throws PropelException
+ */
+ public function getImage(ConnectionInterface $con = null)
+ {
+ if ($this->aImage === null && ($this->id !== null)) {
+ $this->aImage = ChildImageQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aImage->addImageI18ns($this);
+ */
+ }
+
+ return $this->aImage;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aImage = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ImageI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ImageI18nQuery.php b/core/lib/Thelia/Model/Base/ImageI18nQuery.php
new file mode 100644
index 000000000..92fa1d878
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ImageI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildImageI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ImageI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ImageI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildImageI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM image_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildImageI18n();
+ $obj->hydrate($row);
+ ImageI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildImageI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildImageI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(ImageI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(ImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildImageI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(ImageI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(ImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByImage()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ImageI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ImageI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImageI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ImageI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ImageI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ImageI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ImageI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ImageI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Image object
+ *
+ * @param \Thelia\Model\Image|ObjectCollection $image The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageI18nQuery The current query, for fluid interface
+ */
+ public function filterByImage($image, $comparison = null)
+ {
+ if ($image instanceof \Thelia\Model\Image) {
+ return $this
+ ->addUsingAlias(ImageI18nTableMap::ID, $image->getId(), $comparison);
+ } elseif ($image instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ImageI18nTableMap::ID, $image->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Image relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildImageI18nQuery The current query, for fluid interface
+ */
+ public function joinImage($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Image');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Image');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Image relation Image object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
+ */
+ public function useImageQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinImage($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildImageI18n $imageI18n Object to remove from the list of results
+ *
+ * @return ChildImageI18nQuery The current query, for fluid interface
+ */
+ public function prune($imageI18n = null)
+ {
+ if ($imageI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(ImageI18nTableMap::ID), $imageI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(ImageI18nTableMap::LOCALE), $imageI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the image_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ImageI18nTableMap::clearInstancePool();
+ ImageI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildImageI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildImageI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ImageI18nTableMap::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->beginTransaction();
+
+
+ ImageI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ImageI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // ImageI18nQuery
diff --git a/core/lib/Thelia/Model/Base/ImageQuery.php b/core/lib/Thelia/Model/Base/ImageQuery.php
new file mode 100644
index 000000000..6e16a885b
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ImageQuery.php
@@ -0,0 +1,1224 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildImage|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ImageTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ImageTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildImage A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, PRODUCT_ID, CATEGORY_ID, FOLDER_ID, CONTENT_ID, FILE, POSITION, CREATED_AT, UPDATED_AT FROM image WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildImage();
+ $obj->hydrate($row);
+ ImageTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildImage|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ImageTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ImageTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ImageTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ImageTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImageTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(ImageTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(ImageTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImageTableMap::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId)) {
+ $useMinMax = false;
+ if (isset($categoryId['min'])) {
+ $this->addUsingAlias(ImageTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($categoryId['max'])) {
+ $this->addUsingAlias(ImageTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImageTableMap::CATEGORY_ID, $categoryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the folder_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFolderId(1234); // WHERE folder_id = 1234
+ * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34)
+ * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12
+ *
+ *
+ * @see filterByFolder()
+ *
+ * @param mixed $folderId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByFolderId($folderId = null, $comparison = null)
+ {
+ if (is_array($folderId)) {
+ $useMinMax = false;
+ if (isset($folderId['min'])) {
+ $this->addUsingAlias(ImageTableMap::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($folderId['max'])) {
+ $this->addUsingAlias(ImageTableMap::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImageTableMap::FOLDER_ID, $folderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the content_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByContentId(1234); // WHERE content_id = 1234
+ * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34)
+ * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
+ *
+ *
+ * @see filterByContent()
+ *
+ * @param mixed $contentId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByContentId($contentId = null, $comparison = null)
+ {
+ if (is_array($contentId)) {
+ $useMinMax = false;
+ if (isset($contentId['min'])) {
+ $this->addUsingAlias(ImageTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($contentId['max'])) {
+ $this->addUsingAlias(ImageTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImageTableMap::CONTENT_ID, $contentId, $comparison);
+ }
+
+ /**
+ * Filter the query on the file column
+ *
+ * Example usage:
+ *
+ * $query->filterByFile('fooValue'); // WHERE file = 'fooValue'
+ * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%'
+ *
+ *
+ * @param string $file The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByFile($file = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($file)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $file)) {
+ $file = str_replace('*', '%', $file);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ImageTableMap::FILE, $file, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(ImageTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(ImageTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImageTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ImageTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ImageTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImageTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ImageTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ImageTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ImageTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Product object
+ *
+ * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByProduct($product, $comparison = null)
+ {
+ if ($product instanceof \Thelia\Model\Product) {
+ return $this
+ ->addUsingAlias(ImageTableMap::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ImageTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Product relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Product');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Product');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Product relation Product object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
+ */
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Category object
+ *
+ * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByCategory($category, $comparison = null)
+ {
+ if ($category instanceof \Thelia\Model\Category) {
+ return $this
+ ->addUsingAlias(ImageTableMap::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ImageTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Category relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Category');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Category');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Category relation Category object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Content object
+ *
+ * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByContent($content, $comparison = null)
+ {
+ if ($content instanceof \Thelia\Model\Content) {
+ return $this
+ ->addUsingAlias(ImageTableMap::CONTENT_ID, $content->getId(), $comparison);
+ } elseif ($content instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ImageTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Content relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Content');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Content');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Content relation Content object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query
+ */
+ public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinContent($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Folder object
+ *
+ * @param \Thelia\Model\Folder|ObjectCollection $folder The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByFolder($folder, $comparison = null)
+ {
+ if ($folder instanceof \Thelia\Model\Folder) {
+ return $this
+ ->addUsingAlias(ImageTableMap::FOLDER_ID, $folder->getId(), $comparison);
+ } elseif ($folder instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ImageTableMap::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Folder relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Folder');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Folder');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Folder relation Folder object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query
+ */
+ public function useFolderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinFolder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ImageI18n object
+ *
+ * @param \Thelia\Model\ImageI18n|ObjectCollection $imageI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function filterByImageI18n($imageI18n, $comparison = null)
+ {
+ if ($imageI18n instanceof \Thelia\Model\ImageI18n) {
+ return $this
+ ->addUsingAlias(ImageTableMap::ID, $imageI18n->getId(), $comparison);
+ } elseif ($imageI18n instanceof ObjectCollection) {
+ return $this
+ ->useImageI18nQuery()
+ ->filterByPrimaryKeys($imageI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByImageI18n() only accepts arguments of type \Thelia\Model\ImageI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ImageI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function joinImageI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ImageI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ImageI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ImageI18n relation ImageI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ImageI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useImageI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinImageI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ImageI18n', '\Thelia\Model\ImageI18nQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildImage $image Object to remove from the list of results
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function prune($image = null)
+ {
+ if ($image) {
+ $this->addUsingAlias(ImageTableMap::ID, $image->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the image table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ImageTableMap::clearInstancePool();
+ ImageTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildImage or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildImage object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ImageTableMap::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->beginTransaction();
+
+
+ ImageTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ImageTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ImageTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ImageTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ImageTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ImageTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ImageTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ImageTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'ImageI18n';
+
+ return $this
+ ->joinImageI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildImageQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('ImageI18n');
+ $this->with['ImageI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildImageI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ImageI18n', '\Thelia\Model\ImageI18nQuery');
+ }
+
+} // ImageQuery
diff --git a/core/lib/Thelia/Model/Base/Lang.php b/core/lib/Thelia/Model/Base/Lang.php
new file mode 100644
index 000000000..694f86bc5
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Lang.php
@@ -0,0 +1,1507 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Lang instance. If
+ * obj is an instance of Lang, delegates to
+ * equals(Lang). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Lang The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Lang The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [url] column value.
+ *
+ * @return string
+ */
+ public function getUrl()
+ {
+
+ return $this->url;
+ }
+
+ /**
+ * Get the [by_default] column value.
+ *
+ * @return int
+ */
+ public function getByDefault()
+ {
+
+ return $this->by_default;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Lang The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = LangTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Lang The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = LangTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Lang The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = LangTableMap::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Lang The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = LangTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [url] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Lang The current object (for fluent API support)
+ */
+ public function setUrl($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->url !== $v) {
+ $this->url = $v;
+ $this->modifiedColumns[] = LangTableMap::URL;
+ }
+
+
+ return $this;
+ } // setUrl()
+
+ /**
+ * Set the value of [by_default] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Lang The current object (for fluent API support)
+ */
+ public function setByDefault($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->by_default !== $v) {
+ $this->by_default = $v;
+ $this->modifiedColumns[] = LangTableMap::BY_DEFAULT;
+ }
+
+
+ return $this;
+ } // setByDefault()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Lang The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = LangTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Lang The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = LangTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : LangTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : LangTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : LangTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->code = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : LangTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : LangTableMap::translateFieldName('Url', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->url = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : LangTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->by_default = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : LangTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : LangTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = LangTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Lang object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(LangTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildLangQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Lang::setDeleted()
+ * @see Lang::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(LangTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildLangQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(LangTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(LangTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(LangTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(LangTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ LangTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = LangTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . LangTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(LangTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(LangTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(LangTableMap::CODE)) {
+ $modifiedColumns[':p' . $index++] = 'CODE';
+ }
+ if ($this->isColumnModified(LangTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(LangTableMap::URL)) {
+ $modifiedColumns[':p' . $index++] = 'URL';
+ }
+ if ($this->isColumnModified(LangTableMap::BY_DEFAULT)) {
+ $modifiedColumns[':p' . $index++] = 'BY_DEFAULT';
+ }
+ if ($this->isColumnModified(LangTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(LangTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO lang (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'CODE':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'URL':
+ $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR);
+ break;
+ case 'BY_DEFAULT':
+ $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = LangTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getTitle();
+ break;
+ case 2:
+ return $this->getCode();
+ break;
+ case 3:
+ return $this->getLocale();
+ break;
+ case 4:
+ return $this->getUrl();
+ break;
+ case 5:
+ return $this->getByDefault();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array())
+ {
+ if (isset($alreadyDumpedObjects['Lang'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Lang'][$this->getPrimaryKey()] = true;
+ $keys = LangTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getTitle(),
+ $keys[2] => $this->getCode(),
+ $keys[3] => $this->getLocale(),
+ $keys[4] => $this->getUrl(),
+ $keys[5] => $this->getByDefault(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = LangTableMap::translateFieldName($name, $type, TableMap::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->setTitle($value);
+ break;
+ case 2:
+ $this->setCode($value);
+ break;
+ case 3:
+ $this->setLocale($value);
+ break;
+ case 4:
+ $this->setUrl($value);
+ break;
+ case 5:
+ $this->setByDefault($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = LangTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setTitle($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCode($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setLocale($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setUrl($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setByDefault($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * 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(LangTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(LangTableMap::ID)) $criteria->add(LangTableMap::ID, $this->id);
+ if ($this->isColumnModified(LangTableMap::TITLE)) $criteria->add(LangTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(LangTableMap::CODE)) $criteria->add(LangTableMap::CODE, $this->code);
+ if ($this->isColumnModified(LangTableMap::LOCALE)) $criteria->add(LangTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(LangTableMap::URL)) $criteria->add(LangTableMap::URL, $this->url);
+ if ($this->isColumnModified(LangTableMap::BY_DEFAULT)) $criteria->add(LangTableMap::BY_DEFAULT, $this->by_default);
+ if ($this->isColumnModified(LangTableMap::CREATED_AT)) $criteria->add(LangTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(LangTableMap::UPDATED_AT)) $criteria->add(LangTableMap::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(LangTableMap::DATABASE_NAME);
+ $criteria->add(LangTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Lang (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setCode($this->getCode());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setUrl($this->getUrl());
+ $copyObj->setByDefault($this->getByDefault());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Lang 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;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->title = null;
+ $this->code = null;
+ $this->locale = null;
+ $this->url = null;
+ $this->by_default = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(LangTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildLang The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = LangTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/LangQuery.php b/core/lib/Thelia/Model/Base/LangQuery.php
new file mode 100644
index 000000000..1a99ff28a
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/LangQuery.php
@@ -0,0 +1,681 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildLang|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = LangTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(LangTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildLang A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, TITLE, CODE, LOCALE, URL, BY_DEFAULT, CREATED_AT, UPDATED_AT FROM lang WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildLang();
+ $obj->hydrate($row);
+ LangTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildLang|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(LangTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(LangTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(LangTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(LangTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(LangTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(LangTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(LangTableMap::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(LangTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the url column
+ *
+ * Example usage:
+ *
+ * $query->filterByUrl('fooValue'); // WHERE url = 'fooValue'
+ * $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%'
+ *
+ *
+ * @param string $url The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function filterByUrl($url = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($url)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $url)) {
+ $url = str_replace('*', '%', $url);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(LangTableMap::URL, $url, $comparison);
+ }
+
+ /**
+ * Filter the query on the by_default column
+ *
+ * Example usage:
+ *
+ * $query->filterByByDefault(1234); // WHERE by_default = 1234
+ * $query->filterByByDefault(array(12, 34)); // WHERE by_default IN (12, 34)
+ * $query->filterByByDefault(array('min' => 12)); // WHERE by_default > 12
+ *
+ *
+ * @param mixed $byDefault The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function filterByByDefault($byDefault = null, $comparison = null)
+ {
+ if (is_array($byDefault)) {
+ $useMinMax = false;
+ if (isset($byDefault['min'])) {
+ $this->addUsingAlias(LangTableMap::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($byDefault['max'])) {
+ $this->addUsingAlias(LangTableMap::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(LangTableMap::BY_DEFAULT, $byDefault, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(LangTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(LangTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(LangTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(LangTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(LangTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(LangTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildLang $lang Object to remove from the list of results
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function prune($lang = null)
+ {
+ if ($lang) {
+ $this->addUsingAlias(LangTableMap::ID, $lang->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the lang table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(LangTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ LangTableMap::clearInstancePool();
+ LangTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildLang or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildLang object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(LangTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(LangTableMap::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->beginTransaction();
+
+
+ LangTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ LangTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(LangTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(LangTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(LangTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(LangTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(LangTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildLangQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(LangTableMap::CREATED_AT);
+ }
+
+} // LangQuery
diff --git a/core/lib/Thelia/Model/Base/Message.php b/core/lib/Thelia/Model/Base/Message.php
new file mode 100644
index 000000000..f39e4ecbe
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Message.php
@@ -0,0 +1,2669 @@
+version = 0;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\Message object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Message instance. If
+ * obj is an instance of Message, delegates to
+ * equals(Message). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Message The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Message The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * Get the [secured] column value.
+ *
+ * @return int
+ */
+ public function getSecured()
+ {
+
+ return $this->secured;
+ }
+
+ /**
+ * Get the [ref] column value.
+ *
+ * @return string
+ */
+ public function getRef()
+ {
+
+ return $this->ref;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getVersionCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->version_created_at;
+ } else {
+ return $this->version_created_at !== null ? $this->version_created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Message The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = MessageTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Message The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = MessageTableMap::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [secured] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Message The current object (for fluent API support)
+ */
+ public function setSecured($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->secured !== $v) {
+ $this->secured = $v;
+ $this->modifiedColumns[] = MessageTableMap::SECURED;
+ }
+
+
+ return $this;
+ } // setSecured()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Message The current object (for fluent API support)
+ */
+ public function setRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->ref !== $v) {
+ $this->ref = $v;
+ $this->modifiedColumns[] = MessageTableMap::REF;
+ }
+
+
+ return $this;
+ } // setRef()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Message The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = MessageTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Message The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = MessageTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Message The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = MessageTableMap::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Message The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ if ($dt !== $this->version_created_at) {
+ $this->version_created_at = $dt;
+ $this->modifiedColumns[] = MessageTableMap::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Message The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = MessageTableMap::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->version !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : MessageTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : MessageTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->code = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : MessageTableMap::translateFieldName('Secured', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->secured = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : MessageTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->ref = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : MessageTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : MessageTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : MessageTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : MessageTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : MessageTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version_created_by = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 9; // 9 = MessageTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Message object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(MessageTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildMessageQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collMessageI18ns = null;
+
+ $this->collMessageVersions = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Message::setDeleted()
+ * @see Message::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildMessageQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ // versionable behavior
+ if ($this->isVersioningNecessary()) {
+ $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
+ if (!$this->isColumnModified(MessageTableMap::VERSION_CREATED_AT)) {
+ $this->setVersionCreatedAt(time());
+ }
+ $createVersion = true; // for postSave hook
+ }
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(MessageTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(MessageTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(MessageTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ // versionable behavior
+ if (isset($createVersion)) {
+ $this->addVersion($con);
+ }
+ MessageTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->messageI18nsScheduledForDeletion !== null) {
+ if (!$this->messageI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\MessageI18nQuery::create()
+ ->filterByPrimaryKeys($this->messageI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->messageI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collMessageI18ns !== null) {
+ foreach ($this->collMessageI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->messageVersionsScheduledForDeletion !== null) {
+ if (!$this->messageVersionsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\MessageVersionQuery::create()
+ ->filterByPrimaryKeys($this->messageVersionsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->messageVersionsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collMessageVersions !== null) {
+ foreach ($this->collMessageVersions as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = MessageTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . MessageTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(MessageTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(MessageTableMap::CODE)) {
+ $modifiedColumns[':p' . $index++] = 'CODE';
+ }
+ if ($this->isColumnModified(MessageTableMap::SECURED)) {
+ $modifiedColumns[':p' . $index++] = 'SECURED';
+ }
+ if ($this->isColumnModified(MessageTableMap::REF)) {
+ $modifiedColumns[':p' . $index++] = 'REF';
+ }
+ if ($this->isColumnModified(MessageTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(MessageTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+ if ($this->isColumnModified(MessageTableMap::VERSION)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION';
+ }
+ if ($this->isColumnModified(MessageTableMap::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT';
+ }
+ if ($this->isColumnModified(MessageTableMap::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO message (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'CODE':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case 'SECURED':
+ $stmt->bindValue($identifier, $this->secured, PDO::PARAM_INT);
+ break;
+ case 'REF':
+ $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case 'VERSION_CREATED_AT':
+ $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION_CREATED_BY':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = MessageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getCode();
+ break;
+ case 2:
+ return $this->getSecured();
+ break;
+ case 3:
+ return $this->getRef();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ return $this->getUpdatedAt();
+ break;
+ case 6:
+ return $this->getVersion();
+ break;
+ case 7:
+ return $this->getVersionCreatedAt();
+ break;
+ case 8:
+ return $this->getVersionCreatedBy();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Message'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Message'][$this->getPrimaryKey()] = true;
+ $keys = MessageTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getSecured(),
+ $keys[3] => $this->getRef(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ $keys[6] => $this->getVersion(),
+ $keys[7] => $this->getVersionCreatedAt(),
+ $keys[8] => $this->getVersionCreatedBy(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collMessageI18ns) {
+ $result['MessageI18ns'] = $this->collMessageI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collMessageVersions) {
+ $result['MessageVersions'] = $this->collMessageVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = MessageTableMap::translateFieldName($name, $type, TableMap::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->setCode($value);
+ break;
+ case 2:
+ $this->setSecured($value);
+ break;
+ case 3:
+ $this->setRef($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $this->setUpdatedAt($value);
+ break;
+ case 6:
+ $this->setVersion($value);
+ break;
+ case 7:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 8:
+ $this->setVersionCreatedBy($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = MessageTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setSecured($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setRef($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setVersion($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersionCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedBy($arr[$keys[8]]);
+ }
+
+ /**
+ * 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(MessageTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(MessageTableMap::ID)) $criteria->add(MessageTableMap::ID, $this->id);
+ if ($this->isColumnModified(MessageTableMap::CODE)) $criteria->add(MessageTableMap::CODE, $this->code);
+ if ($this->isColumnModified(MessageTableMap::SECURED)) $criteria->add(MessageTableMap::SECURED, $this->secured);
+ if ($this->isColumnModified(MessageTableMap::REF)) $criteria->add(MessageTableMap::REF, $this->ref);
+ if ($this->isColumnModified(MessageTableMap::CREATED_AT)) $criteria->add(MessageTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(MessageTableMap::UPDATED_AT)) $criteria->add(MessageTableMap::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(MessageTableMap::VERSION)) $criteria->add(MessageTableMap::VERSION, $this->version);
+ if ($this->isColumnModified(MessageTableMap::VERSION_CREATED_AT)) $criteria->add(MessageTableMap::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(MessageTableMap::VERSION_CREATED_BY)) $criteria->add(MessageTableMap::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(MessageTableMap::DATABASE_NAME);
+ $criteria->add(MessageTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Message (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setSecured($this->getSecured());
+ $copyObj->setRef($this->getRef());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+
+ 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->getMessageI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addMessageI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getMessageVersions() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addMessageVersion($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Message 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('MessageI18n' == $relationName) {
+ return $this->initMessageI18ns();
+ }
+ if ('MessageVersion' == $relationName) {
+ return $this->initMessageVersions();
+ }
+ }
+
+ /**
+ * Clears out the collMessageI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addMessageI18ns()
+ */
+ public function clearMessageI18ns()
+ {
+ $this->collMessageI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collMessageI18ns collection loaded partially.
+ */
+ public function resetPartialMessageI18ns($v = true)
+ {
+ $this->collMessageI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collMessageI18ns collection.
+ *
+ * By default this just sets the collMessageI18ns collection to an empty array (like clearcollMessageI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initMessageI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collMessageI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collMessageI18ns = new ObjectCollection();
+ $this->collMessageI18ns->setModel('\Thelia\Model\MessageI18n');
+ }
+
+ /**
+ * Gets an array of ChildMessageI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildMessage is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildMessageI18n[] List of ChildMessageI18n objects
+ * @throws PropelException
+ */
+ public function getMessageI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collMessageI18nsPartial && !$this->isNew();
+ if (null === $this->collMessageI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collMessageI18ns) {
+ // return empty collection
+ $this->initMessageI18ns();
+ } else {
+ $collMessageI18ns = ChildMessageI18nQuery::create(null, $criteria)
+ ->filterByMessage($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collMessageI18nsPartial && count($collMessageI18ns)) {
+ $this->initMessageI18ns(false);
+
+ foreach ($collMessageI18ns as $obj) {
+ if (false == $this->collMessageI18ns->contains($obj)) {
+ $this->collMessageI18ns->append($obj);
+ }
+ }
+
+ $this->collMessageI18nsPartial = true;
+ }
+
+ $collMessageI18ns->getInternalIterator()->rewind();
+
+ return $collMessageI18ns;
+ }
+
+ if ($partial && $this->collMessageI18ns) {
+ foreach ($this->collMessageI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collMessageI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collMessageI18ns = $collMessageI18ns;
+ $this->collMessageI18nsPartial = false;
+ }
+ }
+
+ return $this->collMessageI18ns;
+ }
+
+ /**
+ * Sets a collection of MessageI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $messageI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildMessage The current object (for fluent API support)
+ */
+ public function setMessageI18ns(Collection $messageI18ns, ConnectionInterface $con = null)
+ {
+ $messageI18nsToDelete = $this->getMessageI18ns(new Criteria(), $con)->diff($messageI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->messageI18nsScheduledForDeletion = clone $messageI18nsToDelete;
+
+ foreach ($messageI18nsToDelete as $messageI18nRemoved) {
+ $messageI18nRemoved->setMessage(null);
+ }
+
+ $this->collMessageI18ns = null;
+ foreach ($messageI18ns as $messageI18n) {
+ $this->addMessageI18n($messageI18n);
+ }
+
+ $this->collMessageI18ns = $messageI18ns;
+ $this->collMessageI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related MessageI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related MessageI18n objects.
+ * @throws PropelException
+ */
+ public function countMessageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collMessageI18nsPartial && !$this->isNew();
+ if (null === $this->collMessageI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collMessageI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getMessageI18ns());
+ }
+
+ $query = ChildMessageI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByMessage($this)
+ ->count($con);
+ }
+
+ return count($this->collMessageI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildMessageI18n object to this object
+ * through the ChildMessageI18n foreign key attribute.
+ *
+ * @param ChildMessageI18n $l ChildMessageI18n
+ * @return \Thelia\Model\Message The current object (for fluent API support)
+ */
+ public function addMessageI18n(ChildMessageI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collMessageI18ns === null) {
+ $this->initMessageI18ns();
+ $this->collMessageI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collMessageI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddMessageI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param MessageI18n $messageI18n The messageI18n object to add.
+ */
+ protected function doAddMessageI18n($messageI18n)
+ {
+ $this->collMessageI18ns[]= $messageI18n;
+ $messageI18n->setMessage($this);
+ }
+
+ /**
+ * @param MessageI18n $messageI18n The messageI18n object to remove.
+ * @return ChildMessage The current object (for fluent API support)
+ */
+ public function removeMessageI18n($messageI18n)
+ {
+ if ($this->getMessageI18ns()->contains($messageI18n)) {
+ $this->collMessageI18ns->remove($this->collMessageI18ns->search($messageI18n));
+ if (null === $this->messageI18nsScheduledForDeletion) {
+ $this->messageI18nsScheduledForDeletion = clone $this->collMessageI18ns;
+ $this->messageI18nsScheduledForDeletion->clear();
+ }
+ $this->messageI18nsScheduledForDeletion[]= clone $messageI18n;
+ $messageI18n->setMessage(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collMessageVersions collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addMessageVersions()
+ */
+ public function clearMessageVersions()
+ {
+ $this->collMessageVersions = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collMessageVersions collection loaded partially.
+ */
+ public function resetPartialMessageVersions($v = true)
+ {
+ $this->collMessageVersionsPartial = $v;
+ }
+
+ /**
+ * Initializes the collMessageVersions collection.
+ *
+ * By default this just sets the collMessageVersions collection to an empty array (like clearcollMessageVersions());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initMessageVersions($overrideExisting = true)
+ {
+ if (null !== $this->collMessageVersions && !$overrideExisting) {
+ return;
+ }
+ $this->collMessageVersions = new ObjectCollection();
+ $this->collMessageVersions->setModel('\Thelia\Model\MessageVersion');
+ }
+
+ /**
+ * Gets an array of ChildMessageVersion objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildMessage is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildMessageVersion[] List of ChildMessageVersion objects
+ * @throws PropelException
+ */
+ public function getMessageVersions($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collMessageVersionsPartial && !$this->isNew();
+ if (null === $this->collMessageVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collMessageVersions) {
+ // return empty collection
+ $this->initMessageVersions();
+ } else {
+ $collMessageVersions = ChildMessageVersionQuery::create(null, $criteria)
+ ->filterByMessage($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collMessageVersionsPartial && count($collMessageVersions)) {
+ $this->initMessageVersions(false);
+
+ foreach ($collMessageVersions as $obj) {
+ if (false == $this->collMessageVersions->contains($obj)) {
+ $this->collMessageVersions->append($obj);
+ }
+ }
+
+ $this->collMessageVersionsPartial = true;
+ }
+
+ $collMessageVersions->getInternalIterator()->rewind();
+
+ return $collMessageVersions;
+ }
+
+ if ($partial && $this->collMessageVersions) {
+ foreach ($this->collMessageVersions as $obj) {
+ if ($obj->isNew()) {
+ $collMessageVersions[] = $obj;
+ }
+ }
+ }
+
+ $this->collMessageVersions = $collMessageVersions;
+ $this->collMessageVersionsPartial = false;
+ }
+ }
+
+ return $this->collMessageVersions;
+ }
+
+ /**
+ * Sets a collection of MessageVersion objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $messageVersions A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildMessage The current object (for fluent API support)
+ */
+ public function setMessageVersions(Collection $messageVersions, ConnectionInterface $con = null)
+ {
+ $messageVersionsToDelete = $this->getMessageVersions(new Criteria(), $con)->diff($messageVersions);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->messageVersionsScheduledForDeletion = clone $messageVersionsToDelete;
+
+ foreach ($messageVersionsToDelete as $messageVersionRemoved) {
+ $messageVersionRemoved->setMessage(null);
+ }
+
+ $this->collMessageVersions = null;
+ foreach ($messageVersions as $messageVersion) {
+ $this->addMessageVersion($messageVersion);
+ }
+
+ $this->collMessageVersions = $messageVersions;
+ $this->collMessageVersionsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related MessageVersion objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related MessageVersion objects.
+ * @throws PropelException
+ */
+ public function countMessageVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collMessageVersionsPartial && !$this->isNew();
+ if (null === $this->collMessageVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collMessageVersions) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getMessageVersions());
+ }
+
+ $query = ChildMessageVersionQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByMessage($this)
+ ->count($con);
+ }
+
+ return count($this->collMessageVersions);
+ }
+
+ /**
+ * Method called to associate a ChildMessageVersion object to this object
+ * through the ChildMessageVersion foreign key attribute.
+ *
+ * @param ChildMessageVersion $l ChildMessageVersion
+ * @return \Thelia\Model\Message The current object (for fluent API support)
+ */
+ public function addMessageVersion(ChildMessageVersion $l)
+ {
+ if ($this->collMessageVersions === null) {
+ $this->initMessageVersions();
+ $this->collMessageVersionsPartial = true;
+ }
+
+ if (!in_array($l, $this->collMessageVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddMessageVersion($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param MessageVersion $messageVersion The messageVersion object to add.
+ */
+ protected function doAddMessageVersion($messageVersion)
+ {
+ $this->collMessageVersions[]= $messageVersion;
+ $messageVersion->setMessage($this);
+ }
+
+ /**
+ * @param MessageVersion $messageVersion The messageVersion object to remove.
+ * @return ChildMessage The current object (for fluent API support)
+ */
+ public function removeMessageVersion($messageVersion)
+ {
+ if ($this->getMessageVersions()->contains($messageVersion)) {
+ $this->collMessageVersions->remove($this->collMessageVersions->search($messageVersion));
+ if (null === $this->messageVersionsScheduledForDeletion) {
+ $this->messageVersionsScheduledForDeletion = clone $this->collMessageVersions;
+ $this->messageVersionsScheduledForDeletion->clear();
+ }
+ $this->messageVersionsScheduledForDeletion[]= clone $messageVersion;
+ $messageVersion->setMessage(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->secured = null;
+ $this->ref = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collMessageI18ns) {
+ foreach ($this->collMessageI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collMessageVersions) {
+ foreach ($this->collMessageVersions as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collMessageI18ns instanceof Collection) {
+ $this->collMessageI18ns->clearIterator();
+ }
+ $this->collMessageI18ns = null;
+ if ($this->collMessageVersions instanceof Collection) {
+ $this->collMessageVersions->clearIterator();
+ }
+ $this->collMessageVersions = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(MessageTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildMessage The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = MessageTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildMessage The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildMessageI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collMessageI18ns) {
+ foreach ($this->collMessageI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildMessageI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildMessageI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addMessageI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildMessage The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildMessageI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collMessageI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collMessageI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildMessageI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\MessageI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\MessageI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description_html] column value.
+ *
+ * @return string
+ */
+ public function getDescriptionHtml()
+ {
+ return $this->getCurrentTranslation()->getDescriptionHtml();
+ }
+
+
+ /**
+ * Set the value of [description_html] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\MessageI18n The current object (for fluent API support)
+ */
+ public function setDescriptionHtml($v)
+ { $this->getCurrentTranslation()->setDescriptionHtml($v);
+
+ return $this;
+ }
+
+ // versionable behavior
+
+ /**
+ * Enforce a new Version of this object upon next save.
+ *
+ * @return \Thelia\Model\Message
+ */
+ public function enforceVersioning()
+ {
+ $this->enforceVersion = true;
+
+ return $this;
+ }
+
+ /**
+ * Checks whether the current state must be recorded as a version
+ *
+ * @return boolean
+ */
+ public function isVersioningNecessary($con = null)
+ {
+ if ($this->alreadyInSave) {
+ return false;
+ }
+
+ if ($this->enforceVersion) {
+ return true;
+ }
+
+ if (ChildMessageQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Creates a version of the current object and saves it.
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ChildMessageVersion A version object
+ */
+ public function addVersion($con = null)
+ {
+ $this->enforceVersion = false;
+
+ $version = new ChildMessageVersion();
+ $version->setId($this->getId());
+ $version->setCode($this->getCode());
+ $version->setSecured($this->getSecured());
+ $version->setRef($this->getRef());
+ $version->setCreatedAt($this->getCreatedAt());
+ $version->setUpdatedAt($this->getUpdatedAt());
+ $version->setVersion($this->getVersion());
+ $version->setVersionCreatedAt($this->getVersionCreatedAt());
+ $version->setVersionCreatedBy($this->getVersionCreatedBy());
+ $version->setMessage($this);
+ $version->save($con);
+
+ return $version;
+ }
+
+ /**
+ * Sets the properties of the current object to the value they had at a specific version
+ *
+ * @param integer $versionNumber The version number to read
+ * @param ConnectionInterface $con The connection to use
+ *
+ * @return ChildMessage The current object (for fluent API support)
+ */
+ public function toVersion($versionNumber, $con = null)
+ {
+ $version = $this->getOneVersion($versionNumber, $con);
+ if (!$version) {
+ throw new PropelException(sprintf('No ChildMessage object found with version %d', $version));
+ }
+ $this->populateFromVersion($version, $con);
+
+ return $this;
+ }
+
+ /**
+ * Sets the properties of the current object to the value they had at a specific version
+ *
+ * @param ChildMessageVersion $version The version object to use
+ * @param ConnectionInterface $con the connection to use
+ * @param array $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects.
+ *
+ * @return ChildMessage The current object (for fluent API support)
+ */
+ public function populateFromVersion($version, $con = null, &$loadedObjects = array())
+ {
+ $loadedObjects['ChildMessage'][$version->getId()][$version->getVersion()] = $this;
+ $this->setId($version->getId());
+ $this->setCode($version->getCode());
+ $this->setSecured($version->getSecured());
+ $this->setRef($version->getRef());
+ $this->setCreatedAt($version->getCreatedAt());
+ $this->setUpdatedAt($version->getUpdatedAt());
+ $this->setVersion($version->getVersion());
+ $this->setVersionCreatedAt($version->getVersionCreatedAt());
+ $this->setVersionCreatedBy($version->getVersionCreatedBy());
+
+ return $this;
+ }
+
+ /**
+ * Gets the latest persisted version number for the current object
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return integer
+ */
+ public function getLastVersionNumber($con = null)
+ {
+ $v = ChildMessageVersionQuery::create()
+ ->filterByMessage($this)
+ ->orderByVersion('desc')
+ ->findOne($con);
+ if (!$v) {
+ return 0;
+ }
+
+ return $v->getVersion();
+ }
+
+ /**
+ * Checks whether the current object is the latest one
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return Boolean
+ */
+ public function isLastVersion($con = null)
+ {
+ return $this->getLastVersionNumber($con) == $this->getVersion();
+ }
+
+ /**
+ * Retrieves a version object for this entity and a version number
+ *
+ * @param integer $versionNumber The version number to read
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ChildMessageVersion A version object
+ */
+ public function getOneVersion($versionNumber, $con = null)
+ {
+ return ChildMessageVersionQuery::create()
+ ->filterByMessage($this)
+ ->filterByVersion($versionNumber)
+ ->findOne($con);
+ }
+
+ /**
+ * Gets all the versions of this object, in incremental order
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ObjectCollection A list of ChildMessageVersion objects
+ */
+ public function getAllVersions($con = null)
+ {
+ $criteria = new Criteria();
+ $criteria->addAscendingOrderByColumn(MessageVersionTableMap::VERSION);
+
+ return $this->getMessageVersions($criteria, $con);
+ }
+
+ /**
+ * Compares the current object with another of its version.
+ *
+ * print_r($book->compareVersion(1));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $versionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param ConnectionInterface $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->toArray();
+ $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Compares two versions of the current object.
+ *
+ * print_r($book->compareVersions(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $fromVersionNumber
+ * @param integer $toVersionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param ConnectionInterface $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
+ $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Computes the diff between two versions.
+ *
+ * print_r($book->computeDiff(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param array $fromVersion An array representing the original version.
+ * @param array $toVersion An array representing the destination version.
+ * @param string $keys Main key used for the result diff (versions|columns).
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
+ {
+ $fromVersionNumber = $fromVersion['Version'];
+ $toVersionNumber = $toVersion['Version'];
+ $ignoredColumns = array_merge(array(
+ 'Version',
+ 'VersionCreatedAt',
+ 'VersionCreatedBy',
+ ), $ignoredColumns);
+ $diff = array();
+ foreach ($fromVersion as $key => $value) {
+ if (in_array($key, $ignoredColumns)) {
+ continue;
+ }
+ if ($toVersion[$key] != $value) {
+ switch ($keys) {
+ case 'versions':
+ $diff[$fromVersionNumber][$key] = $value;
+ $diff[$toVersionNumber][$key] = $toVersion[$key];
+ break;
+ default:
+ $diff[$key] = array(
+ $fromVersionNumber => $value,
+ $toVersionNumber => $toVersion[$key],
+ );
+ break;
+ }
+ }
+ }
+
+ return $diff;
+ }
+ /**
+ * retrieve the last $number versions.
+ *
+ * @param Integer $number the number of record to return.
+ * @return PropelCollection|array \Thelia\Model\MessageVersion[] List of \Thelia\Model\MessageVersion objects
+ */
+ public function getLastVersions($number = 10, $criteria = null, $con = null)
+ {
+ $criteria = ChildMessageVersionQuery::create(null, $criteria);
+ $criteria->addDescendingOrderByColumn(MessageVersionTableMap::VERSION);
+ $criteria->limit($number);
+
+ return $this->getMessageVersions($criteria, $con);
+ }
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/MessageI18n.php b/core/lib/Thelia/Model/Base/MessageI18n.php
new file mode 100644
index 000000000..545e75244
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/MessageI18n.php
@@ -0,0 +1,1381 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\MessageI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another MessageI18n instance. If
+ * obj is an instance of MessageI18n, delegates to
+ * equals(MessageI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return MessageI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return MessageI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [description_html] column value.
+ *
+ * @return string
+ */
+ public function getDescriptionHtml()
+ {
+
+ return $this->description_html;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\MessageI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = MessageI18nTableMap::ID;
+ }
+
+ if ($this->aMessage !== null && $this->aMessage->getId() !== $v) {
+ $this->aMessage = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\MessageI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = MessageI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\MessageI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = MessageI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\MessageI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = MessageI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [description_html] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\MessageI18n The current object (for fluent API support)
+ */
+ public function setDescriptionHtml($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description_html !== $v) {
+ $this->description_html = $v;
+ $this->modifiedColumns[] = MessageI18nTableMap::DESCRIPTION_HTML;
+ }
+
+
+ return $this;
+ } // setDescriptionHtml()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : MessageI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : MessageI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : MessageI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : MessageI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : MessageI18nTableMap::translateFieldName('DescriptionHtml', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description_html = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 5; // 5 = MessageI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\MessageI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aMessage !== null && $this->id !== $this->aMessage->getId()) {
+ $this->aMessage = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(MessageI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildMessageI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aMessage = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see MessageI18n::setDeleted()
+ * @see MessageI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildMessageI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ MessageI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aMessage !== null) {
+ if ($this->aMessage->isModified() || $this->aMessage->isNew()) {
+ $affectedRows += $this->aMessage->save($con);
+ }
+ $this->setMessage($this->aMessage);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(MessageI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(MessageI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(MessageI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(MessageI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(MessageI18nTableMap::DESCRIPTION_HTML)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION_HTML';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO message_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION_HTML':
+ $stmt->bindValue($identifier, $this->description_html, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = MessageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getDescriptionHtml();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['MessageI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['MessageI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = MessageI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getDescriptionHtml(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aMessage) {
+ $result['Message'] = $this->aMessage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = MessageI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setDescriptionHtml($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = MessageI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescriptionHtml($arr[$keys[4]]);
+ }
+
+ /**
+ * 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(MessageI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(MessageI18nTableMap::ID)) $criteria->add(MessageI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(MessageI18nTableMap::LOCALE)) $criteria->add(MessageI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(MessageI18nTableMap::TITLE)) $criteria->add(MessageI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(MessageI18nTableMap::DESCRIPTION)) $criteria->add(MessageI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(MessageI18nTableMap::DESCRIPTION_HTML)) $criteria->add(MessageI18nTableMap::DESCRIPTION_HTML, $this->description_html);
+
+ 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(MessageI18nTableMap::DATABASE_NAME);
+ $criteria->add(MessageI18nTableMap::ID, $this->id);
+ $criteria->add(MessageI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\MessageI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setDescriptionHtml($this->getDescriptionHtml());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\MessageI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildMessage object.
+ *
+ * @param ChildMessage $v
+ * @return \Thelia\Model\MessageI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setMessage(ChildMessage $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aMessage = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildMessage object, it will not be re-added.
+ if ($v !== null) {
+ $v->addMessageI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildMessage object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildMessage The associated ChildMessage object.
+ * @throws PropelException
+ */
+ public function getMessage(ConnectionInterface $con = null)
+ {
+ if ($this->aMessage === null && ($this->id !== null)) {
+ $this->aMessage = ChildMessageQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aMessage->addMessageI18ns($this);
+ */
+ }
+
+ return $this->aMessage;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->description_html = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aMessage = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(MessageI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/MessageI18nQuery.php b/core/lib/Thelia/Model/Base/MessageI18nQuery.php
new file mode 100644
index 000000000..478c737e8
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/MessageI18nQuery.php
@@ -0,0 +1,574 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildMessageI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = MessageI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(MessageI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildMessageI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, DESCRIPTION_HTML FROM message_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildMessageI18n();
+ $obj->hydrate($row);
+ MessageI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildMessageI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildMessageI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(MessageI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(MessageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildMessageI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(MessageI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(MessageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByMessage()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(MessageI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(MessageI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the description_html column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescriptionHtml('fooValue'); // WHERE description_html = 'fooValue'
+ * $query->filterByDescriptionHtml('%fooValue%'); // WHERE description_html LIKE '%fooValue%'
+ *
+ *
+ * @param string $descriptionHtml The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescriptionHtml($descriptionHtml = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($descriptionHtml)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $descriptionHtml)) {
+ $descriptionHtml = str_replace('*', '%', $descriptionHtml);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageI18nTableMap::DESCRIPTION_HTML, $descriptionHtml, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Message object
+ *
+ * @param \Thelia\Model\Message|ObjectCollection $message The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageI18nQuery The current query, for fluid interface
+ */
+ public function filterByMessage($message, $comparison = null)
+ {
+ if ($message instanceof \Thelia\Model\Message) {
+ return $this
+ ->addUsingAlias(MessageI18nTableMap::ID, $message->getId(), $comparison);
+ } elseif ($message instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(MessageI18nTableMap::ID, $message->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByMessage() only accepts arguments of type \Thelia\Model\Message or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Message relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildMessageI18nQuery The current query, for fluid interface
+ */
+ public function joinMessage($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Message');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Message');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Message relation Message object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\MessageQuery A secondary query class using the current class as primary query
+ */
+ public function useMessageQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinMessage($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Message', '\Thelia\Model\MessageQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildMessageI18n $messageI18n Object to remove from the list of results
+ *
+ * @return ChildMessageI18nQuery The current query, for fluid interface
+ */
+ public function prune($messageI18n = null)
+ {
+ if ($messageI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(MessageI18nTableMap::ID), $messageI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(MessageI18nTableMap::LOCALE), $messageI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the message_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ MessageI18nTableMap::clearInstancePool();
+ MessageI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildMessageI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildMessageI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(MessageI18nTableMap::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->beginTransaction();
+
+
+ MessageI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ MessageI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // MessageI18nQuery
diff --git a/core/lib/Thelia/Model/Base/MessageQuery.php b/core/lib/Thelia/Model/Base/MessageQuery.php
new file mode 100644
index 000000000..938a16aab
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/MessageQuery.php
@@ -0,0 +1,990 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildMessage|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = MessageTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(MessageTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildMessage A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CODE, SECURED, REF, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM message WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildMessage();
+ $obj->hydrate($row);
+ MessageTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildMessage|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(MessageTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(MessageTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(MessageTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(MessageTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageTableMap::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the secured column
+ *
+ * Example usage:
+ *
+ * $query->filterBySecured(1234); // WHERE secured = 1234
+ * $query->filterBySecured(array(12, 34)); // WHERE secured IN (12, 34)
+ * $query->filterBySecured(array('min' => 12)); // WHERE secured > 12
+ *
+ *
+ * @param mixed $secured The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function filterBySecured($secured = null, $comparison = null)
+ {
+ if (is_array($secured)) {
+ $useMinMax = false;
+ if (isset($secured['min'])) {
+ $this->addUsingAlias(MessageTableMap::SECURED, $secured['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($secured['max'])) {
+ $this->addUsingAlias(MessageTableMap::SECURED, $secured['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageTableMap::SECURED, $secured, $comparison);
+ }
+
+ /**
+ * Filter the query on the ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
+ * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $ref The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function filterByRef($ref = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($ref)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $ref)) {
+ $ref = str_replace('*', '%', $ref);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageTableMap::REF, $ref, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(MessageTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(MessageTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(MessageTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(MessageTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(MessageTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(MessageTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageTableMap::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(MessageTableMap::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(MessageTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\MessageI18n object
+ *
+ * @param \Thelia\Model\MessageI18n|ObjectCollection $messageI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function filterByMessageI18n($messageI18n, $comparison = null)
+ {
+ if ($messageI18n instanceof \Thelia\Model\MessageI18n) {
+ return $this
+ ->addUsingAlias(MessageTableMap::ID, $messageI18n->getId(), $comparison);
+ } elseif ($messageI18n instanceof ObjectCollection) {
+ return $this
+ ->useMessageI18nQuery()
+ ->filterByPrimaryKeys($messageI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByMessageI18n() only accepts arguments of type \Thelia\Model\MessageI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the MessageI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function joinMessageI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('MessageI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'MessageI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the MessageI18n relation MessageI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\MessageI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useMessageI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinMessageI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'MessageI18n', '\Thelia\Model\MessageI18nQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\MessageVersion object
+ *
+ * @param \Thelia\Model\MessageVersion|ObjectCollection $messageVersion the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function filterByMessageVersion($messageVersion, $comparison = null)
+ {
+ if ($messageVersion instanceof \Thelia\Model\MessageVersion) {
+ return $this
+ ->addUsingAlias(MessageTableMap::ID, $messageVersion->getId(), $comparison);
+ } elseif ($messageVersion instanceof ObjectCollection) {
+ return $this
+ ->useMessageVersionQuery()
+ ->filterByPrimaryKeys($messageVersion->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByMessageVersion() only accepts arguments of type \Thelia\Model\MessageVersion or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the MessageVersion relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function joinMessageVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('MessageVersion');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'MessageVersion');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the MessageVersion relation MessageVersion object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\MessageVersionQuery A secondary query class using the current class as primary query
+ */
+ public function useMessageVersionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinMessageVersion($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'MessageVersion', '\Thelia\Model\MessageVersionQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildMessage $message Object to remove from the list of results
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function prune($message = null)
+ {
+ if ($message) {
+ $this->addUsingAlias(MessageTableMap::ID, $message->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the message table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ MessageTableMap::clearInstancePool();
+ MessageTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildMessage or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildMessage object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(MessageTableMap::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->beginTransaction();
+
+
+ MessageTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ MessageTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(MessageTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(MessageTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(MessageTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(MessageTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(MessageTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(MessageTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'MessageI18n';
+
+ return $this
+ ->joinMessageI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildMessageQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('MessageI18n');
+ $this->with['MessageI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildMessageI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'MessageI18n', '\Thelia\Model\MessageI18nQuery');
+ }
+
+ // versionable behavior
+
+ /**
+ * Checks whether versioning is enabled
+ *
+ * @return boolean
+ */
+ static public function isVersioningEnabled()
+ {
+ return self::$isVersioningEnabled;
+ }
+
+ /**
+ * Enables versioning
+ */
+ static public function enableVersioning()
+ {
+ self::$isVersioningEnabled = true;
+ }
+
+ /**
+ * Disables versioning
+ */
+ static public function disableVersioning()
+ {
+ self::$isVersioningEnabled = false;
+ }
+
+} // MessageQuery
diff --git a/core/lib/Thelia/Model/Base/MessageVersion.php b/core/lib/Thelia/Model/Base/MessageVersion.php
new file mode 100644
index 000000000..0781a503a
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/MessageVersion.php
@@ -0,0 +1,1651 @@
+version = 0;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\MessageVersion object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another MessageVersion instance. If
+ * obj is an instance of MessageVersion, delegates to
+ * equals(MessageVersion). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return MessageVersion The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return MessageVersion The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * Get the [secured] column value.
+ *
+ * @return int
+ */
+ public function getSecured()
+ {
+
+ return $this->secured;
+ }
+
+ /**
+ * Get the [ref] column value.
+ *
+ * @return string
+ */
+ public function getRef()
+ {
+
+ return $this->ref;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getVersionCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->version_created_at;
+ } else {
+ return $this->version_created_at !== null ? $this->version_created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\MessageVersion The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = MessageVersionTableMap::ID;
+ }
+
+ if ($this->aMessage !== null && $this->aMessage->getId() !== $v) {
+ $this->aMessage = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\MessageVersion The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = MessageVersionTableMap::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [secured] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\MessageVersion The current object (for fluent API support)
+ */
+ public function setSecured($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->secured !== $v) {
+ $this->secured = $v;
+ $this->modifiedColumns[] = MessageVersionTableMap::SECURED;
+ }
+
+
+ return $this;
+ } // setSecured()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\MessageVersion The current object (for fluent API support)
+ */
+ public function setRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->ref !== $v) {
+ $this->ref = $v;
+ $this->modifiedColumns[] = MessageVersionTableMap::REF;
+ }
+
+
+ return $this;
+ } // setRef()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\MessageVersion The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = MessageVersionTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\MessageVersion The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = MessageVersionTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\MessageVersion The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = MessageVersionTableMap::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\MessageVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ if ($dt !== $this->version_created_at) {
+ $this->version_created_at = $dt;
+ $this->modifiedColumns[] = MessageVersionTableMap::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\MessageVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = MessageVersionTableMap::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->version !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : MessageVersionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : MessageVersionTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->code = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : MessageVersionTableMap::translateFieldName('Secured', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->secured = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : MessageVersionTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->ref = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : MessageVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : MessageVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : MessageVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : MessageVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : MessageVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version_created_by = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 9; // 9 = MessageVersionTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\MessageVersion object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aMessage !== null && $this->id !== $this->aMessage->getId()) {
+ $this->aMessage = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(MessageVersionTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildMessageVersionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aMessage = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see MessageVersion::setDeleted()
+ * @see MessageVersion::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageVersionTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildMessageVersionQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageVersionTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ MessageVersionTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aMessage !== null) {
+ if ($this->aMessage->isModified() || $this->aMessage->isNew()) {
+ $affectedRows += $this->aMessage->save($con);
+ }
+ $this->setMessage($this->aMessage);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(MessageVersionTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(MessageVersionTableMap::CODE)) {
+ $modifiedColumns[':p' . $index++] = 'CODE';
+ }
+ if ($this->isColumnModified(MessageVersionTableMap::SECURED)) {
+ $modifiedColumns[':p' . $index++] = 'SECURED';
+ }
+ if ($this->isColumnModified(MessageVersionTableMap::REF)) {
+ $modifiedColumns[':p' . $index++] = 'REF';
+ }
+ if ($this->isColumnModified(MessageVersionTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(MessageVersionTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+ if ($this->isColumnModified(MessageVersionTableMap::VERSION)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION';
+ }
+ if ($this->isColumnModified(MessageVersionTableMap::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT';
+ }
+ if ($this->isColumnModified(MessageVersionTableMap::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO message_version (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'CODE':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case 'SECURED':
+ $stmt->bindValue($identifier, $this->secured, PDO::PARAM_INT);
+ break;
+ case 'REF':
+ $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case 'VERSION_CREATED_AT':
+ $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION_CREATED_BY':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = MessageVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getCode();
+ break;
+ case 2:
+ return $this->getSecured();
+ break;
+ case 3:
+ return $this->getRef();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ return $this->getUpdatedAt();
+ break;
+ case 6:
+ return $this->getVersion();
+ break;
+ case 7:
+ return $this->getVersionCreatedAt();
+ break;
+ case 8:
+ return $this->getVersionCreatedBy();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['MessageVersion'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['MessageVersion'][serialize($this->getPrimaryKey())] = true;
+ $keys = MessageVersionTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getSecured(),
+ $keys[3] => $this->getRef(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ $keys[6] => $this->getVersion(),
+ $keys[7] => $this->getVersionCreatedAt(),
+ $keys[8] => $this->getVersionCreatedBy(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aMessage) {
+ $result['Message'] = $this->aMessage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = MessageVersionTableMap::translateFieldName($name, $type, TableMap::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->setCode($value);
+ break;
+ case 2:
+ $this->setSecured($value);
+ break;
+ case 3:
+ $this->setRef($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $this->setUpdatedAt($value);
+ break;
+ case 6:
+ $this->setVersion($value);
+ break;
+ case 7:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 8:
+ $this->setVersionCreatedBy($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = MessageVersionTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setSecured($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setRef($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setVersion($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setVersionCreatedAt($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setVersionCreatedBy($arr[$keys[8]]);
+ }
+
+ /**
+ * 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(MessageVersionTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(MessageVersionTableMap::ID)) $criteria->add(MessageVersionTableMap::ID, $this->id);
+ if ($this->isColumnModified(MessageVersionTableMap::CODE)) $criteria->add(MessageVersionTableMap::CODE, $this->code);
+ if ($this->isColumnModified(MessageVersionTableMap::SECURED)) $criteria->add(MessageVersionTableMap::SECURED, $this->secured);
+ if ($this->isColumnModified(MessageVersionTableMap::REF)) $criteria->add(MessageVersionTableMap::REF, $this->ref);
+ if ($this->isColumnModified(MessageVersionTableMap::CREATED_AT)) $criteria->add(MessageVersionTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(MessageVersionTableMap::UPDATED_AT)) $criteria->add(MessageVersionTableMap::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(MessageVersionTableMap::VERSION)) $criteria->add(MessageVersionTableMap::VERSION, $this->version);
+ if ($this->isColumnModified(MessageVersionTableMap::VERSION_CREATED_AT)) $criteria->add(MessageVersionTableMap::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(MessageVersionTableMap::VERSION_CREATED_BY)) $criteria->add(MessageVersionTableMap::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(MessageVersionTableMap::DATABASE_NAME);
+ $criteria->add(MessageVersionTableMap::ID, $this->id);
+ $criteria->add(MessageVersionTableMap::VERSION, $this->version);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getVersion();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setVersion($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getVersion());
+ }
+
+ /**
+ * 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 \Thelia\Model\MessageVersion (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setCode($this->getCode());
+ $copyObj->setSecured($this->getSecured());
+ $copyObj->setRef($this->getRef());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\MessageVersion 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildMessage object.
+ *
+ * @param ChildMessage $v
+ * @return \Thelia\Model\MessageVersion The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setMessage(ChildMessage $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aMessage = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildMessage object, it will not be re-added.
+ if ($v !== null) {
+ $v->addMessageVersion($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildMessage object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildMessage The associated ChildMessage object.
+ * @throws PropelException
+ */
+ public function getMessage(ConnectionInterface $con = null)
+ {
+ if ($this->aMessage === null && ($this->id !== null)) {
+ $this->aMessage = ChildMessageQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aMessage->addMessageVersions($this);
+ */
+ }
+
+ return $this->aMessage;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->secured = null;
+ $this->ref = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aMessage = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(MessageVersionTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/MessageVersionQuery.php b/core/lib/Thelia/Model/Base/MessageVersionQuery.php
new file mode 100644
index 000000000..ac9b0ece0
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/MessageVersionQuery.php
@@ -0,0 +1,772 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $version] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildMessageVersion|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = MessageVersionTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(MessageVersionTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildMessageVersion A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CODE, SECURED, REF, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM message_version WHERE ID = :p0 AND VERSION = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildMessageVersion();
+ $obj->hydrate($row);
+ MessageVersionTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildMessageVersion|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildMessageVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(MessageVersionTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(MessageVersionTableMap::VERSION, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildMessageVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(MessageVersionTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(MessageVersionTableMap::VERSION, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByMessage()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageVersionQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(MessageVersionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(MessageVersionTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageVersionTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageVersionQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageVersionTableMap::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the secured column
+ *
+ * Example usage:
+ *
+ * $query->filterBySecured(1234); // WHERE secured = 1234
+ * $query->filterBySecured(array(12, 34)); // WHERE secured IN (12, 34)
+ * $query->filterBySecured(array('min' => 12)); // WHERE secured > 12
+ *
+ *
+ * @param mixed $secured The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageVersionQuery The current query, for fluid interface
+ */
+ public function filterBySecured($secured = null, $comparison = null)
+ {
+ if (is_array($secured)) {
+ $useMinMax = false;
+ if (isset($secured['min'])) {
+ $this->addUsingAlias(MessageVersionTableMap::SECURED, $secured['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($secured['max'])) {
+ $this->addUsingAlias(MessageVersionTableMap::SECURED, $secured['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageVersionTableMap::SECURED, $secured, $comparison);
+ }
+
+ /**
+ * Filter the query on the ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
+ * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $ref The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageVersionQuery The current query, for fluid interface
+ */
+ public function filterByRef($ref = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($ref)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $ref)) {
+ $ref = str_replace('*', '%', $ref);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageVersionTableMap::REF, $ref, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageVersionQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(MessageVersionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(MessageVersionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageVersionTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageVersionQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(MessageVersionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(MessageVersionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageVersionTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(MessageVersionTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(MessageVersionTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageVersionTableMap::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(MessageVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(MessageVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(MessageVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(MessageVersionTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Message object
+ *
+ * @param \Thelia\Model\Message|ObjectCollection $message The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildMessageVersionQuery The current query, for fluid interface
+ */
+ public function filterByMessage($message, $comparison = null)
+ {
+ if ($message instanceof \Thelia\Model\Message) {
+ return $this
+ ->addUsingAlias(MessageVersionTableMap::ID, $message->getId(), $comparison);
+ } elseif ($message instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(MessageVersionTableMap::ID, $message->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByMessage() only accepts arguments of type \Thelia\Model\Message or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Message relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildMessageVersionQuery The current query, for fluid interface
+ */
+ public function joinMessage($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Message');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Message');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Message relation Message object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\MessageQuery A secondary query class using the current class as primary query
+ */
+ public function useMessageQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinMessage($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Message', '\Thelia\Model\MessageQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildMessageVersion $messageVersion Object to remove from the list of results
+ *
+ * @return ChildMessageVersionQuery The current query, for fluid interface
+ */
+ public function prune($messageVersion = null)
+ {
+ if ($messageVersion) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(MessageVersionTableMap::ID), $messageVersion->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(MessageVersionTableMap::VERSION), $messageVersion->getVersion(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the message_version table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageVersionTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ MessageVersionTableMap::clearInstancePool();
+ MessageVersionTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildMessageVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildMessageVersion object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageVersionTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(MessageVersionTableMap::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->beginTransaction();
+
+
+ MessageVersionTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ MessageVersionTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // MessageVersionQuery
diff --git a/core/lib/Thelia/Model/Base/Module.php b/core/lib/Thelia/Model/Base/Module.php
new file mode 100644
index 000000000..ebe4b4c18
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Module.php
@@ -0,0 +1,2263 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Module instance. If
+ * obj is an instance of Module, delegates to
+ * equals(Module). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Module The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Module The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * Get the [type] column value.
+ *
+ * @return int
+ */
+ public function getType()
+ {
+
+ return $this->type;
+ }
+
+ /**
+ * Get the [activate] column value.
+ *
+ * @return int
+ */
+ public function getActivate()
+ {
+
+ return $this->activate;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Module The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ModuleTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Module The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = ModuleTableMap::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [type] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Module The current object (for fluent API support)
+ */
+ public function setType($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->type !== $v) {
+ $this->type = $v;
+ $this->modifiedColumns[] = ModuleTableMap::TYPE;
+ }
+
+
+ return $this;
+ } // setType()
+
+ /**
+ * Set the value of [activate] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Module The current object (for fluent API support)
+ */
+ public function setActivate($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->activate !== $v) {
+ $this->activate = $v;
+ $this->modifiedColumns[] = ModuleTableMap::ACTIVATE;
+ }
+
+
+ return $this;
+ } // setActivate()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Module The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = ModuleTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Module The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = ModuleTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Module The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = ModuleTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ModuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ModuleTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->code = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ModuleTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->type = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ModuleTableMap::translateFieldName('Activate', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->activate = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ModuleTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ModuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ModuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = ModuleTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Module object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ModuleTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildModuleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collGroupModules = null;
+
+ $this->collModuleI18ns = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Module::setDeleted()
+ * @see Module::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ModuleTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildModuleQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ModuleTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(ModuleTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(ModuleTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(ModuleTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ModuleTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->groupModulesScheduledForDeletion !== null) {
+ if (!$this->groupModulesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\GroupModuleQuery::create()
+ ->filterByPrimaryKeys($this->groupModulesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->groupModulesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collGroupModules !== null) {
+ foreach ($this->collGroupModules as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->moduleI18nsScheduledForDeletion !== null) {
+ if (!$this->moduleI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ModuleI18nQuery::create()
+ ->filterByPrimaryKeys($this->moduleI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->moduleI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collModuleI18ns !== null) {
+ foreach ($this->collModuleI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ModuleTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ModuleTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ModuleTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ModuleTableMap::CODE)) {
+ $modifiedColumns[':p' . $index++] = 'CODE';
+ }
+ if ($this->isColumnModified(ModuleTableMap::TYPE)) {
+ $modifiedColumns[':p' . $index++] = 'TYPE';
+ }
+ if ($this->isColumnModified(ModuleTableMap::ACTIVATE)) {
+ $modifiedColumns[':p' . $index++] = 'ACTIVATE';
+ }
+ if ($this->isColumnModified(ModuleTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(ModuleTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(ModuleTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO module (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'CODE':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case 'TYPE':
+ $stmt->bindValue($identifier, $this->type, PDO::PARAM_INT);
+ break;
+ case 'ACTIVATE':
+ $stmt->bindValue($identifier, $this->activate, PDO::PARAM_INT);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getCode();
+ break;
+ case 2:
+ return $this->getType();
+ break;
+ case 3:
+ return $this->getActivate();
+ break;
+ case 4:
+ return $this->getPosition();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Module'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Module'][$this->getPrimaryKey()] = true;
+ $keys = ModuleTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getType(),
+ $keys[3] => $this->getActivate(),
+ $keys[4] => $this->getPosition(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collGroupModules) {
+ $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collModuleI18ns) {
+ $result['ModuleI18ns'] = $this->collModuleI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ModuleTableMap::translateFieldName($name, $type, TableMap::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->setCode($value);
+ break;
+ case 2:
+ $this->setType($value);
+ break;
+ case 3:
+ $this->setActivate($value);
+ break;
+ case 4:
+ $this->setPosition($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ModuleTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setActivate($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * 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(ModuleTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ModuleTableMap::ID)) $criteria->add(ModuleTableMap::ID, $this->id);
+ if ($this->isColumnModified(ModuleTableMap::CODE)) $criteria->add(ModuleTableMap::CODE, $this->code);
+ if ($this->isColumnModified(ModuleTableMap::TYPE)) $criteria->add(ModuleTableMap::TYPE, $this->type);
+ if ($this->isColumnModified(ModuleTableMap::ACTIVATE)) $criteria->add(ModuleTableMap::ACTIVATE, $this->activate);
+ if ($this->isColumnModified(ModuleTableMap::POSITION)) $criteria->add(ModuleTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(ModuleTableMap::CREATED_AT)) $criteria->add(ModuleTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ModuleTableMap::UPDATED_AT)) $criteria->add(ModuleTableMap::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(ModuleTableMap::DATABASE_NAME);
+ $criteria->add(ModuleTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Module (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setType($this->getType());
+ $copyObj->setActivate($this->getActivate());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getGroupModules() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addGroupModule($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getModuleI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addModuleI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Module 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('GroupModule' == $relationName) {
+ return $this->initGroupModules();
+ }
+ if ('ModuleI18n' == $relationName) {
+ return $this->initModuleI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collGroupModules collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addGroupModules()
+ */
+ public function clearGroupModules()
+ {
+ $this->collGroupModules = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collGroupModules collection loaded partially.
+ */
+ public function resetPartialGroupModules($v = true)
+ {
+ $this->collGroupModulesPartial = $v;
+ }
+
+ /**
+ * Initializes the collGroupModules collection.
+ *
+ * By default this just sets the collGroupModules collection to an empty array (like clearcollGroupModules());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initGroupModules($overrideExisting = true)
+ {
+ if (null !== $this->collGroupModules && !$overrideExisting) {
+ return;
+ }
+ $this->collGroupModules = new ObjectCollection();
+ $this->collGroupModules->setModel('\Thelia\Model\GroupModule');
+ }
+
+ /**
+ * Gets an array of ChildGroupModule objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildModule is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildGroupModule[] List of ChildGroupModule objects
+ * @throws PropelException
+ */
+ public function getGroupModules($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collGroupModulesPartial && !$this->isNew();
+ if (null === $this->collGroupModules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupModules) {
+ // return empty collection
+ $this->initGroupModules();
+ } else {
+ $collGroupModules = ChildGroupModuleQuery::create(null, $criteria)
+ ->filterByModule($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collGroupModulesPartial && count($collGroupModules)) {
+ $this->initGroupModules(false);
+
+ foreach ($collGroupModules as $obj) {
+ if (false == $this->collGroupModules->contains($obj)) {
+ $this->collGroupModules->append($obj);
+ }
+ }
+
+ $this->collGroupModulesPartial = true;
+ }
+
+ $collGroupModules->getInternalIterator()->rewind();
+
+ return $collGroupModules;
+ }
+
+ if ($partial && $this->collGroupModules) {
+ foreach ($this->collGroupModules as $obj) {
+ if ($obj->isNew()) {
+ $collGroupModules[] = $obj;
+ }
+ }
+ }
+
+ $this->collGroupModules = $collGroupModules;
+ $this->collGroupModulesPartial = false;
+ }
+ }
+
+ return $this->collGroupModules;
+ }
+
+ /**
+ * Sets a collection of GroupModule objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $groupModules A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildModule The current object (for fluent API support)
+ */
+ public function setGroupModules(Collection $groupModules, ConnectionInterface $con = null)
+ {
+ $groupModulesToDelete = $this->getGroupModules(new Criteria(), $con)->diff($groupModules);
+
+
+ $this->groupModulesScheduledForDeletion = $groupModulesToDelete;
+
+ foreach ($groupModulesToDelete as $groupModuleRemoved) {
+ $groupModuleRemoved->setModule(null);
+ }
+
+ $this->collGroupModules = null;
+ foreach ($groupModules as $groupModule) {
+ $this->addGroupModule($groupModule);
+ }
+
+ $this->collGroupModules = $groupModules;
+ $this->collGroupModulesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related GroupModule objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related GroupModule objects.
+ * @throws PropelException
+ */
+ public function countGroupModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collGroupModulesPartial && !$this->isNew();
+ if (null === $this->collGroupModules || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupModules) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getGroupModules());
+ }
+
+ $query = ChildGroupModuleQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByModule($this)
+ ->count($con);
+ }
+
+ return count($this->collGroupModules);
+ }
+
+ /**
+ * Method called to associate a ChildGroupModule object to this object
+ * through the ChildGroupModule foreign key attribute.
+ *
+ * @param ChildGroupModule $l ChildGroupModule
+ * @return \Thelia\Model\Module The current object (for fluent API support)
+ */
+ public function addGroupModule(ChildGroupModule $l)
+ {
+ if ($this->collGroupModules === null) {
+ $this->initGroupModules();
+ $this->collGroupModulesPartial = true;
+ }
+
+ if (!in_array($l, $this->collGroupModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddGroupModule($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param GroupModule $groupModule The groupModule object to add.
+ */
+ protected function doAddGroupModule($groupModule)
+ {
+ $this->collGroupModules[]= $groupModule;
+ $groupModule->setModule($this);
+ }
+
+ /**
+ * @param GroupModule $groupModule The groupModule object to remove.
+ * @return ChildModule The current object (for fluent API support)
+ */
+ public function removeGroupModule($groupModule)
+ {
+ if ($this->getGroupModules()->contains($groupModule)) {
+ $this->collGroupModules->remove($this->collGroupModules->search($groupModule));
+ if (null === $this->groupModulesScheduledForDeletion) {
+ $this->groupModulesScheduledForDeletion = clone $this->collGroupModules;
+ $this->groupModulesScheduledForDeletion->clear();
+ }
+ $this->groupModulesScheduledForDeletion[]= $groupModule;
+ $groupModule->setModule(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Module is new, it will return
+ * an empty collection; or if this Module has previously
+ * been saved, it will retrieve related GroupModules 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 Module.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildGroupModule[] List of ChildGroupModule objects
+ */
+ public function getGroupModulesJoinGroup($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildGroupModuleQuery::create(null, $criteria);
+ $query->joinWith('Group', $joinBehavior);
+
+ return $this->getGroupModules($query, $con);
+ }
+
+ /**
+ * Clears out the collModuleI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addModuleI18ns()
+ */
+ public function clearModuleI18ns()
+ {
+ $this->collModuleI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collModuleI18ns collection loaded partially.
+ */
+ public function resetPartialModuleI18ns($v = true)
+ {
+ $this->collModuleI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collModuleI18ns collection.
+ *
+ * By default this just sets the collModuleI18ns collection to an empty array (like clearcollModuleI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initModuleI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collModuleI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collModuleI18ns = new ObjectCollection();
+ $this->collModuleI18ns->setModel('\Thelia\Model\ModuleI18n');
+ }
+
+ /**
+ * Gets an array of ChildModuleI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildModule is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildModuleI18n[] List of ChildModuleI18n objects
+ * @throws PropelException
+ */
+ public function getModuleI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collModuleI18nsPartial && !$this->isNew();
+ if (null === $this->collModuleI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collModuleI18ns) {
+ // return empty collection
+ $this->initModuleI18ns();
+ } else {
+ $collModuleI18ns = ChildModuleI18nQuery::create(null, $criteria)
+ ->filterByModule($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collModuleI18nsPartial && count($collModuleI18ns)) {
+ $this->initModuleI18ns(false);
+
+ foreach ($collModuleI18ns as $obj) {
+ if (false == $this->collModuleI18ns->contains($obj)) {
+ $this->collModuleI18ns->append($obj);
+ }
+ }
+
+ $this->collModuleI18nsPartial = true;
+ }
+
+ $collModuleI18ns->getInternalIterator()->rewind();
+
+ return $collModuleI18ns;
+ }
+
+ if ($partial && $this->collModuleI18ns) {
+ foreach ($this->collModuleI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collModuleI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collModuleI18ns = $collModuleI18ns;
+ $this->collModuleI18nsPartial = false;
+ }
+ }
+
+ return $this->collModuleI18ns;
+ }
+
+ /**
+ * Sets a collection of ModuleI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $moduleI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildModule The current object (for fluent API support)
+ */
+ public function setModuleI18ns(Collection $moduleI18ns, ConnectionInterface $con = null)
+ {
+ $moduleI18nsToDelete = $this->getModuleI18ns(new Criteria(), $con)->diff($moduleI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->moduleI18nsScheduledForDeletion = clone $moduleI18nsToDelete;
+
+ foreach ($moduleI18nsToDelete as $moduleI18nRemoved) {
+ $moduleI18nRemoved->setModule(null);
+ }
+
+ $this->collModuleI18ns = null;
+ foreach ($moduleI18ns as $moduleI18n) {
+ $this->addModuleI18n($moduleI18n);
+ }
+
+ $this->collModuleI18ns = $moduleI18ns;
+ $this->collModuleI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ModuleI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ModuleI18n objects.
+ * @throws PropelException
+ */
+ public function countModuleI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collModuleI18nsPartial && !$this->isNew();
+ if (null === $this->collModuleI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collModuleI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getModuleI18ns());
+ }
+
+ $query = ChildModuleI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByModule($this)
+ ->count($con);
+ }
+
+ return count($this->collModuleI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildModuleI18n object to this object
+ * through the ChildModuleI18n foreign key attribute.
+ *
+ * @param ChildModuleI18n $l ChildModuleI18n
+ * @return \Thelia\Model\Module The current object (for fluent API support)
+ */
+ public function addModuleI18n(ChildModuleI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collModuleI18ns === null) {
+ $this->initModuleI18ns();
+ $this->collModuleI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collModuleI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddModuleI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ModuleI18n $moduleI18n The moduleI18n object to add.
+ */
+ protected function doAddModuleI18n($moduleI18n)
+ {
+ $this->collModuleI18ns[]= $moduleI18n;
+ $moduleI18n->setModule($this);
+ }
+
+ /**
+ * @param ModuleI18n $moduleI18n The moduleI18n object to remove.
+ * @return ChildModule The current object (for fluent API support)
+ */
+ public function removeModuleI18n($moduleI18n)
+ {
+ if ($this->getModuleI18ns()->contains($moduleI18n)) {
+ $this->collModuleI18ns->remove($this->collModuleI18ns->search($moduleI18n));
+ if (null === $this->moduleI18nsScheduledForDeletion) {
+ $this->moduleI18nsScheduledForDeletion = clone $this->collModuleI18ns;
+ $this->moduleI18nsScheduledForDeletion->clear();
+ }
+ $this->moduleI18nsScheduledForDeletion[]= clone $moduleI18n;
+ $moduleI18n->setModule(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->type = null;
+ $this->activate = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collGroupModules) {
+ foreach ($this->collGroupModules as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collModuleI18ns) {
+ foreach ($this->collModuleI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collGroupModules instanceof Collection) {
+ $this->collGroupModules->clearIterator();
+ }
+ $this->collGroupModules = null;
+ if ($this->collModuleI18ns instanceof Collection) {
+ $this->collModuleI18ns->clearIterator();
+ }
+ $this->collModuleI18ns = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ModuleTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildModule The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = ModuleTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildModule The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildModuleI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collModuleI18ns) {
+ foreach ($this->collModuleI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildModuleI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildModuleI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addModuleI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildModule The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildModuleI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collModuleI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collModuleI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildModuleI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ModuleI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ModuleI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ModuleI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ModuleI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ModuleI18n.php b/core/lib/Thelia/Model/Base/ModuleI18n.php
new file mode 100644
index 000000000..54cf305e4
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ModuleI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\ModuleI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another ModuleI18n instance. If
+ * obj is an instance of ModuleI18n, delegates to
+ * equals(ModuleI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return ModuleI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return ModuleI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ModuleI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ModuleI18nTableMap::ID;
+ }
+
+ if ($this->aModule !== null && $this->aModule->getId() !== $v) {
+ $this->aModule = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ModuleI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = ModuleI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ModuleI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = ModuleI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ModuleI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = ModuleI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ModuleI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = ModuleI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ModuleI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = ModuleI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ModuleI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ModuleI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ModuleI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ModuleI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ModuleI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ModuleI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = ModuleI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\ModuleI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aModule !== null && $this->id !== $this->aModule->getId()) {
+ $this->aModule = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ModuleI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildModuleI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aModule = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see ModuleI18n::setDeleted()
+ * @see ModuleI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ModuleI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildModuleI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ModuleI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ModuleI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aModule !== null) {
+ if ($this->aModule->isModified() || $this->aModule->isNew()) {
+ $affectedRows += $this->aModule->save($con);
+ }
+ $this->setModule($this->aModule);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ModuleI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ModuleI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(ModuleI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(ModuleI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(ModuleI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(ModuleI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO module_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ModuleI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ModuleI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ModuleI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = ModuleI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aModule) {
+ $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ModuleI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ModuleI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(ModuleI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ModuleI18nTableMap::ID)) $criteria->add(ModuleI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(ModuleI18nTableMap::LOCALE)) $criteria->add(ModuleI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(ModuleI18nTableMap::TITLE)) $criteria->add(ModuleI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(ModuleI18nTableMap::DESCRIPTION)) $criteria->add(ModuleI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(ModuleI18nTableMap::CHAPO)) $criteria->add(ModuleI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(ModuleI18nTableMap::POSTSCRIPTUM)) $criteria->add(ModuleI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(ModuleI18nTableMap::DATABASE_NAME);
+ $criteria->add(ModuleI18nTableMap::ID, $this->id);
+ $criteria->add(ModuleI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\ModuleI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\ModuleI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildModule object.
+ *
+ * @param ChildModule $v
+ * @return \Thelia\Model\ModuleI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setModule(ChildModule $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aModule = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildModule object, it will not be re-added.
+ if ($v !== null) {
+ $v->addModuleI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildModule object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildModule The associated ChildModule object.
+ * @throws PropelException
+ */
+ public function getModule(ConnectionInterface $con = null)
+ {
+ if ($this->aModule === null && ($this->id !== null)) {
+ $this->aModule = ChildModuleQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aModule->addModuleI18ns($this);
+ */
+ }
+
+ return $this->aModule;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aModule = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ModuleI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ModuleI18nQuery.php b/core/lib/Thelia/Model/Base/ModuleI18nQuery.php
new file mode 100644
index 000000000..d3d4694fb
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ModuleI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildModuleI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ModuleI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ModuleI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildModuleI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM module_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildModuleI18n();
+ $obj->hydrate($row);
+ ModuleI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildModuleI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildModuleI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(ModuleI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(ModuleI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildModuleI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(ModuleI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(ModuleI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByModule()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ModuleI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ModuleI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Module object
+ *
+ * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleI18nQuery The current query, for fluid interface
+ */
+ public function filterByModule($module, $comparison = null)
+ {
+ if ($module instanceof \Thelia\Model\Module) {
+ return $this
+ ->addUsingAlias(ModuleI18nTableMap::ID, $module->getId(), $comparison);
+ } elseif ($module instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ModuleI18nTableMap::ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Module relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildModuleI18nQuery The current query, for fluid interface
+ */
+ public function joinModule($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Module');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Module');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Module relation Module object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query
+ */
+ public function useModuleQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinModule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildModuleI18n $moduleI18n Object to remove from the list of results
+ *
+ * @return ChildModuleI18nQuery The current query, for fluid interface
+ */
+ public function prune($moduleI18n = null)
+ {
+ if ($moduleI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(ModuleI18nTableMap::ID), $moduleI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(ModuleI18nTableMap::LOCALE), $moduleI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the module_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ModuleI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ModuleI18nTableMap::clearInstancePool();
+ ModuleI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildModuleI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildModuleI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ModuleI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ModuleI18nTableMap::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->beginTransaction();
+
+
+ ModuleI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ModuleI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // ModuleI18nQuery
diff --git a/core/lib/Thelia/Model/Base/ModuleQuery.php b/core/lib/Thelia/Model/Base/ModuleQuery.php
new file mode 100644
index 000000000..7db21ca22
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ModuleQuery.php
@@ -0,0 +1,887 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildModule|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ModuleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ModuleTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildModule A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CODE, TYPE, ACTIVATE, POSITION, CREATED_AT, UPDATED_AT FROM module WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildModule();
+ $obj->hydrate($row);
+ ModuleTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildModule|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ModuleTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ModuleTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ModuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ModuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleTableMap::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the type column
+ *
+ * Example usage:
+ *
+ * $query->filterByType(1234); // WHERE type = 1234
+ * $query->filterByType(array(12, 34)); // WHERE type IN (12, 34)
+ * $query->filterByType(array('min' => 12)); // WHERE type > 12
+ *
+ *
+ * @param mixed $type The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function filterByType($type = null, $comparison = null)
+ {
+ if (is_array($type)) {
+ $useMinMax = false;
+ if (isset($type['min'])) {
+ $this->addUsingAlias(ModuleTableMap::TYPE, $type['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($type['max'])) {
+ $this->addUsingAlias(ModuleTableMap::TYPE, $type['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleTableMap::TYPE, $type, $comparison);
+ }
+
+ /**
+ * Filter the query on the activate column
+ *
+ * Example usage:
+ *
+ * $query->filterByActivate(1234); // WHERE activate = 1234
+ * $query->filterByActivate(array(12, 34)); // WHERE activate IN (12, 34)
+ * $query->filterByActivate(array('min' => 12)); // WHERE activate > 12
+ *
+ *
+ * @param mixed $activate The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function filterByActivate($activate = null, $comparison = null)
+ {
+ if (is_array($activate)) {
+ $useMinMax = false;
+ if (isset($activate['min'])) {
+ $this->addUsingAlias(ModuleTableMap::ACTIVATE, $activate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($activate['max'])) {
+ $this->addUsingAlias(ModuleTableMap::ACTIVATE, $activate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleTableMap::ACTIVATE, $activate, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(ModuleTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(ModuleTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ModuleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ModuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ModuleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ModuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ModuleTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\GroupModule object
+ *
+ * @param \Thelia\Model\GroupModule|ObjectCollection $groupModule the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function filterByGroupModule($groupModule, $comparison = null)
+ {
+ if ($groupModule instanceof \Thelia\Model\GroupModule) {
+ return $this
+ ->addUsingAlias(ModuleTableMap::ID, $groupModule->getModuleId(), $comparison);
+ } elseif ($groupModule instanceof ObjectCollection) {
+ return $this
+ ->useGroupModuleQuery()
+ ->filterByPrimaryKeys($groupModule->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByGroupModule() only accepts arguments of type \Thelia\Model\GroupModule or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the GroupModule relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function joinGroupModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('GroupModule');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'GroupModule');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the GroupModule relation GroupModule object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\GroupModuleQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinGroupModule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'GroupModule', '\Thelia\Model\GroupModuleQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ModuleI18n object
+ *
+ * @param \Thelia\Model\ModuleI18n|ObjectCollection $moduleI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function filterByModuleI18n($moduleI18n, $comparison = null)
+ {
+ if ($moduleI18n instanceof \Thelia\Model\ModuleI18n) {
+ return $this
+ ->addUsingAlias(ModuleTableMap::ID, $moduleI18n->getId(), $comparison);
+ } elseif ($moduleI18n instanceof ObjectCollection) {
+ return $this
+ ->useModuleI18nQuery()
+ ->filterByPrimaryKeys($moduleI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByModuleI18n() only accepts arguments of type \Thelia\Model\ModuleI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ModuleI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function joinModuleI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ModuleI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ModuleI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ModuleI18n relation ModuleI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ModuleI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useModuleI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinModuleI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ModuleI18n', '\Thelia\Model\ModuleI18nQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildModule $module Object to remove from the list of results
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function prune($module = null)
+ {
+ if ($module) {
+ $this->addUsingAlias(ModuleTableMap::ID, $module->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the module table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ModuleTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ModuleTableMap::clearInstancePool();
+ ModuleTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildModule or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildModule object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ModuleTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ModuleTableMap::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->beginTransaction();
+
+
+ ModuleTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ModuleTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ModuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ModuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ModuleTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ModuleTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ModuleTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ModuleTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'ModuleI18n';
+
+ return $this
+ ->joinModuleI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildModuleQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('ModuleI18n');
+ $this->with['ModuleI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildModuleI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ModuleI18n', '\Thelia\Model\ModuleI18nQuery');
+ }
+
+} // ModuleQuery
diff --git a/core/lib/Thelia/Model/Base/Order.php b/core/lib/Thelia/Model/Base/Order.php
new file mode 100644
index 000000000..b815aff34
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Order.php
@@ -0,0 +1,3056 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Order instance. If
+ * obj is an instance of Order, delegates to
+ * equals(Order). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Order The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Order The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [ref] column value.
+ *
+ * @return string
+ */
+ public function getRef()
+ {
+
+ return $this->ref;
+ }
+
+ /**
+ * Get the [customer_id] column value.
+ *
+ * @return int
+ */
+ public function getCustomerId()
+ {
+
+ return $this->customer_id;
+ }
+
+ /**
+ * Get the [address_invoice] column value.
+ *
+ * @return int
+ */
+ public function getAddressInvoice()
+ {
+
+ return $this->address_invoice;
+ }
+
+ /**
+ * Get the [address_delivery] column value.
+ *
+ * @return int
+ */
+ public function getAddressDelivery()
+ {
+
+ return $this->address_delivery;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [invoice_date] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getInvoiceDate($format = NULL)
+ {
+ if ($format === null) {
+ return $this->invoice_date;
+ } else {
+ return $this->invoice_date !== null ? $this->invoice_date->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [currency_id] column value.
+ *
+ * @return int
+ */
+ public function getCurrencyId()
+ {
+
+ return $this->currency_id;
+ }
+
+ /**
+ * Get the [currency_rate] column value.
+ *
+ * @return double
+ */
+ public function getCurrencyRate()
+ {
+
+ return $this->currency_rate;
+ }
+
+ /**
+ * Get the [transaction] column value.
+ *
+ * @return string
+ */
+ public function getTransaction()
+ {
+
+ return $this->transaction;
+ }
+
+ /**
+ * Get the [delivery_num] column value.
+ *
+ * @return string
+ */
+ public function getDeliveryNum()
+ {
+
+ return $this->delivery_num;
+ }
+
+ /**
+ * Get the [invoice] column value.
+ *
+ * @return string
+ */
+ public function getInvoice()
+ {
+
+ return $this->invoice;
+ }
+
+ /**
+ * Get the [postage] column value.
+ *
+ * @return double
+ */
+ public function getPostage()
+ {
+
+ return $this->postage;
+ }
+
+ /**
+ * Get the [payment] column value.
+ *
+ * @return string
+ */
+ public function getPayment()
+ {
+
+ return $this->payment;
+ }
+
+ /**
+ * Get the [carrier] column value.
+ *
+ * @return string
+ */
+ public function getCarrier()
+ {
+
+ return $this->carrier;
+ }
+
+ /**
+ * Get the [status_id] column value.
+ *
+ * @return int
+ */
+ public function getStatusId()
+ {
+
+ return $this->status_id;
+ }
+
+ /**
+ * Get the [lang] column value.
+ *
+ * @return string
+ */
+ public function getLang()
+ {
+
+ return $this->lang;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = OrderTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->ref !== $v) {
+ $this->ref = $v;
+ $this->modifiedColumns[] = OrderTableMap::REF;
+ }
+
+
+ return $this;
+ } // setRef()
+
+ /**
+ * Set the value of [customer_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setCustomerId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_id !== $v) {
+ $this->customer_id = $v;
+ $this->modifiedColumns[] = OrderTableMap::CUSTOMER_ID;
+ }
+
+ if ($this->aCustomer !== null && $this->aCustomer->getId() !== $v) {
+ $this->aCustomer = null;
+ }
+
+
+ return $this;
+ } // setCustomerId()
+
+ /**
+ * Set the value of [address_invoice] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setAddressInvoice($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->address_invoice !== $v) {
+ $this->address_invoice = $v;
+ $this->modifiedColumns[] = OrderTableMap::ADDRESS_INVOICE;
+ }
+
+ if ($this->aOrderAddressRelatedByAddressInvoice !== null && $this->aOrderAddressRelatedByAddressInvoice->getId() !== $v) {
+ $this->aOrderAddressRelatedByAddressInvoice = null;
+ }
+
+
+ return $this;
+ } // setAddressInvoice()
+
+ /**
+ * Set the value of [address_delivery] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setAddressDelivery($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->address_delivery !== $v) {
+ $this->address_delivery = $v;
+ $this->modifiedColumns[] = OrderTableMap::ADDRESS_DELIVERY;
+ }
+
+ if ($this->aOrderAddressRelatedByAddressDelivery !== null && $this->aOrderAddressRelatedByAddressDelivery->getId() !== $v) {
+ $this->aOrderAddressRelatedByAddressDelivery = null;
+ }
+
+
+ return $this;
+ } // setAddressDelivery()
+
+ /**
+ * Sets the value of [invoice_date] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setInvoiceDate($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->invoice_date !== null || $dt !== null) {
+ if ($dt !== $this->invoice_date) {
+ $this->invoice_date = $dt;
+ $this->modifiedColumns[] = OrderTableMap::INVOICE_DATE;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setInvoiceDate()
+
+ /**
+ * Set the value of [currency_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setCurrencyId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->currency_id !== $v) {
+ $this->currency_id = $v;
+ $this->modifiedColumns[] = OrderTableMap::CURRENCY_ID;
+ }
+
+ if ($this->aCurrency !== null && $this->aCurrency->getId() !== $v) {
+ $this->aCurrency = null;
+ }
+
+
+ return $this;
+ } // setCurrencyId()
+
+ /**
+ * Set the value of [currency_rate] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setCurrencyRate($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->currency_rate !== $v) {
+ $this->currency_rate = $v;
+ $this->modifiedColumns[] = OrderTableMap::CURRENCY_RATE;
+ }
+
+
+ return $this;
+ } // setCurrencyRate()
+
+ /**
+ * Set the value of [transaction] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setTransaction($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->transaction !== $v) {
+ $this->transaction = $v;
+ $this->modifiedColumns[] = OrderTableMap::TRANSACTION;
+ }
+
+
+ return $this;
+ } // setTransaction()
+
+ /**
+ * Set the value of [delivery_num] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setDeliveryNum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->delivery_num !== $v) {
+ $this->delivery_num = $v;
+ $this->modifiedColumns[] = OrderTableMap::DELIVERY_NUM;
+ }
+
+
+ return $this;
+ } // setDeliveryNum()
+
+ /**
+ * Set the value of [invoice] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setInvoice($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->invoice !== $v) {
+ $this->invoice = $v;
+ $this->modifiedColumns[] = OrderTableMap::INVOICE;
+ }
+
+
+ return $this;
+ } // setInvoice()
+
+ /**
+ * Set the value of [postage] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setPostage($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->postage !== $v) {
+ $this->postage = $v;
+ $this->modifiedColumns[] = OrderTableMap::POSTAGE;
+ }
+
+
+ return $this;
+ } // setPostage()
+
+ /**
+ * Set the value of [payment] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setPayment($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->payment !== $v) {
+ $this->payment = $v;
+ $this->modifiedColumns[] = OrderTableMap::PAYMENT;
+ }
+
+
+ return $this;
+ } // setPayment()
+
+ /**
+ * Set the value of [carrier] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setCarrier($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->carrier !== $v) {
+ $this->carrier = $v;
+ $this->modifiedColumns[] = OrderTableMap::CARRIER;
+ }
+
+
+ return $this;
+ } // setCarrier()
+
+ /**
+ * Set the value of [status_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setStatusId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->status_id !== $v) {
+ $this->status_id = $v;
+ $this->modifiedColumns[] = OrderTableMap::STATUS_ID;
+ }
+
+ if ($this->aOrderStatus !== null && $this->aOrderStatus->getId() !== $v) {
+ $this->aOrderStatus = null;
+ }
+
+
+ return $this;
+ } // setStatusId()
+
+ /**
+ * Set the value of [lang] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setLang($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lang !== $v) {
+ $this->lang = $v;
+ $this->modifiedColumns[] = OrderTableMap::LANG;
+ }
+
+
+ return $this;
+ } // setLang()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = OrderTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = OrderTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->ref = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderTableMap::translateFieldName('CustomerId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->customer_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderTableMap::translateFieldName('AddressInvoice', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->address_invoice = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderTableMap::translateFieldName('AddressDelivery', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->address_delivery = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderTableMap::translateFieldName('InvoiceDate', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00') {
+ $col = null;
+ }
+ $this->invoice_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderTableMap::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->currency_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderTableMap::translateFieldName('CurrencyRate', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->currency_rate = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderTableMap::translateFieldName('Transaction', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->transaction = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderTableMap::translateFieldName('DeliveryNum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->delivery_num = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderTableMap::translateFieldName('Invoice', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->invoice = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderTableMap::translateFieldName('Postage', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postage = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderTableMap::translateFieldName('Payment', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->payment = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderTableMap::translateFieldName('Carrier', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->carrier = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderTableMap::translateFieldName('StatusId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->status_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderTableMap::translateFieldName('Lang', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->lang = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : OrderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : OrderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 18; // 18 = OrderTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Order object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) {
+ $this->aCustomer = null;
+ }
+ if ($this->aOrderAddressRelatedByAddressInvoice !== null && $this->address_invoice !== $this->aOrderAddressRelatedByAddressInvoice->getId()) {
+ $this->aOrderAddressRelatedByAddressInvoice = null;
+ }
+ if ($this->aOrderAddressRelatedByAddressDelivery !== null && $this->address_delivery !== $this->aOrderAddressRelatedByAddressDelivery->getId()) {
+ $this->aOrderAddressRelatedByAddressDelivery = null;
+ }
+ if ($this->aCurrency !== null && $this->currency_id !== $this->aCurrency->getId()) {
+ $this->aCurrency = null;
+ }
+ if ($this->aOrderStatus !== null && $this->status_id !== $this->aOrderStatus->getId()) {
+ $this->aOrderStatus = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildOrderQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCurrency = null;
+ $this->aCustomer = null;
+ $this->aOrderAddressRelatedByAddressInvoice = null;
+ $this->aOrderAddressRelatedByAddressDelivery = null;
+ $this->aOrderStatus = null;
+ $this->collOrderProducts = null;
+
+ $this->collCouponOrders = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Order::setDeleted()
+ * @see Order::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildOrderQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(OrderTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(OrderTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(OrderTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCurrency !== null) {
+ if ($this->aCurrency->isModified() || $this->aCurrency->isNew()) {
+ $affectedRows += $this->aCurrency->save($con);
+ }
+ $this->setCurrency($this->aCurrency);
+ }
+
+ if ($this->aCustomer !== null) {
+ if ($this->aCustomer->isModified() || $this->aCustomer->isNew()) {
+ $affectedRows += $this->aCustomer->save($con);
+ }
+ $this->setCustomer($this->aCustomer);
+ }
+
+ if ($this->aOrderAddressRelatedByAddressInvoice !== null) {
+ if ($this->aOrderAddressRelatedByAddressInvoice->isModified() || $this->aOrderAddressRelatedByAddressInvoice->isNew()) {
+ $affectedRows += $this->aOrderAddressRelatedByAddressInvoice->save($con);
+ }
+ $this->setOrderAddressRelatedByAddressInvoice($this->aOrderAddressRelatedByAddressInvoice);
+ }
+
+ if ($this->aOrderAddressRelatedByAddressDelivery !== null) {
+ if ($this->aOrderAddressRelatedByAddressDelivery->isModified() || $this->aOrderAddressRelatedByAddressDelivery->isNew()) {
+ $affectedRows += $this->aOrderAddressRelatedByAddressDelivery->save($con);
+ }
+ $this->setOrderAddressRelatedByAddressDelivery($this->aOrderAddressRelatedByAddressDelivery);
+ }
+
+ if ($this->aOrderStatus !== null) {
+ if ($this->aOrderStatus->isModified() || $this->aOrderStatus->isNew()) {
+ $affectedRows += $this->aOrderStatus->save($con);
+ }
+ $this->setOrderStatus($this->aOrderStatus);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->orderProductsScheduledForDeletion !== null) {
+ if (!$this->orderProductsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\OrderProductQuery::create()
+ ->filterByPrimaryKeys($this->orderProductsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->orderProductsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrderProducts !== null) {
+ foreach ($this->collOrderProducts as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->couponOrdersScheduledForDeletion !== null) {
+ if (!$this->couponOrdersScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\CouponOrderQuery::create()
+ ->filterByPrimaryKeys($this->couponOrdersScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->couponOrdersScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collCouponOrders !== null) {
+ foreach ($this->collCouponOrders as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = OrderTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(OrderTableMap::REF)) {
+ $modifiedColumns[':p' . $index++] = 'REF';
+ }
+ if ($this->isColumnModified(OrderTableMap::CUSTOMER_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID';
+ }
+ if ($this->isColumnModified(OrderTableMap::ADDRESS_INVOICE)) {
+ $modifiedColumns[':p' . $index++] = 'ADDRESS_INVOICE';
+ }
+ if ($this->isColumnModified(OrderTableMap::ADDRESS_DELIVERY)) {
+ $modifiedColumns[':p' . $index++] = 'ADDRESS_DELIVERY';
+ }
+ if ($this->isColumnModified(OrderTableMap::INVOICE_DATE)) {
+ $modifiedColumns[':p' . $index++] = 'INVOICE_DATE';
+ }
+ if ($this->isColumnModified(OrderTableMap::CURRENCY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CURRENCY_ID';
+ }
+ if ($this->isColumnModified(OrderTableMap::CURRENCY_RATE)) {
+ $modifiedColumns[':p' . $index++] = 'CURRENCY_RATE';
+ }
+ if ($this->isColumnModified(OrderTableMap::TRANSACTION)) {
+ $modifiedColumns[':p' . $index++] = 'TRANSACTION';
+ }
+ if ($this->isColumnModified(OrderTableMap::DELIVERY_NUM)) {
+ $modifiedColumns[':p' . $index++] = 'DELIVERY_NUM';
+ }
+ if ($this->isColumnModified(OrderTableMap::INVOICE)) {
+ $modifiedColumns[':p' . $index++] = 'INVOICE';
+ }
+ if ($this->isColumnModified(OrderTableMap::POSTAGE)) {
+ $modifiedColumns[':p' . $index++] = 'POSTAGE';
+ }
+ if ($this->isColumnModified(OrderTableMap::PAYMENT)) {
+ $modifiedColumns[':p' . $index++] = 'PAYMENT';
+ }
+ if ($this->isColumnModified(OrderTableMap::CARRIER)) {
+ $modifiedColumns[':p' . $index++] = 'CARRIER';
+ }
+ if ($this->isColumnModified(OrderTableMap::STATUS_ID)) {
+ $modifiedColumns[':p' . $index++] = 'STATUS_ID';
+ }
+ if ($this->isColumnModified(OrderTableMap::LANG)) {
+ $modifiedColumns[':p' . $index++] = 'LANG';
+ }
+ if ($this->isColumnModified(OrderTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(OrderTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO order (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'REF':
+ $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
+ break;
+ case 'CUSTOMER_ID':
+ $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
+ break;
+ case 'ADDRESS_INVOICE':
+ $stmt->bindValue($identifier, $this->address_invoice, PDO::PARAM_INT);
+ break;
+ case 'ADDRESS_DELIVERY':
+ $stmt->bindValue($identifier, $this->address_delivery, PDO::PARAM_INT);
+ break;
+ case 'INVOICE_DATE':
+ $stmt->bindValue($identifier, $this->invoice_date ? $this->invoice_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'CURRENCY_ID':
+ $stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT);
+ break;
+ case 'CURRENCY_RATE':
+ $stmt->bindValue($identifier, $this->currency_rate, PDO::PARAM_STR);
+ break;
+ case 'TRANSACTION':
+ $stmt->bindValue($identifier, $this->transaction, PDO::PARAM_STR);
+ break;
+ case 'DELIVERY_NUM':
+ $stmt->bindValue($identifier, $this->delivery_num, PDO::PARAM_STR);
+ break;
+ case 'INVOICE':
+ $stmt->bindValue($identifier, $this->invoice, PDO::PARAM_STR);
+ break;
+ case 'POSTAGE':
+ $stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR);
+ break;
+ case 'PAYMENT':
+ $stmt->bindValue($identifier, $this->payment, PDO::PARAM_STR);
+ break;
+ case 'CARRIER':
+ $stmt->bindValue($identifier, $this->carrier, PDO::PARAM_STR);
+ break;
+ case 'STATUS_ID':
+ $stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT);
+ break;
+ case 'LANG':
+ $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getRef();
+ break;
+ case 2:
+ return $this->getCustomerId();
+ break;
+ case 3:
+ return $this->getAddressInvoice();
+ break;
+ case 4:
+ return $this->getAddressDelivery();
+ break;
+ case 5:
+ return $this->getInvoiceDate();
+ break;
+ case 6:
+ return $this->getCurrencyId();
+ break;
+ case 7:
+ return $this->getCurrencyRate();
+ break;
+ case 8:
+ return $this->getTransaction();
+ break;
+ case 9:
+ return $this->getDeliveryNum();
+ break;
+ case 10:
+ return $this->getInvoice();
+ break;
+ case 11:
+ return $this->getPostage();
+ break;
+ case 12:
+ return $this->getPayment();
+ break;
+ case 13:
+ return $this->getCarrier();
+ break;
+ case 14:
+ return $this->getStatusId();
+ break;
+ case 15:
+ return $this->getLang();
+ break;
+ case 16:
+ return $this->getCreatedAt();
+ break;
+ case 17:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Order'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Order'][$this->getPrimaryKey()] = true;
+ $keys = OrderTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getRef(),
+ $keys[2] => $this->getCustomerId(),
+ $keys[3] => $this->getAddressInvoice(),
+ $keys[4] => $this->getAddressDelivery(),
+ $keys[5] => $this->getInvoiceDate(),
+ $keys[6] => $this->getCurrencyId(),
+ $keys[7] => $this->getCurrencyRate(),
+ $keys[8] => $this->getTransaction(),
+ $keys[9] => $this->getDeliveryNum(),
+ $keys[10] => $this->getInvoice(),
+ $keys[11] => $this->getPostage(),
+ $keys[12] => $this->getPayment(),
+ $keys[13] => $this->getCarrier(),
+ $keys[14] => $this->getStatusId(),
+ $keys[15] => $this->getLang(),
+ $keys[16] => $this->getCreatedAt(),
+ $keys[17] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCurrency) {
+ $result['Currency'] = $this->aCurrency->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCustomer) {
+ $result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aOrderAddressRelatedByAddressInvoice) {
+ $result['OrderAddressRelatedByAddressInvoice'] = $this->aOrderAddressRelatedByAddressInvoice->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aOrderAddressRelatedByAddressDelivery) {
+ $result['OrderAddressRelatedByAddressDelivery'] = $this->aOrderAddressRelatedByAddressDelivery->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aOrderStatus) {
+ $result['OrderStatus'] = $this->aOrderStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collOrderProducts) {
+ $result['OrderProducts'] = $this->collOrderProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collCouponOrders) {
+ $result['CouponOrders'] = $this->collCouponOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderTableMap::translateFieldName($name, $type, TableMap::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->setRef($value);
+ break;
+ case 2:
+ $this->setCustomerId($value);
+ break;
+ case 3:
+ $this->setAddressInvoice($value);
+ break;
+ case 4:
+ $this->setAddressDelivery($value);
+ break;
+ case 5:
+ $this->setInvoiceDate($value);
+ break;
+ case 6:
+ $this->setCurrencyId($value);
+ break;
+ case 7:
+ $this->setCurrencyRate($value);
+ break;
+ case 8:
+ $this->setTransaction($value);
+ break;
+ case 9:
+ $this->setDeliveryNum($value);
+ break;
+ case 10:
+ $this->setInvoice($value);
+ break;
+ case 11:
+ $this->setPostage($value);
+ break;
+ case 12:
+ $this->setPayment($value);
+ break;
+ case 13:
+ $this->setCarrier($value);
+ break;
+ case 14:
+ $this->setStatusId($value);
+ break;
+ case 15:
+ $this->setLang($value);
+ break;
+ case 16:
+ $this->setCreatedAt($value);
+ break;
+ case 17:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = OrderTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCustomerId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setAddressInvoice($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setAddressDelivery($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setInvoiceDate($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCurrencyId($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setCurrencyRate($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setTransaction($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setDeliveryNum($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setInvoice($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setPostage($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setPayment($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setCarrier($arr[$keys[13]]);
+ if (array_key_exists($keys[14], $arr)) $this->setStatusId($arr[$keys[14]]);
+ if (array_key_exists($keys[15], $arr)) $this->setLang($arr[$keys[15]]);
+ if (array_key_exists($keys[16], $arr)) $this->setCreatedAt($arr[$keys[16]]);
+ if (array_key_exists($keys[17], $arr)) $this->setUpdatedAt($arr[$keys[17]]);
+ }
+
+ /**
+ * 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(OrderTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderTableMap::ID)) $criteria->add(OrderTableMap::ID, $this->id);
+ if ($this->isColumnModified(OrderTableMap::REF)) $criteria->add(OrderTableMap::REF, $this->ref);
+ if ($this->isColumnModified(OrderTableMap::CUSTOMER_ID)) $criteria->add(OrderTableMap::CUSTOMER_ID, $this->customer_id);
+ if ($this->isColumnModified(OrderTableMap::ADDRESS_INVOICE)) $criteria->add(OrderTableMap::ADDRESS_INVOICE, $this->address_invoice);
+ if ($this->isColumnModified(OrderTableMap::ADDRESS_DELIVERY)) $criteria->add(OrderTableMap::ADDRESS_DELIVERY, $this->address_delivery);
+ if ($this->isColumnModified(OrderTableMap::INVOICE_DATE)) $criteria->add(OrderTableMap::INVOICE_DATE, $this->invoice_date);
+ if ($this->isColumnModified(OrderTableMap::CURRENCY_ID)) $criteria->add(OrderTableMap::CURRENCY_ID, $this->currency_id);
+ if ($this->isColumnModified(OrderTableMap::CURRENCY_RATE)) $criteria->add(OrderTableMap::CURRENCY_RATE, $this->currency_rate);
+ if ($this->isColumnModified(OrderTableMap::TRANSACTION)) $criteria->add(OrderTableMap::TRANSACTION, $this->transaction);
+ if ($this->isColumnModified(OrderTableMap::DELIVERY_NUM)) $criteria->add(OrderTableMap::DELIVERY_NUM, $this->delivery_num);
+ if ($this->isColumnModified(OrderTableMap::INVOICE)) $criteria->add(OrderTableMap::INVOICE, $this->invoice);
+ if ($this->isColumnModified(OrderTableMap::POSTAGE)) $criteria->add(OrderTableMap::POSTAGE, $this->postage);
+ if ($this->isColumnModified(OrderTableMap::PAYMENT)) $criteria->add(OrderTableMap::PAYMENT, $this->payment);
+ if ($this->isColumnModified(OrderTableMap::CARRIER)) $criteria->add(OrderTableMap::CARRIER, $this->carrier);
+ if ($this->isColumnModified(OrderTableMap::STATUS_ID)) $criteria->add(OrderTableMap::STATUS_ID, $this->status_id);
+ if ($this->isColumnModified(OrderTableMap::LANG)) $criteria->add(OrderTableMap::LANG, $this->lang);
+ if ($this->isColumnModified(OrderTableMap::CREATED_AT)) $criteria->add(OrderTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(OrderTableMap::UPDATED_AT)) $criteria->add(OrderTableMap::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(OrderTableMap::DATABASE_NAME);
+ $criteria->add(OrderTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Order (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setRef($this->getRef());
+ $copyObj->setCustomerId($this->getCustomerId());
+ $copyObj->setAddressInvoice($this->getAddressInvoice());
+ $copyObj->setAddressDelivery($this->getAddressDelivery());
+ $copyObj->setInvoiceDate($this->getInvoiceDate());
+ $copyObj->setCurrencyId($this->getCurrencyId());
+ $copyObj->setCurrencyRate($this->getCurrencyRate());
+ $copyObj->setTransaction($this->getTransaction());
+ $copyObj->setDeliveryNum($this->getDeliveryNum());
+ $copyObj->setInvoice($this->getInvoice());
+ $copyObj->setPostage($this->getPostage());
+ $copyObj->setPayment($this->getPayment());
+ $copyObj->setCarrier($this->getCarrier());
+ $copyObj->setStatusId($this->getStatusId());
+ $copyObj->setLang($this->getLang());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getOrderProducts() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderProduct($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getCouponOrders() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addCouponOrder($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Order 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCurrency object.
+ *
+ * @param ChildCurrency $v
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCurrency(ChildCurrency $v = null)
+ {
+ if ($v === null) {
+ $this->setCurrencyId(NULL);
+ } else {
+ $this->setCurrencyId($v->getId());
+ }
+
+ $this->aCurrency = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCurrency object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrder($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCurrency object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCurrency The associated ChildCurrency object.
+ * @throws PropelException
+ */
+ public function getCurrency(ConnectionInterface $con = null)
+ {
+ if ($this->aCurrency === null && ($this->currency_id !== null)) {
+ $this->aCurrency = ChildCurrencyQuery::create()->findPk($this->currency_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCurrency->addOrders($this);
+ */
+ }
+
+ return $this->aCurrency;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCustomer object.
+ *
+ * @param ChildCustomer $v
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCustomer(ChildCustomer $v = null)
+ {
+ if ($v === null) {
+ $this->setCustomerId(NULL);
+ } else {
+ $this->setCustomerId($v->getId());
+ }
+
+ $this->aCustomer = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCustomer object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrder($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCustomer object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCustomer The associated ChildCustomer object.
+ * @throws PropelException
+ */
+ public function getCustomer(ConnectionInterface $con = null)
+ {
+ if ($this->aCustomer === null && ($this->customer_id !== null)) {
+ $this->aCustomer = ChildCustomerQuery::create()->findPk($this->customer_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCustomer->addOrders($this);
+ */
+ }
+
+ return $this->aCustomer;
+ }
+
+ /**
+ * Declares an association between this object and a ChildOrderAddress object.
+ *
+ * @param ChildOrderAddress $v
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrderAddressRelatedByAddressInvoice(ChildOrderAddress $v = null)
+ {
+ if ($v === null) {
+ $this->setAddressInvoice(NULL);
+ } else {
+ $this->setAddressInvoice($v->getId());
+ }
+
+ $this->aOrderAddressRelatedByAddressInvoice = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildOrderAddress object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderRelatedByAddressInvoice($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildOrderAddress object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildOrderAddress The associated ChildOrderAddress object.
+ * @throws PropelException
+ */
+ public function getOrderAddressRelatedByAddressInvoice(ConnectionInterface $con = null)
+ {
+ if ($this->aOrderAddressRelatedByAddressInvoice === null && ($this->address_invoice !== null)) {
+ $this->aOrderAddressRelatedByAddressInvoice = ChildOrderAddressQuery::create()->findPk($this->address_invoice, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aOrderAddressRelatedByAddressInvoice->addOrdersRelatedByAddressInvoice($this);
+ */
+ }
+
+ return $this->aOrderAddressRelatedByAddressInvoice;
+ }
+
+ /**
+ * Declares an association between this object and a ChildOrderAddress object.
+ *
+ * @param ChildOrderAddress $v
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrderAddressRelatedByAddressDelivery(ChildOrderAddress $v = null)
+ {
+ if ($v === null) {
+ $this->setAddressDelivery(NULL);
+ } else {
+ $this->setAddressDelivery($v->getId());
+ }
+
+ $this->aOrderAddressRelatedByAddressDelivery = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildOrderAddress object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderRelatedByAddressDelivery($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildOrderAddress object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildOrderAddress The associated ChildOrderAddress object.
+ * @throws PropelException
+ */
+ public function getOrderAddressRelatedByAddressDelivery(ConnectionInterface $con = null)
+ {
+ if ($this->aOrderAddressRelatedByAddressDelivery === null && ($this->address_delivery !== null)) {
+ $this->aOrderAddressRelatedByAddressDelivery = ChildOrderAddressQuery::create()->findPk($this->address_delivery, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aOrderAddressRelatedByAddressDelivery->addOrdersRelatedByAddressDelivery($this);
+ */
+ }
+
+ return $this->aOrderAddressRelatedByAddressDelivery;
+ }
+
+ /**
+ * Declares an association between this object and a ChildOrderStatus object.
+ *
+ * @param ChildOrderStatus $v
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrderStatus(ChildOrderStatus $v = null)
+ {
+ if ($v === null) {
+ $this->setStatusId(NULL);
+ } else {
+ $this->setStatusId($v->getId());
+ }
+
+ $this->aOrderStatus = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildOrderStatus object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrder($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildOrderStatus object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildOrderStatus The associated ChildOrderStatus object.
+ * @throws PropelException
+ */
+ public function getOrderStatus(ConnectionInterface $con = null)
+ {
+ if ($this->aOrderStatus === null && ($this->status_id !== null)) {
+ $this->aOrderStatus = ChildOrderStatusQuery::create()->findPk($this->status_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aOrderStatus->addOrders($this);
+ */
+ }
+
+ return $this->aOrderStatus;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('OrderProduct' == $relationName) {
+ return $this->initOrderProducts();
+ }
+ if ('CouponOrder' == $relationName) {
+ return $this->initCouponOrders();
+ }
+ }
+
+ /**
+ * Clears out the collOrderProducts collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addOrderProducts()
+ */
+ public function clearOrderProducts()
+ {
+ $this->collOrderProducts = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collOrderProducts collection loaded partially.
+ */
+ public function resetPartialOrderProducts($v = true)
+ {
+ $this->collOrderProductsPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrderProducts collection.
+ *
+ * By default this just sets the collOrderProducts collection to an empty array (like clearcollOrderProducts());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initOrderProducts($overrideExisting = true)
+ {
+ if (null !== $this->collOrderProducts && !$overrideExisting) {
+ return;
+ }
+ $this->collOrderProducts = new ObjectCollection();
+ $this->collOrderProducts->setModel('\Thelia\Model\OrderProduct');
+ }
+
+ /**
+ * Gets an array of ChildOrderProduct objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildOrder is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildOrderProduct[] List of ChildOrderProduct objects
+ * @throws PropelException
+ */
+ public function getOrderProducts($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderProductsPartial && !$this->isNew();
+ if (null === $this->collOrderProducts || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderProducts) {
+ // return empty collection
+ $this->initOrderProducts();
+ } else {
+ $collOrderProducts = ChildOrderProductQuery::create(null, $criteria)
+ ->filterByOrder($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collOrderProductsPartial && count($collOrderProducts)) {
+ $this->initOrderProducts(false);
+
+ foreach ($collOrderProducts as $obj) {
+ if (false == $this->collOrderProducts->contains($obj)) {
+ $this->collOrderProducts->append($obj);
+ }
+ }
+
+ $this->collOrderProductsPartial = true;
+ }
+
+ $collOrderProducts->getInternalIterator()->rewind();
+
+ return $collOrderProducts;
+ }
+
+ if ($partial && $this->collOrderProducts) {
+ foreach ($this->collOrderProducts as $obj) {
+ if ($obj->isNew()) {
+ $collOrderProducts[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrderProducts = $collOrderProducts;
+ $this->collOrderProductsPartial = false;
+ }
+ }
+
+ return $this->collOrderProducts;
+ }
+
+ /**
+ * Sets a collection of OrderProduct objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $orderProducts A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildOrder The current object (for fluent API support)
+ */
+ public function setOrderProducts(Collection $orderProducts, ConnectionInterface $con = null)
+ {
+ $orderProductsToDelete = $this->getOrderProducts(new Criteria(), $con)->diff($orderProducts);
+
+
+ $this->orderProductsScheduledForDeletion = $orderProductsToDelete;
+
+ foreach ($orderProductsToDelete as $orderProductRemoved) {
+ $orderProductRemoved->setOrder(null);
+ }
+
+ $this->collOrderProducts = null;
+ foreach ($orderProducts as $orderProduct) {
+ $this->addOrderProduct($orderProduct);
+ }
+
+ $this->collOrderProducts = $orderProducts;
+ $this->collOrderProductsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related OrderProduct objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related OrderProduct objects.
+ * @throws PropelException
+ */
+ public function countOrderProducts(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderProductsPartial && !$this->isNew();
+ if (null === $this->collOrderProducts || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderProducts) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getOrderProducts());
+ }
+
+ $query = ChildOrderProductQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrder($this)
+ ->count($con);
+ }
+
+ return count($this->collOrderProducts);
+ }
+
+ /**
+ * Method called to associate a ChildOrderProduct object to this object
+ * through the ChildOrderProduct foreign key attribute.
+ *
+ * @param ChildOrderProduct $l ChildOrderProduct
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function addOrderProduct(ChildOrderProduct $l)
+ {
+ if ($this->collOrderProducts === null) {
+ $this->initOrderProducts();
+ $this->collOrderProductsPartial = true;
+ }
+
+ if (!in_array($l, $this->collOrderProducts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderProduct($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param OrderProduct $orderProduct The orderProduct object to add.
+ */
+ protected function doAddOrderProduct($orderProduct)
+ {
+ $this->collOrderProducts[]= $orderProduct;
+ $orderProduct->setOrder($this);
+ }
+
+ /**
+ * @param OrderProduct $orderProduct The orderProduct object to remove.
+ * @return ChildOrder The current object (for fluent API support)
+ */
+ public function removeOrderProduct($orderProduct)
+ {
+ if ($this->getOrderProducts()->contains($orderProduct)) {
+ $this->collOrderProducts->remove($this->collOrderProducts->search($orderProduct));
+ if (null === $this->orderProductsScheduledForDeletion) {
+ $this->orderProductsScheduledForDeletion = clone $this->collOrderProducts;
+ $this->orderProductsScheduledForDeletion->clear();
+ }
+ $this->orderProductsScheduledForDeletion[]= clone $orderProduct;
+ $orderProduct->setOrder(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collCouponOrders collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCouponOrders()
+ */
+ public function clearCouponOrders()
+ {
+ $this->collCouponOrders = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collCouponOrders collection loaded partially.
+ */
+ public function resetPartialCouponOrders($v = true)
+ {
+ $this->collCouponOrdersPartial = $v;
+ }
+
+ /**
+ * Initializes the collCouponOrders collection.
+ *
+ * By default this just sets the collCouponOrders collection to an empty array (like clearcollCouponOrders());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initCouponOrders($overrideExisting = true)
+ {
+ if (null !== $this->collCouponOrders && !$overrideExisting) {
+ return;
+ }
+ $this->collCouponOrders = new ObjectCollection();
+ $this->collCouponOrders->setModel('\Thelia\Model\CouponOrder');
+ }
+
+ /**
+ * Gets an array of ChildCouponOrder objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildOrder is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildCouponOrder[] List of ChildCouponOrder objects
+ * @throws PropelException
+ */
+ public function getCouponOrders($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCouponOrdersPartial && !$this->isNew();
+ if (null === $this->collCouponOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCouponOrders) {
+ // return empty collection
+ $this->initCouponOrders();
+ } else {
+ $collCouponOrders = ChildCouponOrderQuery::create(null, $criteria)
+ ->filterByOrder($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collCouponOrdersPartial && count($collCouponOrders)) {
+ $this->initCouponOrders(false);
+
+ foreach ($collCouponOrders as $obj) {
+ if (false == $this->collCouponOrders->contains($obj)) {
+ $this->collCouponOrders->append($obj);
+ }
+ }
+
+ $this->collCouponOrdersPartial = true;
+ }
+
+ $collCouponOrders->getInternalIterator()->rewind();
+
+ return $collCouponOrders;
+ }
+
+ if ($partial && $this->collCouponOrders) {
+ foreach ($this->collCouponOrders as $obj) {
+ if ($obj->isNew()) {
+ $collCouponOrders[] = $obj;
+ }
+ }
+ }
+
+ $this->collCouponOrders = $collCouponOrders;
+ $this->collCouponOrdersPartial = false;
+ }
+ }
+
+ return $this->collCouponOrders;
+ }
+
+ /**
+ * Sets a collection of CouponOrder objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $couponOrders A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildOrder The current object (for fluent API support)
+ */
+ public function setCouponOrders(Collection $couponOrders, ConnectionInterface $con = null)
+ {
+ $couponOrdersToDelete = $this->getCouponOrders(new Criteria(), $con)->diff($couponOrders);
+
+
+ $this->couponOrdersScheduledForDeletion = $couponOrdersToDelete;
+
+ foreach ($couponOrdersToDelete as $couponOrderRemoved) {
+ $couponOrderRemoved->setOrder(null);
+ }
+
+ $this->collCouponOrders = null;
+ foreach ($couponOrders as $couponOrder) {
+ $this->addCouponOrder($couponOrder);
+ }
+
+ $this->collCouponOrders = $couponOrders;
+ $this->collCouponOrdersPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related CouponOrder objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related CouponOrder objects.
+ * @throws PropelException
+ */
+ public function countCouponOrders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collCouponOrdersPartial && !$this->isNew();
+ if (null === $this->collCouponOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collCouponOrders) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getCouponOrders());
+ }
+
+ $query = ChildCouponOrderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrder($this)
+ ->count($con);
+ }
+
+ return count($this->collCouponOrders);
+ }
+
+ /**
+ * Method called to associate a ChildCouponOrder object to this object
+ * through the ChildCouponOrder foreign key attribute.
+ *
+ * @param ChildCouponOrder $l ChildCouponOrder
+ * @return \Thelia\Model\Order The current object (for fluent API support)
+ */
+ public function addCouponOrder(ChildCouponOrder $l)
+ {
+ if ($this->collCouponOrders === null) {
+ $this->initCouponOrders();
+ $this->collCouponOrdersPartial = true;
+ }
+
+ if (!in_array($l, $this->collCouponOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddCouponOrder($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param CouponOrder $couponOrder The couponOrder object to add.
+ */
+ protected function doAddCouponOrder($couponOrder)
+ {
+ $this->collCouponOrders[]= $couponOrder;
+ $couponOrder->setOrder($this);
+ }
+
+ /**
+ * @param CouponOrder $couponOrder The couponOrder object to remove.
+ * @return ChildOrder The current object (for fluent API support)
+ */
+ public function removeCouponOrder($couponOrder)
+ {
+ if ($this->getCouponOrders()->contains($couponOrder)) {
+ $this->collCouponOrders->remove($this->collCouponOrders->search($couponOrder));
+ if (null === $this->couponOrdersScheduledForDeletion) {
+ $this->couponOrdersScheduledForDeletion = clone $this->collCouponOrders;
+ $this->couponOrdersScheduledForDeletion->clear();
+ }
+ $this->couponOrdersScheduledForDeletion[]= clone $couponOrder;
+ $couponOrder->setOrder(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->ref = null;
+ $this->customer_id = null;
+ $this->address_invoice = null;
+ $this->address_delivery = null;
+ $this->invoice_date = null;
+ $this->currency_id = null;
+ $this->currency_rate = null;
+ $this->transaction = null;
+ $this->delivery_num = null;
+ $this->invoice = null;
+ $this->postage = null;
+ $this->payment = null;
+ $this->carrier = null;
+ $this->status_id = null;
+ $this->lang = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collOrderProducts) {
+ foreach ($this->collOrderProducts as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCouponOrders) {
+ foreach ($this->collCouponOrders as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collOrderProducts instanceof Collection) {
+ $this->collOrderProducts->clearIterator();
+ }
+ $this->collOrderProducts = null;
+ if ($this->collCouponOrders instanceof Collection) {
+ $this->collCouponOrders->clearIterator();
+ }
+ $this->collCouponOrders = null;
+ $this->aCurrency = null;
+ $this->aCustomer = null;
+ $this->aOrderAddressRelatedByAddressInvoice = null;
+ $this->aOrderAddressRelatedByAddressDelivery = null;
+ $this->aOrderStatus = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildOrder The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = OrderTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/OrderAddress.php b/core/lib/Thelia/Model/Base/OrderAddress.php
new file mode 100644
index 000000000..b5ff32951
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderAddress.php
@@ -0,0 +1,2574 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another OrderAddress instance. If
+ * obj is an instance of OrderAddress, delegates to
+ * equals(OrderAddress). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return OrderAddress The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return OrderAddress The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [customer_title_id] column value.
+ *
+ * @return int
+ */
+ public function getCustomerTitleId()
+ {
+
+ return $this->customer_title_id;
+ }
+
+ /**
+ * Get the [company] column value.
+ *
+ * @return string
+ */
+ public function getCompany()
+ {
+
+ return $this->company;
+ }
+
+ /**
+ * Get the [firstname] column value.
+ *
+ * @return string
+ */
+ public function getFirstname()
+ {
+
+ return $this->firstname;
+ }
+
+ /**
+ * Get the [lastname] column value.
+ *
+ * @return string
+ */
+ public function getLastname()
+ {
+
+ return $this->lastname;
+ }
+
+ /**
+ * 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 [address3] column value.
+ *
+ * @return string
+ */
+ public function getAddress3()
+ {
+
+ return $this->address3;
+ }
+
+ /**
+ * Get the [zipcode] column value.
+ *
+ * @return string
+ */
+ public function getZipcode()
+ {
+
+ return $this->zipcode;
+ }
+
+ /**
+ * 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 [country_id] column value.
+ *
+ * @return int
+ */
+ public function getCountryId()
+ {
+
+ return $this->country_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = OrderAddressTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [customer_title_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function setCustomerTitleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->customer_title_id !== $v) {
+ $this->customer_title_id = $v;
+ $this->modifiedColumns[] = OrderAddressTableMap::CUSTOMER_TITLE_ID;
+ }
+
+
+ return $this;
+ } // setCustomerTitleId()
+
+ /**
+ * Set the value of [company] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function setCompany($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->company !== $v) {
+ $this->company = $v;
+ $this->modifiedColumns[] = OrderAddressTableMap::COMPANY;
+ }
+
+
+ return $this;
+ } // setCompany()
+
+ /**
+ * Set the value of [firstname] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function setFirstname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->firstname !== $v) {
+ $this->firstname = $v;
+ $this->modifiedColumns[] = OrderAddressTableMap::FIRSTNAME;
+ }
+
+
+ return $this;
+ } // setFirstname()
+
+ /**
+ * Set the value of [lastname] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function setLastname($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->lastname !== $v) {
+ $this->lastname = $v;
+ $this->modifiedColumns[] = OrderAddressTableMap::LASTNAME;
+ }
+
+
+ return $this;
+ } // setLastname()
+
+ /**
+ * Set the value of [address1] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function setAddress1($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address1 !== $v) {
+ $this->address1 = $v;
+ $this->modifiedColumns[] = OrderAddressTableMap::ADDRESS1;
+ }
+
+
+ return $this;
+ } // setAddress1()
+
+ /**
+ * Set the value of [address2] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function setAddress2($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address2 !== $v) {
+ $this->address2 = $v;
+ $this->modifiedColumns[] = OrderAddressTableMap::ADDRESS2;
+ }
+
+
+ return $this;
+ } // setAddress2()
+
+ /**
+ * Set the value of [address3] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function setAddress3($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->address3 !== $v) {
+ $this->address3 = $v;
+ $this->modifiedColumns[] = OrderAddressTableMap::ADDRESS3;
+ }
+
+
+ return $this;
+ } // setAddress3()
+
+ /**
+ * Set the value of [zipcode] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function setZipcode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->zipcode !== $v) {
+ $this->zipcode = $v;
+ $this->modifiedColumns[] = OrderAddressTableMap::ZIPCODE;
+ }
+
+
+ return $this;
+ } // setZipcode()
+
+ /**
+ * Set the value of [city] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function setCity($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->city !== $v) {
+ $this->city = $v;
+ $this->modifiedColumns[] = OrderAddressTableMap::CITY;
+ }
+
+
+ return $this;
+ } // setCity()
+
+ /**
+ * Set the value of [phone] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function setPhone($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->phone !== $v) {
+ $this->phone = $v;
+ $this->modifiedColumns[] = OrderAddressTableMap::PHONE;
+ }
+
+
+ return $this;
+ } // setPhone()
+
+ /**
+ * Set the value of [country_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function setCountryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->country_id !== $v) {
+ $this->country_id = $v;
+ $this->modifiedColumns[] = OrderAddressTableMap::COUNTRY_ID;
+ }
+
+
+ return $this;
+ } // setCountryId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = OrderAddressTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = OrderAddressTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderAddressTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderAddressTableMap::translateFieldName('CustomerTitleId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->customer_title_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderAddressTableMap::translateFieldName('Company', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->company = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderAddressTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->firstname = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderAddressTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->lastname = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderAddressTableMap::translateFieldName('Address1', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->address1 = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderAddressTableMap::translateFieldName('Address2', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->address2 = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderAddressTableMap::translateFieldName('Address3', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->address3 = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderAddressTableMap::translateFieldName('Zipcode', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->zipcode = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderAddressTableMap::translateFieldName('City', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->city = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderAddressTableMap::translateFieldName('Phone', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->phone = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderAddressTableMap::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->country_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderAddressTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderAddressTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 14; // 14 = OrderAddressTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\OrderAddress object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderAddressTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildOrderAddressQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collOrdersRelatedByAddressInvoice = null;
+
+ $this->collOrdersRelatedByAddressDelivery = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see OrderAddress::setDeleted()
+ * @see OrderAddress::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderAddressTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildOrderAddressQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderAddressTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(OrderAddressTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(OrderAddressTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(OrderAddressTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderAddressTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->ordersRelatedByAddressInvoiceScheduledForDeletion !== null) {
+ if (!$this->ordersRelatedByAddressInvoiceScheduledForDeletion->isEmpty()) {
+ foreach ($this->ordersRelatedByAddressInvoiceScheduledForDeletion as $orderRelatedByAddressInvoice) {
+ // need to save related object because we set the relation to null
+ $orderRelatedByAddressInvoice->save($con);
+ }
+ $this->ordersRelatedByAddressInvoiceScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrdersRelatedByAddressInvoice !== null) {
+ foreach ($this->collOrdersRelatedByAddressInvoice as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->ordersRelatedByAddressDeliveryScheduledForDeletion !== null) {
+ if (!$this->ordersRelatedByAddressDeliveryScheduledForDeletion->isEmpty()) {
+ foreach ($this->ordersRelatedByAddressDeliveryScheduledForDeletion as $orderRelatedByAddressDelivery) {
+ // need to save related object because we set the relation to null
+ $orderRelatedByAddressDelivery->save($con);
+ }
+ $this->ordersRelatedByAddressDeliveryScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrdersRelatedByAddressDelivery !== null) {
+ foreach ($this->collOrdersRelatedByAddressDelivery as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = OrderAddressTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderAddressTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderAddressTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(OrderAddressTableMap::CUSTOMER_TITLE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CUSTOMER_TITLE_ID';
+ }
+ if ($this->isColumnModified(OrderAddressTableMap::COMPANY)) {
+ $modifiedColumns[':p' . $index++] = 'COMPANY';
+ }
+ if ($this->isColumnModified(OrderAddressTableMap::FIRSTNAME)) {
+ $modifiedColumns[':p' . $index++] = 'FIRSTNAME';
+ }
+ if ($this->isColumnModified(OrderAddressTableMap::LASTNAME)) {
+ $modifiedColumns[':p' . $index++] = 'LASTNAME';
+ }
+ if ($this->isColumnModified(OrderAddressTableMap::ADDRESS1)) {
+ $modifiedColumns[':p' . $index++] = 'ADDRESS1';
+ }
+ if ($this->isColumnModified(OrderAddressTableMap::ADDRESS2)) {
+ $modifiedColumns[':p' . $index++] = 'ADDRESS2';
+ }
+ if ($this->isColumnModified(OrderAddressTableMap::ADDRESS3)) {
+ $modifiedColumns[':p' . $index++] = 'ADDRESS3';
+ }
+ if ($this->isColumnModified(OrderAddressTableMap::ZIPCODE)) {
+ $modifiedColumns[':p' . $index++] = 'ZIPCODE';
+ }
+ if ($this->isColumnModified(OrderAddressTableMap::CITY)) {
+ $modifiedColumns[':p' . $index++] = 'CITY';
+ }
+ if ($this->isColumnModified(OrderAddressTableMap::PHONE)) {
+ $modifiedColumns[':p' . $index++] = 'PHONE';
+ }
+ if ($this->isColumnModified(OrderAddressTableMap::COUNTRY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'COUNTRY_ID';
+ }
+ if ($this->isColumnModified(OrderAddressTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(OrderAddressTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO order_address (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'CUSTOMER_TITLE_ID':
+ $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT);
+ break;
+ case 'COMPANY':
+ $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR);
+ break;
+ case 'FIRSTNAME':
+ $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR);
+ break;
+ case 'LASTNAME':
+ $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR);
+ break;
+ case 'ADDRESS1':
+ $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR);
+ break;
+ case 'ADDRESS2':
+ $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR);
+ break;
+ case 'ADDRESS3':
+ $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR);
+ break;
+ case 'ZIPCODE':
+ $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR);
+ break;
+ case 'CITY':
+ $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR);
+ break;
+ case 'PHONE':
+ $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR);
+ break;
+ case 'COUNTRY_ID':
+ $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderAddressTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getCustomerTitleId();
+ break;
+ case 2:
+ return $this->getCompany();
+ break;
+ case 3:
+ return $this->getFirstname();
+ break;
+ case 4:
+ return $this->getLastname();
+ break;
+ case 5:
+ return $this->getAddress1();
+ break;
+ case 6:
+ return $this->getAddress2();
+ break;
+ case 7:
+ return $this->getAddress3();
+ break;
+ case 8:
+ return $this->getZipcode();
+ break;
+ case 9:
+ return $this->getCity();
+ break;
+ case 10:
+ return $this->getPhone();
+ break;
+ case 11:
+ return $this->getCountryId();
+ break;
+ case 12:
+ return $this->getCreatedAt();
+ break;
+ case 13:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['OrderAddress'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['OrderAddress'][$this->getPrimaryKey()] = true;
+ $keys = OrderAddressTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCustomerTitleId(),
+ $keys[2] => $this->getCompany(),
+ $keys[3] => $this->getFirstname(),
+ $keys[4] => $this->getLastname(),
+ $keys[5] => $this->getAddress1(),
+ $keys[6] => $this->getAddress2(),
+ $keys[7] => $this->getAddress3(),
+ $keys[8] => $this->getZipcode(),
+ $keys[9] => $this->getCity(),
+ $keys[10] => $this->getPhone(),
+ $keys[11] => $this->getCountryId(),
+ $keys[12] => $this->getCreatedAt(),
+ $keys[13] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collOrdersRelatedByAddressInvoice) {
+ $result['OrdersRelatedByAddressInvoice'] = $this->collOrdersRelatedByAddressInvoice->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collOrdersRelatedByAddressDelivery) {
+ $result['OrdersRelatedByAddressDelivery'] = $this->collOrdersRelatedByAddressDelivery->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderAddressTableMap::translateFieldName($name, $type, TableMap::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->setCustomerTitleId($value);
+ break;
+ case 2:
+ $this->setCompany($value);
+ break;
+ case 3:
+ $this->setFirstname($value);
+ break;
+ case 4:
+ $this->setLastname($value);
+ break;
+ case 5:
+ $this->setAddress1($value);
+ break;
+ case 6:
+ $this->setAddress2($value);
+ break;
+ case 7:
+ $this->setAddress3($value);
+ break;
+ case 8:
+ $this->setZipcode($value);
+ break;
+ case 9:
+ $this->setCity($value);
+ break;
+ case 10:
+ $this->setPhone($value);
+ break;
+ case 11:
+ $this->setCountryId($value);
+ break;
+ case 12:
+ $this->setCreatedAt($value);
+ break;
+ case 13:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = OrderAddressTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCustomerTitleId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCompany($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setFirstname($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setLastname($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->setAddress3($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setZipcode($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setCity($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setPhone($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setCountryId($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]);
+ }
+
+ /**
+ * 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(OrderAddressTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderAddressTableMap::ID)) $criteria->add(OrderAddressTableMap::ID, $this->id);
+ if ($this->isColumnModified(OrderAddressTableMap::CUSTOMER_TITLE_ID)) $criteria->add(OrderAddressTableMap::CUSTOMER_TITLE_ID, $this->customer_title_id);
+ if ($this->isColumnModified(OrderAddressTableMap::COMPANY)) $criteria->add(OrderAddressTableMap::COMPANY, $this->company);
+ if ($this->isColumnModified(OrderAddressTableMap::FIRSTNAME)) $criteria->add(OrderAddressTableMap::FIRSTNAME, $this->firstname);
+ if ($this->isColumnModified(OrderAddressTableMap::LASTNAME)) $criteria->add(OrderAddressTableMap::LASTNAME, $this->lastname);
+ if ($this->isColumnModified(OrderAddressTableMap::ADDRESS1)) $criteria->add(OrderAddressTableMap::ADDRESS1, $this->address1);
+ if ($this->isColumnModified(OrderAddressTableMap::ADDRESS2)) $criteria->add(OrderAddressTableMap::ADDRESS2, $this->address2);
+ if ($this->isColumnModified(OrderAddressTableMap::ADDRESS3)) $criteria->add(OrderAddressTableMap::ADDRESS3, $this->address3);
+ if ($this->isColumnModified(OrderAddressTableMap::ZIPCODE)) $criteria->add(OrderAddressTableMap::ZIPCODE, $this->zipcode);
+ if ($this->isColumnModified(OrderAddressTableMap::CITY)) $criteria->add(OrderAddressTableMap::CITY, $this->city);
+ if ($this->isColumnModified(OrderAddressTableMap::PHONE)) $criteria->add(OrderAddressTableMap::PHONE, $this->phone);
+ if ($this->isColumnModified(OrderAddressTableMap::COUNTRY_ID)) $criteria->add(OrderAddressTableMap::COUNTRY_ID, $this->country_id);
+ if ($this->isColumnModified(OrderAddressTableMap::CREATED_AT)) $criteria->add(OrderAddressTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(OrderAddressTableMap::UPDATED_AT)) $criteria->add(OrderAddressTableMap::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(OrderAddressTableMap::DATABASE_NAME);
+ $criteria->add(OrderAddressTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\OrderAddress (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCustomerTitleId($this->getCustomerTitleId());
+ $copyObj->setCompany($this->getCompany());
+ $copyObj->setFirstname($this->getFirstname());
+ $copyObj->setLastname($this->getLastname());
+ $copyObj->setAddress1($this->getAddress1());
+ $copyObj->setAddress2($this->getAddress2());
+ $copyObj->setAddress3($this->getAddress3());
+ $copyObj->setZipcode($this->getZipcode());
+ $copyObj->setCity($this->getCity());
+ $copyObj->setPhone($this->getPhone());
+ $copyObj->setCountryId($this->getCountryId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getOrdersRelatedByAddressInvoice() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderRelatedByAddressInvoice($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getOrdersRelatedByAddressDelivery() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderRelatedByAddressDelivery($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\OrderAddress 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('OrderRelatedByAddressInvoice' == $relationName) {
+ return $this->initOrdersRelatedByAddressInvoice();
+ }
+ if ('OrderRelatedByAddressDelivery' == $relationName) {
+ return $this->initOrdersRelatedByAddressDelivery();
+ }
+ }
+
+ /**
+ * Clears out the collOrdersRelatedByAddressInvoice collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addOrdersRelatedByAddressInvoice()
+ */
+ public function clearOrdersRelatedByAddressInvoice()
+ {
+ $this->collOrdersRelatedByAddressInvoice = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collOrdersRelatedByAddressInvoice collection loaded partially.
+ */
+ public function resetPartialOrdersRelatedByAddressInvoice($v = true)
+ {
+ $this->collOrdersRelatedByAddressInvoicePartial = $v;
+ }
+
+ /**
+ * Initializes the collOrdersRelatedByAddressInvoice collection.
+ *
+ * By default this just sets the collOrdersRelatedByAddressInvoice collection to an empty array (like clearcollOrdersRelatedByAddressInvoice());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initOrdersRelatedByAddressInvoice($overrideExisting = true)
+ {
+ if (null !== $this->collOrdersRelatedByAddressInvoice && !$overrideExisting) {
+ return;
+ }
+ $this->collOrdersRelatedByAddressInvoice = new ObjectCollection();
+ $this->collOrdersRelatedByAddressInvoice->setModel('\Thelia\Model\Order');
+ }
+
+ /**
+ * Gets an array of ChildOrder objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildOrderAddress is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ * @throws PropelException
+ */
+ public function getOrdersRelatedByAddressInvoice($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrdersRelatedByAddressInvoicePartial && !$this->isNew();
+ if (null === $this->collOrdersRelatedByAddressInvoice || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrdersRelatedByAddressInvoice) {
+ // return empty collection
+ $this->initOrdersRelatedByAddressInvoice();
+ } else {
+ $collOrdersRelatedByAddressInvoice = ChildOrderQuery::create(null, $criteria)
+ ->filterByOrderAddressRelatedByAddressInvoice($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collOrdersRelatedByAddressInvoicePartial && count($collOrdersRelatedByAddressInvoice)) {
+ $this->initOrdersRelatedByAddressInvoice(false);
+
+ foreach ($collOrdersRelatedByAddressInvoice as $obj) {
+ if (false == $this->collOrdersRelatedByAddressInvoice->contains($obj)) {
+ $this->collOrdersRelatedByAddressInvoice->append($obj);
+ }
+ }
+
+ $this->collOrdersRelatedByAddressInvoicePartial = true;
+ }
+
+ $collOrdersRelatedByAddressInvoice->getInternalIterator()->rewind();
+
+ return $collOrdersRelatedByAddressInvoice;
+ }
+
+ if ($partial && $this->collOrdersRelatedByAddressInvoice) {
+ foreach ($this->collOrdersRelatedByAddressInvoice as $obj) {
+ if ($obj->isNew()) {
+ $collOrdersRelatedByAddressInvoice[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrdersRelatedByAddressInvoice = $collOrdersRelatedByAddressInvoice;
+ $this->collOrdersRelatedByAddressInvoicePartial = false;
+ }
+ }
+
+ return $this->collOrdersRelatedByAddressInvoice;
+ }
+
+ /**
+ * Sets a collection of OrderRelatedByAddressInvoice objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $ordersRelatedByAddressInvoice A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildOrderAddress The current object (for fluent API support)
+ */
+ public function setOrdersRelatedByAddressInvoice(Collection $ordersRelatedByAddressInvoice, ConnectionInterface $con = null)
+ {
+ $ordersRelatedByAddressInvoiceToDelete = $this->getOrdersRelatedByAddressInvoice(new Criteria(), $con)->diff($ordersRelatedByAddressInvoice);
+
+
+ $this->ordersRelatedByAddressInvoiceScheduledForDeletion = $ordersRelatedByAddressInvoiceToDelete;
+
+ foreach ($ordersRelatedByAddressInvoiceToDelete as $orderRelatedByAddressInvoiceRemoved) {
+ $orderRelatedByAddressInvoiceRemoved->setOrderAddressRelatedByAddressInvoice(null);
+ }
+
+ $this->collOrdersRelatedByAddressInvoice = null;
+ foreach ($ordersRelatedByAddressInvoice as $orderRelatedByAddressInvoice) {
+ $this->addOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice);
+ }
+
+ $this->collOrdersRelatedByAddressInvoice = $ordersRelatedByAddressInvoice;
+ $this->collOrdersRelatedByAddressInvoicePartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Order objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Order objects.
+ * @throws PropelException
+ */
+ public function countOrdersRelatedByAddressInvoice(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrdersRelatedByAddressInvoicePartial && !$this->isNew();
+ if (null === $this->collOrdersRelatedByAddressInvoice || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrdersRelatedByAddressInvoice) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getOrdersRelatedByAddressInvoice());
+ }
+
+ $query = ChildOrderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrderAddressRelatedByAddressInvoice($this)
+ ->count($con);
+ }
+
+ return count($this->collOrdersRelatedByAddressInvoice);
+ }
+
+ /**
+ * Method called to associate a ChildOrder object to this object
+ * through the ChildOrder foreign key attribute.
+ *
+ * @param ChildOrder $l ChildOrder
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function addOrderRelatedByAddressInvoice(ChildOrder $l)
+ {
+ if ($this->collOrdersRelatedByAddressInvoice === null) {
+ $this->initOrdersRelatedByAddressInvoice();
+ $this->collOrdersRelatedByAddressInvoicePartial = true;
+ }
+
+ if (!in_array($l, $this->collOrdersRelatedByAddressInvoice->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderRelatedByAddressInvoice($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to add.
+ */
+ protected function doAddOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice)
+ {
+ $this->collOrdersRelatedByAddressInvoice[]= $orderRelatedByAddressInvoice;
+ $orderRelatedByAddressInvoice->setOrderAddressRelatedByAddressInvoice($this);
+ }
+
+ /**
+ * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to remove.
+ * @return ChildOrderAddress The current object (for fluent API support)
+ */
+ public function removeOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice)
+ {
+ if ($this->getOrdersRelatedByAddressInvoice()->contains($orderRelatedByAddressInvoice)) {
+ $this->collOrdersRelatedByAddressInvoice->remove($this->collOrdersRelatedByAddressInvoice->search($orderRelatedByAddressInvoice));
+ if (null === $this->ordersRelatedByAddressInvoiceScheduledForDeletion) {
+ $this->ordersRelatedByAddressInvoiceScheduledForDeletion = clone $this->collOrdersRelatedByAddressInvoice;
+ $this->ordersRelatedByAddressInvoiceScheduledForDeletion->clear();
+ }
+ $this->ordersRelatedByAddressInvoiceScheduledForDeletion[]= $orderRelatedByAddressInvoice;
+ $orderRelatedByAddressInvoice->setOrderAddressRelatedByAddressInvoice(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderAddress is new, it will return
+ * an empty collection; or if this OrderAddress has previously
+ * been saved, it will retrieve related OrdersRelatedByAddressInvoice 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 OrderAddress.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersRelatedByAddressInvoiceJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('Currency', $joinBehavior);
+
+ return $this->getOrdersRelatedByAddressInvoice($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderAddress is new, it will return
+ * an empty collection; or if this OrderAddress has previously
+ * been saved, it will retrieve related OrdersRelatedByAddressInvoice 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 OrderAddress.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersRelatedByAddressInvoiceJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('Customer', $joinBehavior);
+
+ return $this->getOrdersRelatedByAddressInvoice($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderAddress is new, it will return
+ * an empty collection; or if this OrderAddress has previously
+ * been saved, it will retrieve related OrdersRelatedByAddressInvoice 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 OrderAddress.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersRelatedByAddressInvoiceJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('OrderStatus', $joinBehavior);
+
+ return $this->getOrdersRelatedByAddressInvoice($query, $con);
+ }
+
+ /**
+ * Clears out the collOrdersRelatedByAddressDelivery collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addOrdersRelatedByAddressDelivery()
+ */
+ public function clearOrdersRelatedByAddressDelivery()
+ {
+ $this->collOrdersRelatedByAddressDelivery = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collOrdersRelatedByAddressDelivery collection loaded partially.
+ */
+ public function resetPartialOrdersRelatedByAddressDelivery($v = true)
+ {
+ $this->collOrdersRelatedByAddressDeliveryPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrdersRelatedByAddressDelivery collection.
+ *
+ * By default this just sets the collOrdersRelatedByAddressDelivery collection to an empty array (like clearcollOrdersRelatedByAddressDelivery());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initOrdersRelatedByAddressDelivery($overrideExisting = true)
+ {
+ if (null !== $this->collOrdersRelatedByAddressDelivery && !$overrideExisting) {
+ return;
+ }
+ $this->collOrdersRelatedByAddressDelivery = new ObjectCollection();
+ $this->collOrdersRelatedByAddressDelivery->setModel('\Thelia\Model\Order');
+ }
+
+ /**
+ * Gets an array of ChildOrder objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildOrderAddress is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ * @throws PropelException
+ */
+ public function getOrdersRelatedByAddressDelivery($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrdersRelatedByAddressDeliveryPartial && !$this->isNew();
+ if (null === $this->collOrdersRelatedByAddressDelivery || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrdersRelatedByAddressDelivery) {
+ // return empty collection
+ $this->initOrdersRelatedByAddressDelivery();
+ } else {
+ $collOrdersRelatedByAddressDelivery = ChildOrderQuery::create(null, $criteria)
+ ->filterByOrderAddressRelatedByAddressDelivery($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collOrdersRelatedByAddressDeliveryPartial && count($collOrdersRelatedByAddressDelivery)) {
+ $this->initOrdersRelatedByAddressDelivery(false);
+
+ foreach ($collOrdersRelatedByAddressDelivery as $obj) {
+ if (false == $this->collOrdersRelatedByAddressDelivery->contains($obj)) {
+ $this->collOrdersRelatedByAddressDelivery->append($obj);
+ }
+ }
+
+ $this->collOrdersRelatedByAddressDeliveryPartial = true;
+ }
+
+ $collOrdersRelatedByAddressDelivery->getInternalIterator()->rewind();
+
+ return $collOrdersRelatedByAddressDelivery;
+ }
+
+ if ($partial && $this->collOrdersRelatedByAddressDelivery) {
+ foreach ($this->collOrdersRelatedByAddressDelivery as $obj) {
+ if ($obj->isNew()) {
+ $collOrdersRelatedByAddressDelivery[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrdersRelatedByAddressDelivery = $collOrdersRelatedByAddressDelivery;
+ $this->collOrdersRelatedByAddressDeliveryPartial = false;
+ }
+ }
+
+ return $this->collOrdersRelatedByAddressDelivery;
+ }
+
+ /**
+ * Sets a collection of OrderRelatedByAddressDelivery objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $ordersRelatedByAddressDelivery A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildOrderAddress The current object (for fluent API support)
+ */
+ public function setOrdersRelatedByAddressDelivery(Collection $ordersRelatedByAddressDelivery, ConnectionInterface $con = null)
+ {
+ $ordersRelatedByAddressDeliveryToDelete = $this->getOrdersRelatedByAddressDelivery(new Criteria(), $con)->diff($ordersRelatedByAddressDelivery);
+
+
+ $this->ordersRelatedByAddressDeliveryScheduledForDeletion = $ordersRelatedByAddressDeliveryToDelete;
+
+ foreach ($ordersRelatedByAddressDeliveryToDelete as $orderRelatedByAddressDeliveryRemoved) {
+ $orderRelatedByAddressDeliveryRemoved->setOrderAddressRelatedByAddressDelivery(null);
+ }
+
+ $this->collOrdersRelatedByAddressDelivery = null;
+ foreach ($ordersRelatedByAddressDelivery as $orderRelatedByAddressDelivery) {
+ $this->addOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery);
+ }
+
+ $this->collOrdersRelatedByAddressDelivery = $ordersRelatedByAddressDelivery;
+ $this->collOrdersRelatedByAddressDeliveryPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Order objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Order objects.
+ * @throws PropelException
+ */
+ public function countOrdersRelatedByAddressDelivery(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrdersRelatedByAddressDeliveryPartial && !$this->isNew();
+ if (null === $this->collOrdersRelatedByAddressDelivery || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrdersRelatedByAddressDelivery) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getOrdersRelatedByAddressDelivery());
+ }
+
+ $query = ChildOrderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrderAddressRelatedByAddressDelivery($this)
+ ->count($con);
+ }
+
+ return count($this->collOrdersRelatedByAddressDelivery);
+ }
+
+ /**
+ * Method called to associate a ChildOrder object to this object
+ * through the ChildOrder foreign key attribute.
+ *
+ * @param ChildOrder $l ChildOrder
+ * @return \Thelia\Model\OrderAddress The current object (for fluent API support)
+ */
+ public function addOrderRelatedByAddressDelivery(ChildOrder $l)
+ {
+ if ($this->collOrdersRelatedByAddressDelivery === null) {
+ $this->initOrdersRelatedByAddressDelivery();
+ $this->collOrdersRelatedByAddressDeliveryPartial = true;
+ }
+
+ if (!in_array($l, $this->collOrdersRelatedByAddressDelivery->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderRelatedByAddressDelivery($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to add.
+ */
+ protected function doAddOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery)
+ {
+ $this->collOrdersRelatedByAddressDelivery[]= $orderRelatedByAddressDelivery;
+ $orderRelatedByAddressDelivery->setOrderAddressRelatedByAddressDelivery($this);
+ }
+
+ /**
+ * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to remove.
+ * @return ChildOrderAddress The current object (for fluent API support)
+ */
+ public function removeOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery)
+ {
+ if ($this->getOrdersRelatedByAddressDelivery()->contains($orderRelatedByAddressDelivery)) {
+ $this->collOrdersRelatedByAddressDelivery->remove($this->collOrdersRelatedByAddressDelivery->search($orderRelatedByAddressDelivery));
+ if (null === $this->ordersRelatedByAddressDeliveryScheduledForDeletion) {
+ $this->ordersRelatedByAddressDeliveryScheduledForDeletion = clone $this->collOrdersRelatedByAddressDelivery;
+ $this->ordersRelatedByAddressDeliveryScheduledForDeletion->clear();
+ }
+ $this->ordersRelatedByAddressDeliveryScheduledForDeletion[]= $orderRelatedByAddressDelivery;
+ $orderRelatedByAddressDelivery->setOrderAddressRelatedByAddressDelivery(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderAddress is new, it will return
+ * an empty collection; or if this OrderAddress has previously
+ * been saved, it will retrieve related OrdersRelatedByAddressDelivery 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 OrderAddress.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersRelatedByAddressDeliveryJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('Currency', $joinBehavior);
+
+ return $this->getOrdersRelatedByAddressDelivery($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderAddress is new, it will return
+ * an empty collection; or if this OrderAddress has previously
+ * been saved, it will retrieve related OrdersRelatedByAddressDelivery 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 OrderAddress.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersRelatedByAddressDeliveryJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('Customer', $joinBehavior);
+
+ return $this->getOrdersRelatedByAddressDelivery($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderAddress is new, it will return
+ * an empty collection; or if this OrderAddress has previously
+ * been saved, it will retrieve related OrdersRelatedByAddressDelivery 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 OrderAddress.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersRelatedByAddressDeliveryJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('OrderStatus', $joinBehavior);
+
+ return $this->getOrdersRelatedByAddressDelivery($query, $con);
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->customer_title_id = null;
+ $this->company = null;
+ $this->firstname = null;
+ $this->lastname = null;
+ $this->address1 = null;
+ $this->address2 = null;
+ $this->address3 = null;
+ $this->zipcode = null;
+ $this->city = null;
+ $this->phone = null;
+ $this->country_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collOrdersRelatedByAddressInvoice) {
+ foreach ($this->collOrdersRelatedByAddressInvoice as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collOrdersRelatedByAddressDelivery) {
+ foreach ($this->collOrdersRelatedByAddressDelivery as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collOrdersRelatedByAddressInvoice instanceof Collection) {
+ $this->collOrdersRelatedByAddressInvoice->clearIterator();
+ }
+ $this->collOrdersRelatedByAddressInvoice = null;
+ if ($this->collOrdersRelatedByAddressDelivery instanceof Collection) {
+ $this->collOrdersRelatedByAddressDelivery->clearIterator();
+ }
+ $this->collOrdersRelatedByAddressDelivery = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderAddressTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildOrderAddress The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = OrderAddressTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/OrderAddressQuery.php b/core/lib/Thelia/Model/Base/OrderAddressQuery.php
new file mode 100644
index 000000000..0552feb85
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderAddressQuery.php
@@ -0,0 +1,1048 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildOrderAddress|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderAddressTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderAddressTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildOrderAddress A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CUSTOMER_TITLE_ID, COMPANY, FIRSTNAME, LASTNAME, ADDRESS1, ADDRESS2, ADDRESS3, ZIPCODE, CITY, PHONE, COUNTRY_ID, CREATED_AT, UPDATED_AT FROM order_address WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildOrderAddress();
+ $obj->hydrate($row);
+ OrderAddressTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildOrderAddress|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(OrderAddressTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(OrderAddressTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(OrderAddressTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(OrderAddressTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_title_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234
+ * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34)
+ * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12
+ *
+ *
+ * @param mixed $customerTitleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByCustomerTitleId($customerTitleId = null, $comparison = null)
+ {
+ if (is_array($customerTitleId)) {
+ $useMinMax = false;
+ if (isset($customerTitleId['min'])) {
+ $this->addUsingAlias(OrderAddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerTitleId['max'])) {
+ $this->addUsingAlias(OrderAddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the company column
+ *
+ * Example usage:
+ *
+ * $query->filterByCompany('fooValue'); // WHERE company = 'fooValue'
+ * $query->filterByCompany('%fooValue%'); // WHERE company LIKE '%fooValue%'
+ *
+ *
+ * @param string $company The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByCompany($company = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($company)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $company)) {
+ $company = str_replace('*', '%', $company);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressTableMap::COMPANY, $company, $comparison);
+ }
+
+ /**
+ * Filter the query on the firstname column
+ *
+ * Example usage:
+ *
+ * $query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue'
+ * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%'
+ *
+ *
+ * @param string $firstname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByFirstname($firstname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($firstname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $firstname)) {
+ $firstname = str_replace('*', '%', $firstname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressTableMap::FIRSTNAME, $firstname, $comparison);
+ }
+
+ /**
+ * Filter the query on the lastname column
+ *
+ * Example usage:
+ *
+ * $query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue'
+ * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%'
+ *
+ *
+ * @param string $lastname The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByLastname($lastname = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lastname)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lastname)) {
+ $lastname = str_replace('*', '%', $lastname);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressTableMap::LASTNAME, $lastname, $comparison);
+ }
+
+ /**
+ * Filter the query on the address1 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress1('fooValue'); // WHERE address1 = 'fooValue'
+ * $query->filterByAddress1('%fooValue%'); // WHERE address1 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address1 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress1($address1 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address1)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address1)) {
+ $address1 = str_replace('*', '%', $address1);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressTableMap::ADDRESS1, $address1, $comparison);
+ }
+
+ /**
+ * Filter the query on the address2 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress2('fooValue'); // WHERE address2 = 'fooValue'
+ * $query->filterByAddress2('%fooValue%'); // WHERE address2 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address2 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress2($address2 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address2)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address2)) {
+ $address2 = str_replace('*', '%', $address2);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressTableMap::ADDRESS2, $address2, $comparison);
+ }
+
+ /**
+ * Filter the query on the address3 column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddress3('fooValue'); // WHERE address3 = 'fooValue'
+ * $query->filterByAddress3('%fooValue%'); // WHERE address3 LIKE '%fooValue%'
+ *
+ *
+ * @param string $address3 The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByAddress3($address3 = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($address3)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $address3)) {
+ $address3 = str_replace('*', '%', $address3);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressTableMap::ADDRESS3, $address3, $comparison);
+ }
+
+ /**
+ * Filter the query on the zipcode column
+ *
+ * Example usage:
+ *
+ * $query->filterByZipcode('fooValue'); // WHERE zipcode = 'fooValue'
+ * $query->filterByZipcode('%fooValue%'); // WHERE zipcode LIKE '%fooValue%'
+ *
+ *
+ * @param string $zipcode The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByZipcode($zipcode = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($zipcode)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $zipcode)) {
+ $zipcode = str_replace('*', '%', $zipcode);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressTableMap::ZIPCODE, $zipcode, $comparison);
+ }
+
+ /**
+ * Filter the query on the city column
+ *
+ * Example usage:
+ *
+ * $query->filterByCity('fooValue'); // WHERE city = 'fooValue'
+ * $query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%'
+ *
+ *
+ * @param string $city The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByCity($city = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($city)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $city)) {
+ $city = str_replace('*', '%', $city);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressTableMap::CITY, $city, $comparison);
+ }
+
+ /**
+ * Filter the query on the phone column
+ *
+ * Example usage:
+ *
+ * $query->filterByPhone('fooValue'); // WHERE phone = 'fooValue'
+ * $query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%'
+ *
+ *
+ * @param string $phone The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByPhone($phone = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($phone)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $phone)) {
+ $phone = str_replace('*', '%', $phone);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressTableMap::PHONE, $phone, $comparison);
+ }
+
+ /**
+ * Filter the query on the country_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCountryId(1234); // WHERE country_id = 1234
+ * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
+ * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
+ *
+ *
+ * @param mixed $countryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByCountryId($countryId = null, $comparison = null)
+ {
+ if (is_array($countryId)) {
+ $useMinMax = false;
+ if (isset($countryId['min'])) {
+ $this->addUsingAlias(OrderAddressTableMap::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($countryId['max'])) {
+ $this->addUsingAlias(OrderAddressTableMap::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressTableMap::COUNTRY_ID, $countryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(OrderAddressTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(OrderAddressTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(OrderAddressTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(OrderAddressTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderAddressTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Order object
+ *
+ * @param \Thelia\Model\Order|ObjectCollection $order the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByOrderRelatedByAddressInvoice($order, $comparison = null)
+ {
+ if ($order instanceof \Thelia\Model\Order) {
+ return $this
+ ->addUsingAlias(OrderAddressTableMap::ID, $order->getAddressInvoice(), $comparison);
+ } elseif ($order instanceof ObjectCollection) {
+ return $this
+ ->useOrderRelatedByAddressInvoiceQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderRelatedByAddressInvoice() only accepts arguments of type \Thelia\Model\Order or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderRelatedByAddressInvoice relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function joinOrderRelatedByAddressInvoice($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderRelatedByAddressInvoice');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'OrderRelatedByAddressInvoice');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderRelatedByAddressInvoice relation Order object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderRelatedByAddressInvoiceQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinOrderRelatedByAddressInvoice($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByAddressInvoice', '\Thelia\Model\OrderQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Order object
+ *
+ * @param \Thelia\Model\Order|ObjectCollection $order the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function filterByOrderRelatedByAddressDelivery($order, $comparison = null)
+ {
+ if ($order instanceof \Thelia\Model\Order) {
+ return $this
+ ->addUsingAlias(OrderAddressTableMap::ID, $order->getAddressDelivery(), $comparison);
+ } elseif ($order instanceof ObjectCollection) {
+ return $this
+ ->useOrderRelatedByAddressDeliveryQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderRelatedByAddressDelivery() only accepts arguments of type \Thelia\Model\Order or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderRelatedByAddressDelivery relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function joinOrderRelatedByAddressDelivery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderRelatedByAddressDelivery');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'OrderRelatedByAddressDelivery');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderRelatedByAddressDelivery relation Order object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderRelatedByAddressDeliveryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinOrderRelatedByAddressDelivery($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByAddressDelivery', '\Thelia\Model\OrderQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildOrderAddress $orderAddress Object to remove from the list of results
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function prune($orderAddress = null)
+ {
+ if ($orderAddress) {
+ $this->addUsingAlias(OrderAddressTableMap::ID, $orderAddress->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the order_address table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderAddressTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ OrderAddressTableMap::clearInstancePool();
+ OrderAddressTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildOrderAddress or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildOrderAddress object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderAddressTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderAddressTableMap::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->beginTransaction();
+
+
+ OrderAddressTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ OrderAddressTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(OrderAddressTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(OrderAddressTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(OrderAddressTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(OrderAddressTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(OrderAddressTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildOrderAddressQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(OrderAddressTableMap::CREATED_AT);
+ }
+
+} // OrderAddressQuery
diff --git a/core/lib/Thelia/Model/Base/OrderFeature.php b/core/lib/Thelia/Model/Base/OrderFeature.php
new file mode 100644
index 000000000..49c1a0911
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderFeature.php
@@ -0,0 +1,1476 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another OrderFeature instance. If
+ * obj is an instance of OrderFeature, delegates to
+ * equals(OrderFeature). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return OrderFeature The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return OrderFeature The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [order_product_id] column value.
+ *
+ * @return int
+ */
+ public function getOrderProductId()
+ {
+
+ return $this->order_product_id;
+ }
+
+ /**
+ * Get the [feature_desc] column value.
+ *
+ * @return string
+ */
+ public function getFeatureDesc()
+ {
+
+ return $this->feature_desc;
+ }
+
+ /**
+ * Get the [feature_av_desc] column value.
+ *
+ * @return string
+ */
+ public function getFeatureAvDesc()
+ {
+
+ return $this->feature_av_desc;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\OrderFeature The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = OrderFeatureTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [order_product_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\OrderFeature The current object (for fluent API support)
+ */
+ public function setOrderProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->order_product_id !== $v) {
+ $this->order_product_id = $v;
+ $this->modifiedColumns[] = OrderFeatureTableMap::ORDER_PRODUCT_ID;
+ }
+
+ if ($this->aOrderProduct !== null && $this->aOrderProduct->getId() !== $v) {
+ $this->aOrderProduct = null;
+ }
+
+
+ return $this;
+ } // setOrderProductId()
+
+ /**
+ * Set the value of [feature_desc] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderFeature The current object (for fluent API support)
+ */
+ public function setFeatureDesc($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->feature_desc !== $v) {
+ $this->feature_desc = $v;
+ $this->modifiedColumns[] = OrderFeatureTableMap::FEATURE_DESC;
+ }
+
+
+ return $this;
+ } // setFeatureDesc()
+
+ /**
+ * Set the value of [feature_av_desc] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderFeature The current object (for fluent API support)
+ */
+ public function setFeatureAvDesc($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->feature_av_desc !== $v) {
+ $this->feature_av_desc = $v;
+ $this->modifiedColumns[] = OrderFeatureTableMap::FEATURE_AV_DESC;
+ }
+
+
+ return $this;
+ } // setFeatureAvDesc()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\OrderFeature The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = OrderFeatureTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\OrderFeature The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = OrderFeatureTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderFeatureTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderFeatureTableMap::translateFieldName('OrderProductId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->order_product_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderFeatureTableMap::translateFieldName('FeatureDesc', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->feature_desc = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderFeatureTableMap::translateFieldName('FeatureAvDesc', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->feature_av_desc = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderFeatureTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderFeatureTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = OrderFeatureTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\OrderFeature object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aOrderProduct !== null && $this->order_product_id !== $this->aOrderProduct->getId()) {
+ $this->aOrderProduct = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderFeatureTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildOrderFeatureQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aOrderProduct = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see OrderFeature::setDeleted()
+ * @see OrderFeature::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderFeatureTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildOrderFeatureQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderFeatureTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(OrderFeatureTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(OrderFeatureTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(OrderFeatureTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderFeatureTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aOrderProduct !== null) {
+ if ($this->aOrderProduct->isModified() || $this->aOrderProduct->isNew()) {
+ $affectedRows += $this->aOrderProduct->save($con);
+ }
+ $this->setOrderProduct($this->aOrderProduct);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = OrderFeatureTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderFeatureTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderFeatureTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(OrderFeatureTableMap::ORDER_PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'ORDER_PRODUCT_ID';
+ }
+ if ($this->isColumnModified(OrderFeatureTableMap::FEATURE_DESC)) {
+ $modifiedColumns[':p' . $index++] = 'FEATURE_DESC';
+ }
+ if ($this->isColumnModified(OrderFeatureTableMap::FEATURE_AV_DESC)) {
+ $modifiedColumns[':p' . $index++] = 'FEATURE_AV_DESC';
+ }
+ if ($this->isColumnModified(OrderFeatureTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(OrderFeatureTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO order_feature (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'ORDER_PRODUCT_ID':
+ $stmt->bindValue($identifier, $this->order_product_id, PDO::PARAM_INT);
+ break;
+ case 'FEATURE_DESC':
+ $stmt->bindValue($identifier, $this->feature_desc, PDO::PARAM_STR);
+ break;
+ case 'FEATURE_AV_DESC':
+ $stmt->bindValue($identifier, $this->feature_av_desc, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderFeatureTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getOrderProductId();
+ break;
+ case 2:
+ return $this->getFeatureDesc();
+ break;
+ case 3:
+ return $this->getFeatureAvDesc();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['OrderFeature'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['OrderFeature'][$this->getPrimaryKey()] = true;
+ $keys = OrderFeatureTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getOrderProductId(),
+ $keys[2] => $this->getFeatureDesc(),
+ $keys[3] => $this->getFeatureAvDesc(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aOrderProduct) {
+ $result['OrderProduct'] = $this->aOrderProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderFeatureTableMap::translateFieldName($name, $type, TableMap::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->setOrderProductId($value);
+ break;
+ case 2:
+ $this->setFeatureDesc($value);
+ break;
+ case 3:
+ $this->setFeatureAvDesc($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = OrderFeatureTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setOrderProductId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setFeatureDesc($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setFeatureAvDesc($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(OrderFeatureTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderFeatureTableMap::ID)) $criteria->add(OrderFeatureTableMap::ID, $this->id);
+ if ($this->isColumnModified(OrderFeatureTableMap::ORDER_PRODUCT_ID)) $criteria->add(OrderFeatureTableMap::ORDER_PRODUCT_ID, $this->order_product_id);
+ if ($this->isColumnModified(OrderFeatureTableMap::FEATURE_DESC)) $criteria->add(OrderFeatureTableMap::FEATURE_DESC, $this->feature_desc);
+ if ($this->isColumnModified(OrderFeatureTableMap::FEATURE_AV_DESC)) $criteria->add(OrderFeatureTableMap::FEATURE_AV_DESC, $this->feature_av_desc);
+ if ($this->isColumnModified(OrderFeatureTableMap::CREATED_AT)) $criteria->add(OrderFeatureTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(OrderFeatureTableMap::UPDATED_AT)) $criteria->add(OrderFeatureTableMap::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(OrderFeatureTableMap::DATABASE_NAME);
+ $criteria->add(OrderFeatureTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\OrderFeature (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setOrderProductId($this->getOrderProductId());
+ $copyObj->setFeatureDesc($this->getFeatureDesc());
+ $copyObj->setFeatureAvDesc($this->getFeatureAvDesc());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\OrderFeature 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildOrderProduct object.
+ *
+ * @param ChildOrderProduct $v
+ * @return \Thelia\Model\OrderFeature The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrderProduct(ChildOrderProduct $v = null)
+ {
+ if ($v === null) {
+ $this->setOrderProductId(NULL);
+ } else {
+ $this->setOrderProductId($v->getId());
+ }
+
+ $this->aOrderProduct = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildOrderProduct object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderFeature($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildOrderProduct object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildOrderProduct The associated ChildOrderProduct object.
+ * @throws PropelException
+ */
+ public function getOrderProduct(ConnectionInterface $con = null)
+ {
+ if ($this->aOrderProduct === null && ($this->order_product_id !== null)) {
+ $this->aOrderProduct = ChildOrderProductQuery::create()->findPk($this->order_product_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aOrderProduct->addOrderFeatures($this);
+ */
+ }
+
+ return $this->aOrderProduct;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->order_product_id = null;
+ $this->feature_desc = null;
+ $this->feature_av_desc = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aOrderProduct = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderFeatureTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildOrderFeature The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = OrderFeatureTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/OrderFeatureQuery.php b/core/lib/Thelia/Model/Base/OrderFeatureQuery.php
new file mode 100644
index 000000000..5c59b36e8
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderFeatureQuery.php
@@ -0,0 +1,699 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildOrderFeature|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderFeatureTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderFeatureTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildOrderFeature A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, ORDER_PRODUCT_ID, FEATURE_DESC, FEATURE_AV_DESC, CREATED_AT, UPDATED_AT FROM order_feature WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildOrderFeature();
+ $obj->hydrate($row);
+ OrderFeatureTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildOrderFeature|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(OrderFeatureTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(OrderFeatureTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(OrderFeatureTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(OrderFeatureTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderFeatureTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the order_product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByOrderProductId(1234); // WHERE order_product_id = 1234
+ * $query->filterByOrderProductId(array(12, 34)); // WHERE order_product_id IN (12, 34)
+ * $query->filterByOrderProductId(array('min' => 12)); // WHERE order_product_id > 12
+ *
+ *
+ * @see filterByOrderProduct()
+ *
+ * @param mixed $orderProductId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByOrderProductId($orderProductId = null, $comparison = null)
+ {
+ if (is_array($orderProductId)) {
+ $useMinMax = false;
+ if (isset($orderProductId['min'])) {
+ $this->addUsingAlias(OrderFeatureTableMap::ORDER_PRODUCT_ID, $orderProductId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($orderProductId['max'])) {
+ $this->addUsingAlias(OrderFeatureTableMap::ORDER_PRODUCT_ID, $orderProductId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderFeatureTableMap::ORDER_PRODUCT_ID, $orderProductId, $comparison);
+ }
+
+ /**
+ * Filter the query on the feature_desc column
+ *
+ * Example usage:
+ *
+ * $query->filterByFeatureDesc('fooValue'); // WHERE feature_desc = 'fooValue'
+ * $query->filterByFeatureDesc('%fooValue%'); // WHERE feature_desc LIKE '%fooValue%'
+ *
+ *
+ * @param string $featureDesc The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByFeatureDesc($featureDesc = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($featureDesc)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $featureDesc)) {
+ $featureDesc = str_replace('*', '%', $featureDesc);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderFeatureTableMap::FEATURE_DESC, $featureDesc, $comparison);
+ }
+
+ /**
+ * Filter the query on the feature_av_desc column
+ *
+ * Example usage:
+ *
+ * $query->filterByFeatureAvDesc('fooValue'); // WHERE feature_av_desc = 'fooValue'
+ * $query->filterByFeatureAvDesc('%fooValue%'); // WHERE feature_av_desc LIKE '%fooValue%'
+ *
+ *
+ * @param string $featureAvDesc The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByFeatureAvDesc($featureAvDesc = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($featureAvDesc)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $featureAvDesc)) {
+ $featureAvDesc = str_replace('*', '%', $featureAvDesc);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderFeatureTableMap::FEATURE_AV_DESC, $featureAvDesc, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(OrderFeatureTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(OrderFeatureTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderFeatureTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(OrderFeatureTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(OrderFeatureTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderFeatureTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\OrderProduct object
+ *
+ * @param \Thelia\Model\OrderProduct|ObjectCollection $orderProduct The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function filterByOrderProduct($orderProduct, $comparison = null)
+ {
+ if ($orderProduct instanceof \Thelia\Model\OrderProduct) {
+ return $this
+ ->addUsingAlias(OrderFeatureTableMap::ORDER_PRODUCT_ID, $orderProduct->getId(), $comparison);
+ } elseif ($orderProduct instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderFeatureTableMap::ORDER_PRODUCT_ID, $orderProduct->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrderProduct() only accepts arguments of type \Thelia\Model\OrderProduct or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderProduct relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function joinOrderProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderProduct');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'OrderProduct');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderProduct relation OrderProduct object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderProductQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderProduct', '\Thelia\Model\OrderProductQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildOrderFeature $orderFeature Object to remove from the list of results
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function prune($orderFeature = null)
+ {
+ if ($orderFeature) {
+ $this->addUsingAlias(OrderFeatureTableMap::ID, $orderFeature->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the order_feature table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderFeatureTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ OrderFeatureTableMap::clearInstancePool();
+ OrderFeatureTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildOrderFeature or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildOrderFeature object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderFeatureTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderFeatureTableMap::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->beginTransaction();
+
+
+ OrderFeatureTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ OrderFeatureTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(OrderFeatureTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(OrderFeatureTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(OrderFeatureTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(OrderFeatureTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(OrderFeatureTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildOrderFeatureQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(OrderFeatureTableMap::CREATED_AT);
+ }
+
+} // OrderFeatureQuery
diff --git a/core/lib/Thelia/Model/Base/OrderProduct.php b/core/lib/Thelia/Model/Base/OrderProduct.php
new file mode 100644
index 000000000..b448e4e0c
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderProduct.php
@@ -0,0 +1,2118 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another OrderProduct instance. If
+ * obj is an instance of OrderProduct, delegates to
+ * equals(OrderProduct). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return OrderProduct The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return OrderProduct The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [order_id] column value.
+ *
+ * @return int
+ */
+ public function getOrderId()
+ {
+
+ return $this->order_id;
+ }
+
+ /**
+ * Get the [product_ref] column value.
+ *
+ * @return string
+ */
+ public function getProductRef()
+ {
+
+ return $this->product_ref;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [quantity] column value.
+ *
+ * @return double
+ */
+ public function getQuantity()
+ {
+
+ return $this->quantity;
+ }
+
+ /**
+ * Get the [price] column value.
+ *
+ * @return double
+ */
+ public function getPrice()
+ {
+
+ return $this->price;
+ }
+
+ /**
+ * Get the [tax] column value.
+ *
+ * @return double
+ */
+ public function getTax()
+ {
+
+ return $this->tax;
+ }
+
+ /**
+ * Get the [parent] column value.
+ *
+ * @return int
+ */
+ public function getParent()
+ {
+
+ return $this->parent;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\OrderProduct The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = OrderProductTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [order_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\OrderProduct The current object (for fluent API support)
+ */
+ public function setOrderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->order_id !== $v) {
+ $this->order_id = $v;
+ $this->modifiedColumns[] = OrderProductTableMap::ORDER_ID;
+ }
+
+ if ($this->aOrder !== null && $this->aOrder->getId() !== $v) {
+ $this->aOrder = null;
+ }
+
+
+ return $this;
+ } // setOrderId()
+
+ /**
+ * Set the value of [product_ref] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderProduct The current object (for fluent API support)
+ */
+ public function setProductRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->product_ref !== $v) {
+ $this->product_ref = $v;
+ $this->modifiedColumns[] = OrderProductTableMap::PRODUCT_REF;
+ }
+
+
+ return $this;
+ } // setProductRef()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderProduct The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = OrderProductTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderProduct The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = OrderProductTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderProduct The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = OrderProductTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [quantity] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\OrderProduct The current object (for fluent API support)
+ */
+ public function setQuantity($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->quantity !== $v) {
+ $this->quantity = $v;
+ $this->modifiedColumns[] = OrderProductTableMap::QUANTITY;
+ }
+
+
+ return $this;
+ } // setQuantity()
+
+ /**
+ * Set the value of [price] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\OrderProduct The current object (for fluent API support)
+ */
+ public function setPrice($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->price !== $v) {
+ $this->price = $v;
+ $this->modifiedColumns[] = OrderProductTableMap::PRICE;
+ }
+
+
+ return $this;
+ } // setPrice()
+
+ /**
+ * Set the value of [tax] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\OrderProduct The current object (for fluent API support)
+ */
+ public function setTax($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->tax !== $v) {
+ $this->tax = $v;
+ $this->modifiedColumns[] = OrderProductTableMap::TAX;
+ }
+
+
+ return $this;
+ } // setTax()
+
+ /**
+ * Set the value of [parent] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\OrderProduct The current object (for fluent API support)
+ */
+ public function setParent($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->parent !== $v) {
+ $this->parent = $v;
+ $this->modifiedColumns[] = OrderProductTableMap::PARENT;
+ }
+
+
+ return $this;
+ } // setParent()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\OrderProduct The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = OrderProductTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\OrderProduct The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = OrderProductTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderProductTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderProductTableMap::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->order_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderProductTableMap::translateFieldName('ProductRef', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->product_ref = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderProductTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderProductTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderProductTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->quantity = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderProductTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->price = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderProductTableMap::translateFieldName('Tax', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->tax = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderProductTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->parent = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 12; // 12 = OrderProductTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\OrderProduct object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) {
+ $this->aOrder = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderProductTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildOrderProductQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aOrder = null;
+ $this->collOrderFeatures = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see OrderProduct::setDeleted()
+ * @see OrderProduct::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildOrderProductQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(OrderProductTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(OrderProductTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(OrderProductTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderProductTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aOrder !== null) {
+ if ($this->aOrder->isModified() || $this->aOrder->isNew()) {
+ $affectedRows += $this->aOrder->save($con);
+ }
+ $this->setOrder($this->aOrder);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->orderFeaturesScheduledForDeletion !== null) {
+ if (!$this->orderFeaturesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\OrderFeatureQuery::create()
+ ->filterByPrimaryKeys($this->orderFeaturesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->orderFeaturesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrderFeatures !== null) {
+ foreach ($this->collOrderFeatures as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = OrderProductTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderProductTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderProductTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(OrderProductTableMap::ORDER_ID)) {
+ $modifiedColumns[':p' . $index++] = 'ORDER_ID';
+ }
+ if ($this->isColumnModified(OrderProductTableMap::PRODUCT_REF)) {
+ $modifiedColumns[':p' . $index++] = 'PRODUCT_REF';
+ }
+ if ($this->isColumnModified(OrderProductTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(OrderProductTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(OrderProductTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(OrderProductTableMap::QUANTITY)) {
+ $modifiedColumns[':p' . $index++] = 'QUANTITY';
+ }
+ if ($this->isColumnModified(OrderProductTableMap::PRICE)) {
+ $modifiedColumns[':p' . $index++] = 'PRICE';
+ }
+ if ($this->isColumnModified(OrderProductTableMap::TAX)) {
+ $modifiedColumns[':p' . $index++] = 'TAX';
+ }
+ if ($this->isColumnModified(OrderProductTableMap::PARENT)) {
+ $modifiedColumns[':p' . $index++] = 'PARENT';
+ }
+ if ($this->isColumnModified(OrderProductTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(OrderProductTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO order_product (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'ORDER_ID':
+ $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT);
+ break;
+ case 'PRODUCT_REF':
+ $stmt->bindValue($identifier, $this->product_ref, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'QUANTITY':
+ $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_STR);
+ break;
+ case 'PRICE':
+ $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR);
+ break;
+ case 'TAX':
+ $stmt->bindValue($identifier, $this->tax, PDO::PARAM_STR);
+ break;
+ case 'PARENT':
+ $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderProductTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getOrderId();
+ break;
+ case 2:
+ return $this->getProductRef();
+ break;
+ case 3:
+ return $this->getTitle();
+ break;
+ case 4:
+ return $this->getDescription();
+ break;
+ case 5:
+ return $this->getChapo();
+ break;
+ case 6:
+ return $this->getQuantity();
+ break;
+ case 7:
+ return $this->getPrice();
+ break;
+ case 8:
+ return $this->getTax();
+ break;
+ case 9:
+ return $this->getParent();
+ break;
+ case 10:
+ return $this->getCreatedAt();
+ break;
+ case 11:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['OrderProduct'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['OrderProduct'][$this->getPrimaryKey()] = true;
+ $keys = OrderProductTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getOrderId(),
+ $keys[2] => $this->getProductRef(),
+ $keys[3] => $this->getTitle(),
+ $keys[4] => $this->getDescription(),
+ $keys[5] => $this->getChapo(),
+ $keys[6] => $this->getQuantity(),
+ $keys[7] => $this->getPrice(),
+ $keys[8] => $this->getTax(),
+ $keys[9] => $this->getParent(),
+ $keys[10] => $this->getCreatedAt(),
+ $keys[11] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aOrder) {
+ $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collOrderFeatures) {
+ $result['OrderFeatures'] = $this->collOrderFeatures->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderProductTableMap::translateFieldName($name, $type, TableMap::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->setOrderId($value);
+ break;
+ case 2:
+ $this->setProductRef($value);
+ break;
+ case 3:
+ $this->setTitle($value);
+ break;
+ case 4:
+ $this->setDescription($value);
+ break;
+ case 5:
+ $this->setChapo($value);
+ break;
+ case 6:
+ $this->setQuantity($value);
+ break;
+ case 7:
+ $this->setPrice($value);
+ break;
+ case 8:
+ $this->setTax($value);
+ break;
+ case 9:
+ $this->setParent($value);
+ break;
+ case 10:
+ $this->setCreatedAt($value);
+ break;
+ case 11:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = OrderProductTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setOrderId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setProductRef($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setQuantity($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setPrice($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setTax($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setParent($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setCreatedAt($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setUpdatedAt($arr[$keys[11]]);
+ }
+
+ /**
+ * 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(OrderProductTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderProductTableMap::ID)) $criteria->add(OrderProductTableMap::ID, $this->id);
+ if ($this->isColumnModified(OrderProductTableMap::ORDER_ID)) $criteria->add(OrderProductTableMap::ORDER_ID, $this->order_id);
+ if ($this->isColumnModified(OrderProductTableMap::PRODUCT_REF)) $criteria->add(OrderProductTableMap::PRODUCT_REF, $this->product_ref);
+ if ($this->isColumnModified(OrderProductTableMap::TITLE)) $criteria->add(OrderProductTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(OrderProductTableMap::DESCRIPTION)) $criteria->add(OrderProductTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(OrderProductTableMap::CHAPO)) $criteria->add(OrderProductTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(OrderProductTableMap::QUANTITY)) $criteria->add(OrderProductTableMap::QUANTITY, $this->quantity);
+ if ($this->isColumnModified(OrderProductTableMap::PRICE)) $criteria->add(OrderProductTableMap::PRICE, $this->price);
+ if ($this->isColumnModified(OrderProductTableMap::TAX)) $criteria->add(OrderProductTableMap::TAX, $this->tax);
+ if ($this->isColumnModified(OrderProductTableMap::PARENT)) $criteria->add(OrderProductTableMap::PARENT, $this->parent);
+ if ($this->isColumnModified(OrderProductTableMap::CREATED_AT)) $criteria->add(OrderProductTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(OrderProductTableMap::UPDATED_AT)) $criteria->add(OrderProductTableMap::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(OrderProductTableMap::DATABASE_NAME);
+ $criteria->add(OrderProductTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\OrderProduct (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setOrderId($this->getOrderId());
+ $copyObj->setProductRef($this->getProductRef());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setQuantity($this->getQuantity());
+ $copyObj->setPrice($this->getPrice());
+ $copyObj->setTax($this->getTax());
+ $copyObj->setParent($this->getParent());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getOrderFeatures() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderFeature($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\OrderProduct 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildOrder object.
+ *
+ * @param ChildOrder $v
+ * @return \Thelia\Model\OrderProduct The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrder(ChildOrder $v = null)
+ {
+ if ($v === null) {
+ $this->setOrderId(NULL);
+ } else {
+ $this->setOrderId($v->getId());
+ }
+
+ $this->aOrder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildOrder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderProduct($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildOrder object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildOrder The associated ChildOrder object.
+ * @throws PropelException
+ */
+ public function getOrder(ConnectionInterface $con = null)
+ {
+ if ($this->aOrder === null && ($this->order_id !== null)) {
+ $this->aOrder = ChildOrderQuery::create()->findPk($this->order_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aOrder->addOrderProducts($this);
+ */
+ }
+
+ return $this->aOrder;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('OrderFeature' == $relationName) {
+ return $this->initOrderFeatures();
+ }
+ }
+
+ /**
+ * Clears out the collOrderFeatures collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addOrderFeatures()
+ */
+ public function clearOrderFeatures()
+ {
+ $this->collOrderFeatures = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collOrderFeatures collection loaded partially.
+ */
+ public function resetPartialOrderFeatures($v = true)
+ {
+ $this->collOrderFeaturesPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrderFeatures collection.
+ *
+ * By default this just sets the collOrderFeatures collection to an empty array (like clearcollOrderFeatures());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initOrderFeatures($overrideExisting = true)
+ {
+ if (null !== $this->collOrderFeatures && !$overrideExisting) {
+ return;
+ }
+ $this->collOrderFeatures = new ObjectCollection();
+ $this->collOrderFeatures->setModel('\Thelia\Model\OrderFeature');
+ }
+
+ /**
+ * Gets an array of ChildOrderFeature objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildOrderProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildOrderFeature[] List of ChildOrderFeature objects
+ * @throws PropelException
+ */
+ public function getOrderFeatures($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderFeaturesPartial && !$this->isNew();
+ if (null === $this->collOrderFeatures || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderFeatures) {
+ // return empty collection
+ $this->initOrderFeatures();
+ } else {
+ $collOrderFeatures = ChildOrderFeatureQuery::create(null, $criteria)
+ ->filterByOrderProduct($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collOrderFeaturesPartial && count($collOrderFeatures)) {
+ $this->initOrderFeatures(false);
+
+ foreach ($collOrderFeatures as $obj) {
+ if (false == $this->collOrderFeatures->contains($obj)) {
+ $this->collOrderFeatures->append($obj);
+ }
+ }
+
+ $this->collOrderFeaturesPartial = true;
+ }
+
+ $collOrderFeatures->getInternalIterator()->rewind();
+
+ return $collOrderFeatures;
+ }
+
+ if ($partial && $this->collOrderFeatures) {
+ foreach ($this->collOrderFeatures as $obj) {
+ if ($obj->isNew()) {
+ $collOrderFeatures[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrderFeatures = $collOrderFeatures;
+ $this->collOrderFeaturesPartial = false;
+ }
+ }
+
+ return $this->collOrderFeatures;
+ }
+
+ /**
+ * Sets a collection of OrderFeature objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $orderFeatures A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildOrderProduct The current object (for fluent API support)
+ */
+ public function setOrderFeatures(Collection $orderFeatures, ConnectionInterface $con = null)
+ {
+ $orderFeaturesToDelete = $this->getOrderFeatures(new Criteria(), $con)->diff($orderFeatures);
+
+
+ $this->orderFeaturesScheduledForDeletion = $orderFeaturesToDelete;
+
+ foreach ($orderFeaturesToDelete as $orderFeatureRemoved) {
+ $orderFeatureRemoved->setOrderProduct(null);
+ }
+
+ $this->collOrderFeatures = null;
+ foreach ($orderFeatures as $orderFeature) {
+ $this->addOrderFeature($orderFeature);
+ }
+
+ $this->collOrderFeatures = $orderFeatures;
+ $this->collOrderFeaturesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related OrderFeature objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related OrderFeature objects.
+ * @throws PropelException
+ */
+ public function countOrderFeatures(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderFeaturesPartial && !$this->isNew();
+ if (null === $this->collOrderFeatures || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderFeatures) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getOrderFeatures());
+ }
+
+ $query = ChildOrderFeatureQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrderProduct($this)
+ ->count($con);
+ }
+
+ return count($this->collOrderFeatures);
+ }
+
+ /**
+ * Method called to associate a ChildOrderFeature object to this object
+ * through the ChildOrderFeature foreign key attribute.
+ *
+ * @param ChildOrderFeature $l ChildOrderFeature
+ * @return \Thelia\Model\OrderProduct The current object (for fluent API support)
+ */
+ public function addOrderFeature(ChildOrderFeature $l)
+ {
+ if ($this->collOrderFeatures === null) {
+ $this->initOrderFeatures();
+ $this->collOrderFeaturesPartial = true;
+ }
+
+ if (!in_array($l, $this->collOrderFeatures->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderFeature($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param OrderFeature $orderFeature The orderFeature object to add.
+ */
+ protected function doAddOrderFeature($orderFeature)
+ {
+ $this->collOrderFeatures[]= $orderFeature;
+ $orderFeature->setOrderProduct($this);
+ }
+
+ /**
+ * @param OrderFeature $orderFeature The orderFeature object to remove.
+ * @return ChildOrderProduct The current object (for fluent API support)
+ */
+ public function removeOrderFeature($orderFeature)
+ {
+ if ($this->getOrderFeatures()->contains($orderFeature)) {
+ $this->collOrderFeatures->remove($this->collOrderFeatures->search($orderFeature));
+ if (null === $this->orderFeaturesScheduledForDeletion) {
+ $this->orderFeaturesScheduledForDeletion = clone $this->collOrderFeatures;
+ $this->orderFeaturesScheduledForDeletion->clear();
+ }
+ $this->orderFeaturesScheduledForDeletion[]= clone $orderFeature;
+ $orderFeature->setOrderProduct(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->order_id = null;
+ $this->product_ref = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->quantity = null;
+ $this->price = null;
+ $this->tax = null;
+ $this->parent = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collOrderFeatures) {
+ foreach ($this->collOrderFeatures as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ if ($this->collOrderFeatures instanceof Collection) {
+ $this->collOrderFeatures->clearIterator();
+ }
+ $this->collOrderFeatures = null;
+ $this->aOrder = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderProductTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildOrderProduct The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = OrderProductTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/OrderProductQuery.php b/core/lib/Thelia/Model/Base/OrderProductQuery.php
new file mode 100644
index 000000000..b007c89e1
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderProductQuery.php
@@ -0,0 +1,1022 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildOrderProduct|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderProductTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderProductTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildOrderProduct A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, ORDER_ID, PRODUCT_REF, TITLE, DESCRIPTION, CHAPO, QUANTITY, PRICE, TAX, PARENT, CREATED_AT, UPDATED_AT FROM order_product WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildOrderProduct();
+ $obj->hydrate($row);
+ OrderProductTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildOrderProduct|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(OrderProductTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(OrderProductTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(OrderProductTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(OrderProductTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the order_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByOrderId(1234); // WHERE order_id = 1234
+ * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34)
+ * $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12
+ *
+ *
+ * @see filterByOrder()
+ *
+ * @param mixed $orderId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByOrderId($orderId = null, $comparison = null)
+ {
+ if (is_array($orderId)) {
+ $useMinMax = false;
+ if (isset($orderId['min'])) {
+ $this->addUsingAlias(OrderProductTableMap::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($orderId['max'])) {
+ $this->addUsingAlias(OrderProductTableMap::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::ORDER_ID, $orderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductRef('fooValue'); // WHERE product_ref = 'fooValue'
+ * $query->filterByProductRef('%fooValue%'); // WHERE product_ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $productRef The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByProductRef($productRef = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($productRef)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $productRef)) {
+ $productRef = str_replace('*', '%', $productRef);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::PRODUCT_REF, $productRef, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the quantity column
+ *
+ * Example usage:
+ *
+ * $query->filterByQuantity(1234); // WHERE quantity = 1234
+ * $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34)
+ * $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12
+ *
+ *
+ * @param mixed $quantity The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByQuantity($quantity = null, $comparison = null)
+ {
+ if (is_array($quantity)) {
+ $useMinMax = false;
+ if (isset($quantity['min'])) {
+ $this->addUsingAlias(OrderProductTableMap::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($quantity['max'])) {
+ $this->addUsingAlias(OrderProductTableMap::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::QUANTITY, $quantity, $comparison);
+ }
+
+ /**
+ * Filter the query on the price column
+ *
+ * Example usage:
+ *
+ * $query->filterByPrice(1234); // WHERE price = 1234
+ * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34)
+ * $query->filterByPrice(array('min' => 12)); // WHERE price > 12
+ *
+ *
+ * @param mixed $price The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByPrice($price = null, $comparison = null)
+ {
+ if (is_array($price)) {
+ $useMinMax = false;
+ if (isset($price['min'])) {
+ $this->addUsingAlias(OrderProductTableMap::PRICE, $price['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($price['max'])) {
+ $this->addUsingAlias(OrderProductTableMap::PRICE, $price['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::PRICE, $price, $comparison);
+ }
+
+ /**
+ * Filter the query on the tax column
+ *
+ * Example usage:
+ *
+ * $query->filterByTax(1234); // WHERE tax = 1234
+ * $query->filterByTax(array(12, 34)); // WHERE tax IN (12, 34)
+ * $query->filterByTax(array('min' => 12)); // WHERE tax > 12
+ *
+ *
+ * @param mixed $tax The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByTax($tax = null, $comparison = null)
+ {
+ if (is_array($tax)) {
+ $useMinMax = false;
+ if (isset($tax['min'])) {
+ $this->addUsingAlias(OrderProductTableMap::TAX, $tax['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($tax['max'])) {
+ $this->addUsingAlias(OrderProductTableMap::TAX, $tax['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::TAX, $tax, $comparison);
+ }
+
+ /**
+ * Filter the query on the parent column
+ *
+ * Example usage:
+ *
+ * $query->filterByParent(1234); // WHERE parent = 1234
+ * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34)
+ * $query->filterByParent(array('min' => 12)); // WHERE parent > 12
+ *
+ *
+ * @param mixed $parent The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByParent($parent = null, $comparison = null)
+ {
+ if (is_array($parent)) {
+ $useMinMax = false;
+ if (isset($parent['min'])) {
+ $this->addUsingAlias(OrderProductTableMap::PARENT, $parent['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($parent['max'])) {
+ $this->addUsingAlias(OrderProductTableMap::PARENT, $parent['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::PARENT, $parent, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(OrderProductTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(OrderProductTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Order object
+ *
+ * @param \Thelia\Model\Order|ObjectCollection $order The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByOrder($order, $comparison = null)
+ {
+ if ($order instanceof \Thelia\Model\Order) {
+ return $this
+ ->addUsingAlias(OrderProductTableMap::ORDER_ID, $order->getId(), $comparison);
+ } elseif ($order instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderProductTableMap::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Order relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Order');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Order');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Order relation Order object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\OrderFeature object
+ *
+ * @param \Thelia\Model\OrderFeature|ObjectCollection $orderFeature the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function filterByOrderFeature($orderFeature, $comparison = null)
+ {
+ if ($orderFeature instanceof \Thelia\Model\OrderFeature) {
+ return $this
+ ->addUsingAlias(OrderProductTableMap::ID, $orderFeature->getOrderProductId(), $comparison);
+ } elseif ($orderFeature instanceof ObjectCollection) {
+ return $this
+ ->useOrderFeatureQuery()
+ ->filterByPrimaryKeys($orderFeature->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderFeature() only accepts arguments of type \Thelia\Model\OrderFeature or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderFeature relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function joinOrderFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderFeature');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'OrderFeature');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderFeature relation OrderFeature object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderFeatureQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderFeature($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderFeature', '\Thelia\Model\OrderFeatureQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildOrderProduct $orderProduct Object to remove from the list of results
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function prune($orderProduct = null)
+ {
+ if ($orderProduct) {
+ $this->addUsingAlias(OrderProductTableMap::ID, $orderProduct->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the order_product table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ OrderProductTableMap::clearInstancePool();
+ OrderProductTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildOrderProduct or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildOrderProduct object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderProductTableMap::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->beginTransaction();
+
+
+ OrderProductTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ OrderProductTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(OrderProductTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(OrderProductTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(OrderProductTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(OrderProductTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildOrderProductQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(OrderProductTableMap::CREATED_AT);
+ }
+
+} // OrderProductQuery
diff --git a/core/lib/Thelia/Model/Base/OrderQuery.php b/core/lib/Thelia/Model/Base/OrderQuery.php
new file mode 100644
index 000000000..bdff793a8
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderQuery.php
@@ -0,0 +1,1659 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildOrder|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildOrder A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, REF, CUSTOMER_ID, ADDRESS_INVOICE, ADDRESS_DELIVERY, INVOICE_DATE, CURRENCY_ID, CURRENCY_RATE, TRANSACTION, DELIVERY_NUM, INVOICE, POSTAGE, PAYMENT, CARRIER, STATUS_ID, LANG, CREATED_AT, UPDATED_AT FROM order WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildOrder();
+ $obj->hydrate($row);
+ OrderTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildOrder|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(OrderTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(OrderTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(OrderTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(OrderTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
+ * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $ref The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByRef($ref = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($ref)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $ref)) {
+ $ref = str_replace('*', '%', $ref);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::REF, $ref, $comparison);
+ }
+
+ /**
+ * Filter the query on the customer_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCustomerId(1234); // WHERE customer_id = 1234
+ * $query->filterByCustomerId(array(12, 34)); // WHERE customer_id IN (12, 34)
+ * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id > 12
+ *
+ *
+ * @see filterByCustomer()
+ *
+ * @param mixed $customerId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByCustomerId($customerId = null, $comparison = null)
+ {
+ if (is_array($customerId)) {
+ $useMinMax = false;
+ if (isset($customerId['min'])) {
+ $this->addUsingAlias(OrderTableMap::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($customerId['max'])) {
+ $this->addUsingAlias(OrderTableMap::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::CUSTOMER_ID, $customerId, $comparison);
+ }
+
+ /**
+ * Filter the query on the address_invoice column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddressInvoice(1234); // WHERE address_invoice = 1234
+ * $query->filterByAddressInvoice(array(12, 34)); // WHERE address_invoice IN (12, 34)
+ * $query->filterByAddressInvoice(array('min' => 12)); // WHERE address_invoice > 12
+ *
+ *
+ * @see filterByOrderAddressRelatedByAddressInvoice()
+ *
+ * @param mixed $addressInvoice The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByAddressInvoice($addressInvoice = null, $comparison = null)
+ {
+ if (is_array($addressInvoice)) {
+ $useMinMax = false;
+ if (isset($addressInvoice['min'])) {
+ $this->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $addressInvoice['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($addressInvoice['max'])) {
+ $this->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $addressInvoice['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $addressInvoice, $comparison);
+ }
+
+ /**
+ * Filter the query on the address_delivery column
+ *
+ * Example usage:
+ *
+ * $query->filterByAddressDelivery(1234); // WHERE address_delivery = 1234
+ * $query->filterByAddressDelivery(array(12, 34)); // WHERE address_delivery IN (12, 34)
+ * $query->filterByAddressDelivery(array('min' => 12)); // WHERE address_delivery > 12
+ *
+ *
+ * @see filterByOrderAddressRelatedByAddressDelivery()
+ *
+ * @param mixed $addressDelivery The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByAddressDelivery($addressDelivery = null, $comparison = null)
+ {
+ if (is_array($addressDelivery)) {
+ $useMinMax = false;
+ if (isset($addressDelivery['min'])) {
+ $this->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $addressDelivery['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($addressDelivery['max'])) {
+ $this->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $addressDelivery['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $addressDelivery, $comparison);
+ }
+
+ /**
+ * Filter the query on the invoice_date column
+ *
+ * Example usage:
+ *
+ * $query->filterByInvoiceDate('2011-03-14'); // WHERE invoice_date = '2011-03-14'
+ * $query->filterByInvoiceDate('now'); // WHERE invoice_date = '2011-03-14'
+ * $query->filterByInvoiceDate(array('max' => 'yesterday')); // WHERE invoice_date > '2011-03-13'
+ *
+ *
+ * @param mixed $invoiceDate The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByInvoiceDate($invoiceDate = null, $comparison = null)
+ {
+ if (is_array($invoiceDate)) {
+ $useMinMax = false;
+ if (isset($invoiceDate['min'])) {
+ $this->addUsingAlias(OrderTableMap::INVOICE_DATE, $invoiceDate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($invoiceDate['max'])) {
+ $this->addUsingAlias(OrderTableMap::INVOICE_DATE, $invoiceDate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::INVOICE_DATE, $invoiceDate, $comparison);
+ }
+
+ /**
+ * Filter the query on the currency_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCurrencyId(1234); // WHERE currency_id = 1234
+ * $query->filterByCurrencyId(array(12, 34)); // WHERE currency_id IN (12, 34)
+ * $query->filterByCurrencyId(array('min' => 12)); // WHERE currency_id > 12
+ *
+ *
+ * @see filterByCurrency()
+ *
+ * @param mixed $currencyId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByCurrencyId($currencyId = null, $comparison = null)
+ {
+ if (is_array($currencyId)) {
+ $useMinMax = false;
+ if (isset($currencyId['min'])) {
+ $this->addUsingAlias(OrderTableMap::CURRENCY_ID, $currencyId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($currencyId['max'])) {
+ $this->addUsingAlias(OrderTableMap::CURRENCY_ID, $currencyId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::CURRENCY_ID, $currencyId, $comparison);
+ }
+
+ /**
+ * Filter the query on the currency_rate column
+ *
+ * Example usage:
+ *
+ * $query->filterByCurrencyRate(1234); // WHERE currency_rate = 1234
+ * $query->filterByCurrencyRate(array(12, 34)); // WHERE currency_rate IN (12, 34)
+ * $query->filterByCurrencyRate(array('min' => 12)); // WHERE currency_rate > 12
+ *
+ *
+ * @param mixed $currencyRate The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByCurrencyRate($currencyRate = null, $comparison = null)
+ {
+ if (is_array($currencyRate)) {
+ $useMinMax = false;
+ if (isset($currencyRate['min'])) {
+ $this->addUsingAlias(OrderTableMap::CURRENCY_RATE, $currencyRate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($currencyRate['max'])) {
+ $this->addUsingAlias(OrderTableMap::CURRENCY_RATE, $currencyRate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::CURRENCY_RATE, $currencyRate, $comparison);
+ }
+
+ /**
+ * Filter the query on the transaction column
+ *
+ * Example usage:
+ *
+ * $query->filterByTransaction('fooValue'); // WHERE transaction = 'fooValue'
+ * $query->filterByTransaction('%fooValue%'); // WHERE transaction LIKE '%fooValue%'
+ *
+ *
+ * @param string $transaction The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByTransaction($transaction = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($transaction)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $transaction)) {
+ $transaction = str_replace('*', '%', $transaction);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::TRANSACTION, $transaction, $comparison);
+ }
+
+ /**
+ * Filter the query on the delivery_num column
+ *
+ * Example usage:
+ *
+ * $query->filterByDeliveryNum('fooValue'); // WHERE delivery_num = 'fooValue'
+ * $query->filterByDeliveryNum('%fooValue%'); // WHERE delivery_num LIKE '%fooValue%'
+ *
+ *
+ * @param string $deliveryNum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByDeliveryNum($deliveryNum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($deliveryNum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $deliveryNum)) {
+ $deliveryNum = str_replace('*', '%', $deliveryNum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::DELIVERY_NUM, $deliveryNum, $comparison);
+ }
+
+ /**
+ * Filter the query on the invoice column
+ *
+ * Example usage:
+ *
+ * $query->filterByInvoice('fooValue'); // WHERE invoice = 'fooValue'
+ * $query->filterByInvoice('%fooValue%'); // WHERE invoice LIKE '%fooValue%'
+ *
+ *
+ * @param string $invoice The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByInvoice($invoice = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($invoice)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $invoice)) {
+ $invoice = str_replace('*', '%', $invoice);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::INVOICE, $invoice, $comparison);
+ }
+
+ /**
+ * Filter the query on the postage column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostage(1234); // WHERE postage = 1234
+ * $query->filterByPostage(array(12, 34)); // WHERE postage IN (12, 34)
+ * $query->filterByPostage(array('min' => 12)); // WHERE postage > 12
+ *
+ *
+ * @param mixed $postage The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByPostage($postage = null, $comparison = null)
+ {
+ if (is_array($postage)) {
+ $useMinMax = false;
+ if (isset($postage['min'])) {
+ $this->addUsingAlias(OrderTableMap::POSTAGE, $postage['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($postage['max'])) {
+ $this->addUsingAlias(OrderTableMap::POSTAGE, $postage['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::POSTAGE, $postage, $comparison);
+ }
+
+ /**
+ * Filter the query on the payment column
+ *
+ * Example usage:
+ *
+ * $query->filterByPayment('fooValue'); // WHERE payment = 'fooValue'
+ * $query->filterByPayment('%fooValue%'); // WHERE payment LIKE '%fooValue%'
+ *
+ *
+ * @param string $payment The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByPayment($payment = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($payment)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $payment)) {
+ $payment = str_replace('*', '%', $payment);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::PAYMENT, $payment, $comparison);
+ }
+
+ /**
+ * Filter the query on the carrier column
+ *
+ * Example usage:
+ *
+ * $query->filterByCarrier('fooValue'); // WHERE carrier = 'fooValue'
+ * $query->filterByCarrier('%fooValue%'); // WHERE carrier LIKE '%fooValue%'
+ *
+ *
+ * @param string $carrier The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByCarrier($carrier = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($carrier)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $carrier)) {
+ $carrier = str_replace('*', '%', $carrier);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::CARRIER, $carrier, $comparison);
+ }
+
+ /**
+ * Filter the query on the status_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByStatusId(1234); // WHERE status_id = 1234
+ * $query->filterByStatusId(array(12, 34)); // WHERE status_id IN (12, 34)
+ * $query->filterByStatusId(array('min' => 12)); // WHERE status_id > 12
+ *
+ *
+ * @see filterByOrderStatus()
+ *
+ * @param mixed $statusId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByStatusId($statusId = null, $comparison = null)
+ {
+ if (is_array($statusId)) {
+ $useMinMax = false;
+ if (isset($statusId['min'])) {
+ $this->addUsingAlias(OrderTableMap::STATUS_ID, $statusId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($statusId['max'])) {
+ $this->addUsingAlias(OrderTableMap::STATUS_ID, $statusId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::STATUS_ID, $statusId, $comparison);
+ }
+
+ /**
+ * Filter the query on the lang column
+ *
+ * Example usage:
+ *
+ * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue'
+ * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%'
+ *
+ *
+ * @param string $lang The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByLang($lang = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($lang)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $lang)) {
+ $lang = str_replace('*', '%', $lang);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::LANG, $lang, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(OrderTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(OrderTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(OrderTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(OrderTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Currency object
+ *
+ * @param \Thelia\Model\Currency|ObjectCollection $currency The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByCurrency($currency, $comparison = null)
+ {
+ if ($currency instanceof \Thelia\Model\Currency) {
+ return $this
+ ->addUsingAlias(OrderTableMap::CURRENCY_ID, $currency->getId(), $comparison);
+ } elseif ($currency instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderTableMap::CURRENCY_ID, $currency->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCurrency() only accepts arguments of type \Thelia\Model\Currency or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Currency relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function joinCurrency($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Currency');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Currency');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Currency relation Currency object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CurrencyQuery A secondary query class using the current class as primary query
+ */
+ public function useCurrencyQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCurrency($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Currency', '\Thelia\Model\CurrencyQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Customer object
+ *
+ * @param \Thelia\Model\Customer|ObjectCollection $customer The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByCustomer($customer, $comparison = null)
+ {
+ if ($customer instanceof \Thelia\Model\Customer) {
+ return $this
+ ->addUsingAlias(OrderTableMap::CUSTOMER_ID, $customer->getId(), $comparison);
+ } elseif ($customer instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderTableMap::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCustomer() only accepts arguments of type \Thelia\Model\Customer or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Customer relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Customer');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Customer');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Customer relation Customer object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CustomerQuery A secondary query class using the current class as primary query
+ */
+ public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCustomer($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\OrderAddress object
+ *
+ * @param \Thelia\Model\OrderAddress|ObjectCollection $orderAddress The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByOrderAddressRelatedByAddressInvoice($orderAddress, $comparison = null)
+ {
+ if ($orderAddress instanceof \Thelia\Model\OrderAddress) {
+ return $this
+ ->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $orderAddress->getId(), $comparison);
+ } elseif ($orderAddress instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrderAddressRelatedByAddressInvoice() only accepts arguments of type \Thelia\Model\OrderAddress or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderAddressRelatedByAddressInvoice relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function joinOrderAddressRelatedByAddressInvoice($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderAddressRelatedByAddressInvoice');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'OrderAddressRelatedByAddressInvoice');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderAddressRelatedByAddressInvoice relation OrderAddress object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderAddressQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderAddressRelatedByAddressInvoiceQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinOrderAddressRelatedByAddressInvoice($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderAddressRelatedByAddressInvoice', '\Thelia\Model\OrderAddressQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\OrderAddress object
+ *
+ * @param \Thelia\Model\OrderAddress|ObjectCollection $orderAddress The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByOrderAddressRelatedByAddressDelivery($orderAddress, $comparison = null)
+ {
+ if ($orderAddress instanceof \Thelia\Model\OrderAddress) {
+ return $this
+ ->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $orderAddress->getId(), $comparison);
+ } elseif ($orderAddress instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrderAddressRelatedByAddressDelivery() only accepts arguments of type \Thelia\Model\OrderAddress or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderAddressRelatedByAddressDelivery relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function joinOrderAddressRelatedByAddressDelivery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderAddressRelatedByAddressDelivery');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'OrderAddressRelatedByAddressDelivery');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderAddressRelatedByAddressDelivery relation OrderAddress object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderAddressQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderAddressRelatedByAddressDeliveryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinOrderAddressRelatedByAddressDelivery($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderAddressRelatedByAddressDelivery', '\Thelia\Model\OrderAddressQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\OrderStatus object
+ *
+ * @param \Thelia\Model\OrderStatus|ObjectCollection $orderStatus The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByOrderStatus($orderStatus, $comparison = null)
+ {
+ if ($orderStatus instanceof \Thelia\Model\OrderStatus) {
+ return $this
+ ->addUsingAlias(OrderTableMap::STATUS_ID, $orderStatus->getId(), $comparison);
+ } elseif ($orderStatus instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderTableMap::STATUS_ID, $orderStatus->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrderStatus() only accepts arguments of type \Thelia\Model\OrderStatus or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderStatus relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function joinOrderStatus($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderStatus');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'OrderStatus');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderStatus relation OrderStatus object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderStatusQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderStatusQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinOrderStatus($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderStatus', '\Thelia\Model\OrderStatusQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\OrderProduct object
+ *
+ * @param \Thelia\Model\OrderProduct|ObjectCollection $orderProduct the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByOrderProduct($orderProduct, $comparison = null)
+ {
+ if ($orderProduct instanceof \Thelia\Model\OrderProduct) {
+ return $this
+ ->addUsingAlias(OrderTableMap::ID, $orderProduct->getOrderId(), $comparison);
+ } elseif ($orderProduct instanceof ObjectCollection) {
+ return $this
+ ->useOrderProductQuery()
+ ->filterByPrimaryKeys($orderProduct->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderProduct() only accepts arguments of type \Thelia\Model\OrderProduct or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderProduct relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function joinOrderProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderProduct');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'OrderProduct');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderProduct relation OrderProduct object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderProductQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinOrderProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderProduct', '\Thelia\Model\OrderProductQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\CouponOrder object
+ *
+ * @param \Thelia\Model\CouponOrder|ObjectCollection $couponOrder the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function filterByCouponOrder($couponOrder, $comparison = null)
+ {
+ if ($couponOrder instanceof \Thelia\Model\CouponOrder) {
+ return $this
+ ->addUsingAlias(OrderTableMap::ID, $couponOrder->getOrderId(), $comparison);
+ } elseif ($couponOrder instanceof ObjectCollection) {
+ return $this
+ ->useCouponOrderQuery()
+ ->filterByPrimaryKeys($couponOrder->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByCouponOrder() only accepts arguments of type \Thelia\Model\CouponOrder or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the CouponOrder relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function joinCouponOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('CouponOrder');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'CouponOrder');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the CouponOrder relation CouponOrder object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CouponOrderQuery A secondary query class using the current class as primary query
+ */
+ public function useCouponOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCouponOrder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'CouponOrder', '\Thelia\Model\CouponOrderQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildOrder $order Object to remove from the list of results
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function prune($order = null)
+ {
+ if ($order) {
+ $this->addUsingAlias(OrderTableMap::ID, $order->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the order table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ OrderTableMap::clearInstancePool();
+ OrderTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildOrder or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildOrder object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderTableMap::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->beginTransaction();
+
+
+ OrderTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ OrderTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(OrderTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(OrderTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(OrderTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(OrderTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(OrderTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildOrderQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(OrderTableMap::CREATED_AT);
+ }
+
+} // OrderQuery
diff --git a/core/lib/Thelia/Model/Base/OrderStatus.php b/core/lib/Thelia/Model/Base/OrderStatus.php
new file mode 100644
index 000000000..15ce7fbf7
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderStatus.php
@@ -0,0 +1,2165 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another OrderStatus instance. If
+ * obj is an instance of OrderStatus, delegates to
+ * equals(OrderStatus). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return OrderStatus The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return OrderStatus The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\OrderStatus The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = OrderStatusTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderStatus The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = OrderStatusTableMap::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\OrderStatus The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = OrderStatusTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\OrderStatus The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = OrderStatusTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderStatusTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderStatusTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->code = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderStatusTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderStatusTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = OrderStatusTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\OrderStatus object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderStatusTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildOrderStatusQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collOrders = null;
+
+ $this->collOrderStatusI18ns = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see OrderStatus::setDeleted()
+ * @see OrderStatus::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildOrderStatusQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(OrderStatusTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(OrderStatusTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(OrderStatusTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderStatusTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->ordersScheduledForDeletion !== null) {
+ if (!$this->ordersScheduledForDeletion->isEmpty()) {
+ foreach ($this->ordersScheduledForDeletion as $order) {
+ // need to save related object because we set the relation to null
+ $order->save($con);
+ }
+ $this->ordersScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrders !== null) {
+ foreach ($this->collOrders as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->orderStatusI18nsScheduledForDeletion !== null) {
+ if (!$this->orderStatusI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\OrderStatusI18nQuery::create()
+ ->filterByPrimaryKeys($this->orderStatusI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->orderStatusI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collOrderStatusI18ns !== null) {
+ foreach ($this->collOrderStatusI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = OrderStatusTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderStatusTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderStatusTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(OrderStatusTableMap::CODE)) {
+ $modifiedColumns[':p' . $index++] = 'CODE';
+ }
+ if ($this->isColumnModified(OrderStatusTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(OrderStatusTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO order_status (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'CODE':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderStatusTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getCode();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['OrderStatus'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['OrderStatus'][$this->getPrimaryKey()] = true;
+ $keys = OrderStatusTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collOrders) {
+ $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collOrderStatusI18ns) {
+ $result['OrderStatusI18ns'] = $this->collOrderStatusI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderStatusTableMap::translateFieldName($name, $type, TableMap::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->setCode($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = OrderStatusTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * 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(OrderStatusTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderStatusTableMap::ID)) $criteria->add(OrderStatusTableMap::ID, $this->id);
+ if ($this->isColumnModified(OrderStatusTableMap::CODE)) $criteria->add(OrderStatusTableMap::CODE, $this->code);
+ if ($this->isColumnModified(OrderStatusTableMap::CREATED_AT)) $criteria->add(OrderStatusTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(OrderStatusTableMap::UPDATED_AT)) $criteria->add(OrderStatusTableMap::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(OrderStatusTableMap::DATABASE_NAME);
+ $criteria->add(OrderStatusTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\OrderStatus (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getOrders() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrder($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getOrderStatusI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addOrderStatusI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\OrderStatus 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('Order' == $relationName) {
+ return $this->initOrders();
+ }
+ if ('OrderStatusI18n' == $relationName) {
+ return $this->initOrderStatusI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collOrders collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addOrders()
+ */
+ public function clearOrders()
+ {
+ $this->collOrders = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collOrders collection loaded partially.
+ */
+ public function resetPartialOrders($v = true)
+ {
+ $this->collOrdersPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrders collection.
+ *
+ * By default this just sets the collOrders collection to an empty array (like clearcollOrders());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initOrders($overrideExisting = true)
+ {
+ if (null !== $this->collOrders && !$overrideExisting) {
+ return;
+ }
+ $this->collOrders = new ObjectCollection();
+ $this->collOrders->setModel('\Thelia\Model\Order');
+ }
+
+ /**
+ * Gets an array of ChildOrder objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildOrderStatus is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ * @throws PropelException
+ */
+ public function getOrders($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrdersPartial && !$this->isNew();
+ if (null === $this->collOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrders) {
+ // return empty collection
+ $this->initOrders();
+ } else {
+ $collOrders = ChildOrderQuery::create(null, $criteria)
+ ->filterByOrderStatus($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collOrdersPartial && count($collOrders)) {
+ $this->initOrders(false);
+
+ foreach ($collOrders as $obj) {
+ if (false == $this->collOrders->contains($obj)) {
+ $this->collOrders->append($obj);
+ }
+ }
+
+ $this->collOrdersPartial = true;
+ }
+
+ $collOrders->getInternalIterator()->rewind();
+
+ return $collOrders;
+ }
+
+ if ($partial && $this->collOrders) {
+ foreach ($this->collOrders as $obj) {
+ if ($obj->isNew()) {
+ $collOrders[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrders = $collOrders;
+ $this->collOrdersPartial = false;
+ }
+ }
+
+ return $this->collOrders;
+ }
+
+ /**
+ * Sets a collection of Order objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $orders A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildOrderStatus The current object (for fluent API support)
+ */
+ public function setOrders(Collection $orders, ConnectionInterface $con = null)
+ {
+ $ordersToDelete = $this->getOrders(new Criteria(), $con)->diff($orders);
+
+
+ $this->ordersScheduledForDeletion = $ordersToDelete;
+
+ foreach ($ordersToDelete as $orderRemoved) {
+ $orderRemoved->setOrderStatus(null);
+ }
+
+ $this->collOrders = null;
+ foreach ($orders as $order) {
+ $this->addOrder($order);
+ }
+
+ $this->collOrders = $orders;
+ $this->collOrdersPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Order objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Order objects.
+ * @throws PropelException
+ */
+ public function countOrders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrdersPartial && !$this->isNew();
+ if (null === $this->collOrders || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrders) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getOrders());
+ }
+
+ $query = ChildOrderQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrderStatus($this)
+ ->count($con);
+ }
+
+ return count($this->collOrders);
+ }
+
+ /**
+ * Method called to associate a ChildOrder object to this object
+ * through the ChildOrder foreign key attribute.
+ *
+ * @param ChildOrder $l ChildOrder
+ * @return \Thelia\Model\OrderStatus The current object (for fluent API support)
+ */
+ public function addOrder(ChildOrder $l)
+ {
+ if ($this->collOrders === null) {
+ $this->initOrders();
+ $this->collOrdersPartial = true;
+ }
+
+ if (!in_array($l, $this->collOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddOrder($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Order $order The order object to add.
+ */
+ protected function doAddOrder($order)
+ {
+ $this->collOrders[]= $order;
+ $order->setOrderStatus($this);
+ }
+
+ /**
+ * @param Order $order The order object to remove.
+ * @return ChildOrderStatus The current object (for fluent API support)
+ */
+ public function removeOrder($order)
+ {
+ if ($this->getOrders()->contains($order)) {
+ $this->collOrders->remove($this->collOrders->search($order));
+ if (null === $this->ordersScheduledForDeletion) {
+ $this->ordersScheduledForDeletion = clone $this->collOrders;
+ $this->ordersScheduledForDeletion->clear();
+ }
+ $this->ordersScheduledForDeletion[]= $order;
+ $order->setOrderStatus(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderStatus is new, it will return
+ * an empty collection; or if this OrderStatus has previously
+ * been saved, it will retrieve related Orders 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 OrderStatus.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('Currency', $joinBehavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderStatus is new, it will return
+ * an empty collection; or if this OrderStatus has previously
+ * been saved, it will retrieve related Orders 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 OrderStatus.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('Customer', $joinBehavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderStatus is new, it will return
+ * an empty collection; or if this OrderStatus has previously
+ * been saved, it will retrieve related Orders 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 OrderStatus.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('OrderAddressRelatedByAddressInvoice', $joinBehavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this OrderStatus is new, it will return
+ * an empty collection; or if this OrderStatus has previously
+ * been saved, it will retrieve related Orders 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 OrderStatus.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildOrder[] List of ChildOrder objects
+ */
+ public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildOrderQuery::create(null, $criteria);
+ $query->joinWith('OrderAddressRelatedByAddressDelivery', $joinBehavior);
+
+ return $this->getOrders($query, $con);
+ }
+
+ /**
+ * Clears out the collOrderStatusI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addOrderStatusI18ns()
+ */
+ public function clearOrderStatusI18ns()
+ {
+ $this->collOrderStatusI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collOrderStatusI18ns collection loaded partially.
+ */
+ public function resetPartialOrderStatusI18ns($v = true)
+ {
+ $this->collOrderStatusI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collOrderStatusI18ns collection.
+ *
+ * By default this just sets the collOrderStatusI18ns collection to an empty array (like clearcollOrderStatusI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initOrderStatusI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collOrderStatusI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collOrderStatusI18ns = new ObjectCollection();
+ $this->collOrderStatusI18ns->setModel('\Thelia\Model\OrderStatusI18n');
+ }
+
+ /**
+ * Gets an array of ChildOrderStatusI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildOrderStatus is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildOrderStatusI18n[] List of ChildOrderStatusI18n objects
+ * @throws PropelException
+ */
+ public function getOrderStatusI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderStatusI18nsPartial && !$this->isNew();
+ if (null === $this->collOrderStatusI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderStatusI18ns) {
+ // return empty collection
+ $this->initOrderStatusI18ns();
+ } else {
+ $collOrderStatusI18ns = ChildOrderStatusI18nQuery::create(null, $criteria)
+ ->filterByOrderStatus($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collOrderStatusI18nsPartial && count($collOrderStatusI18ns)) {
+ $this->initOrderStatusI18ns(false);
+
+ foreach ($collOrderStatusI18ns as $obj) {
+ if (false == $this->collOrderStatusI18ns->contains($obj)) {
+ $this->collOrderStatusI18ns->append($obj);
+ }
+ }
+
+ $this->collOrderStatusI18nsPartial = true;
+ }
+
+ $collOrderStatusI18ns->getInternalIterator()->rewind();
+
+ return $collOrderStatusI18ns;
+ }
+
+ if ($partial && $this->collOrderStatusI18ns) {
+ foreach ($this->collOrderStatusI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collOrderStatusI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collOrderStatusI18ns = $collOrderStatusI18ns;
+ $this->collOrderStatusI18nsPartial = false;
+ }
+ }
+
+ return $this->collOrderStatusI18ns;
+ }
+
+ /**
+ * Sets a collection of OrderStatusI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $orderStatusI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildOrderStatus The current object (for fluent API support)
+ */
+ public function setOrderStatusI18ns(Collection $orderStatusI18ns, ConnectionInterface $con = null)
+ {
+ $orderStatusI18nsToDelete = $this->getOrderStatusI18ns(new Criteria(), $con)->diff($orderStatusI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->orderStatusI18nsScheduledForDeletion = clone $orderStatusI18nsToDelete;
+
+ foreach ($orderStatusI18nsToDelete as $orderStatusI18nRemoved) {
+ $orderStatusI18nRemoved->setOrderStatus(null);
+ }
+
+ $this->collOrderStatusI18ns = null;
+ foreach ($orderStatusI18ns as $orderStatusI18n) {
+ $this->addOrderStatusI18n($orderStatusI18n);
+ }
+
+ $this->collOrderStatusI18ns = $orderStatusI18ns;
+ $this->collOrderStatusI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related OrderStatusI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related OrderStatusI18n objects.
+ * @throws PropelException
+ */
+ public function countOrderStatusI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collOrderStatusI18nsPartial && !$this->isNew();
+ if (null === $this->collOrderStatusI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collOrderStatusI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getOrderStatusI18ns());
+ }
+
+ $query = ChildOrderStatusI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByOrderStatus($this)
+ ->count($con);
+ }
+
+ return count($this->collOrderStatusI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildOrderStatusI18n object to this object
+ * through the ChildOrderStatusI18n foreign key attribute.
+ *
+ * @param ChildOrderStatusI18n $l ChildOrderStatusI18n
+ * @return \Thelia\Model\OrderStatus The current object (for fluent API support)
+ */
+ public function addOrderStatusI18n(ChildOrderStatusI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collOrderStatusI18ns === null) {
+ $this->initOrderStatusI18ns();
+ $this->collOrderStatusI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collOrderStatusI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddOrderStatusI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param OrderStatusI18n $orderStatusI18n The orderStatusI18n object to add.
+ */
+ protected function doAddOrderStatusI18n($orderStatusI18n)
+ {
+ $this->collOrderStatusI18ns[]= $orderStatusI18n;
+ $orderStatusI18n->setOrderStatus($this);
+ }
+
+ /**
+ * @param OrderStatusI18n $orderStatusI18n The orderStatusI18n object to remove.
+ * @return ChildOrderStatus The current object (for fluent API support)
+ */
+ public function removeOrderStatusI18n($orderStatusI18n)
+ {
+ if ($this->getOrderStatusI18ns()->contains($orderStatusI18n)) {
+ $this->collOrderStatusI18ns->remove($this->collOrderStatusI18ns->search($orderStatusI18n));
+ if (null === $this->orderStatusI18nsScheduledForDeletion) {
+ $this->orderStatusI18nsScheduledForDeletion = clone $this->collOrderStatusI18ns;
+ $this->orderStatusI18nsScheduledForDeletion->clear();
+ }
+ $this->orderStatusI18nsScheduledForDeletion[]= clone $orderStatusI18n;
+ $orderStatusI18n->setOrderStatus(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collOrders) {
+ foreach ($this->collOrders as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collOrderStatusI18ns) {
+ foreach ($this->collOrderStatusI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collOrders instanceof Collection) {
+ $this->collOrders->clearIterator();
+ }
+ $this->collOrders = null;
+ if ($this->collOrderStatusI18ns instanceof Collection) {
+ $this->collOrderStatusI18ns->clearIterator();
+ }
+ $this->collOrderStatusI18ns = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderStatusTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildOrderStatus The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = OrderStatusTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildOrderStatus The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildOrderStatusI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collOrderStatusI18ns) {
+ foreach ($this->collOrderStatusI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildOrderStatusI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildOrderStatusI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addOrderStatusI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildOrderStatus The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildOrderStatusI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collOrderStatusI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collOrderStatusI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildOrderStatusI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/OrderStatusI18n.php b/core/lib/Thelia/Model/Base/OrderStatusI18n.php
new file mode 100644
index 000000000..1f98739f0
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderStatusI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\OrderStatusI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another OrderStatusI18n instance. If
+ * obj is an instance of OrderStatusI18n, delegates to
+ * equals(OrderStatusI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return OrderStatusI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return OrderStatusI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = OrderStatusI18nTableMap::ID;
+ }
+
+ if ($this->aOrderStatus !== null && $this->aOrderStatus->getId() !== $v) {
+ $this->aOrderStatus = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = OrderStatusI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = OrderStatusI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = OrderStatusI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = OrderStatusI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = OrderStatusI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderStatusI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderStatusI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderStatusI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderStatusI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderStatusI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderStatusI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = OrderStatusI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\OrderStatusI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aOrderStatus !== null && $this->id !== $this->aOrderStatus->getId()) {
+ $this->aOrderStatus = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderStatusI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildOrderStatusI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aOrderStatus = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see OrderStatusI18n::setDeleted()
+ * @see OrderStatusI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildOrderStatusI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ OrderStatusI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aOrderStatus !== null) {
+ if ($this->aOrderStatus->isModified() || $this->aOrderStatus->isNew()) {
+ $affectedRows += $this->aOrderStatus->save($con);
+ }
+ $this->setOrderStatus($this->aOrderStatus);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(OrderStatusI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(OrderStatusI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(OrderStatusI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(OrderStatusI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(OrderStatusI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(OrderStatusI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO order_status_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderStatusI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['OrderStatusI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['OrderStatusI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = OrderStatusI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aOrderStatus) {
+ $result['OrderStatus'] = $this->aOrderStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = OrderStatusI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = OrderStatusI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(OrderStatusI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(OrderStatusI18nTableMap::ID)) $criteria->add(OrderStatusI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(OrderStatusI18nTableMap::LOCALE)) $criteria->add(OrderStatusI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(OrderStatusI18nTableMap::TITLE)) $criteria->add(OrderStatusI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(OrderStatusI18nTableMap::DESCRIPTION)) $criteria->add(OrderStatusI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(OrderStatusI18nTableMap::CHAPO)) $criteria->add(OrderStatusI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(OrderStatusI18nTableMap::POSTSCRIPTUM)) $criteria->add(OrderStatusI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(OrderStatusI18nTableMap::DATABASE_NAME);
+ $criteria->add(OrderStatusI18nTableMap::ID, $this->id);
+ $criteria->add(OrderStatusI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\OrderStatusI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\OrderStatusI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildOrderStatus object.
+ *
+ * @param ChildOrderStatus $v
+ * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setOrderStatus(ChildOrderStatus $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aOrderStatus = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildOrderStatus object, it will not be re-added.
+ if ($v !== null) {
+ $v->addOrderStatusI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildOrderStatus object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildOrderStatus The associated ChildOrderStatus object.
+ * @throws PropelException
+ */
+ public function getOrderStatus(ConnectionInterface $con = null)
+ {
+ if ($this->aOrderStatus === null && ($this->id !== null)) {
+ $this->aOrderStatus = ChildOrderStatusQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aOrderStatus->addOrderStatusI18ns($this);
+ */
+ }
+
+ return $this->aOrderStatus;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aOrderStatus = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(OrderStatusI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/OrderStatusI18nQuery.php b/core/lib/Thelia/Model/Base/OrderStatusI18nQuery.php
new file mode 100644
index 000000000..58127979f
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderStatusI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildOrderStatusI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderStatusI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderStatusI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildOrderStatusI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM order_status_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildOrderStatusI18n();
+ $obj->hydrate($row);
+ OrderStatusI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildOrderStatusI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildOrderStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(OrderStatusI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(OrderStatusI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildOrderStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(OrderStatusI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(OrderStatusI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByOrderStatus()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(OrderStatusI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(OrderStatusI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\OrderStatus object
+ *
+ * @param \Thelia\Model\OrderStatus|ObjectCollection $orderStatus The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderStatusI18nQuery The current query, for fluid interface
+ */
+ public function filterByOrderStatus($orderStatus, $comparison = null)
+ {
+ if ($orderStatus instanceof \Thelia\Model\OrderStatus) {
+ return $this
+ ->addUsingAlias(OrderStatusI18nTableMap::ID, $orderStatus->getId(), $comparison);
+ } elseif ($orderStatus instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(OrderStatusI18nTableMap::ID, $orderStatus->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByOrderStatus() only accepts arguments of type \Thelia\Model\OrderStatus or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderStatus relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderStatusI18nQuery The current query, for fluid interface
+ */
+ public function joinOrderStatus($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderStatus');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'OrderStatus');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderStatus relation OrderStatus object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderStatusQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderStatusQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinOrderStatus($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderStatus', '\Thelia\Model\OrderStatusQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildOrderStatusI18n $orderStatusI18n Object to remove from the list of results
+ *
+ * @return ChildOrderStatusI18nQuery The current query, for fluid interface
+ */
+ public function prune($orderStatusI18n = null)
+ {
+ if ($orderStatusI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(OrderStatusI18nTableMap::ID), $orderStatusI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(OrderStatusI18nTableMap::LOCALE), $orderStatusI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the order_status_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ OrderStatusI18nTableMap::clearInstancePool();
+ OrderStatusI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildOrderStatusI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildOrderStatusI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderStatusI18nTableMap::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->beginTransaction();
+
+
+ OrderStatusI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ OrderStatusI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // OrderStatusI18nQuery
diff --git a/core/lib/Thelia/Model/Base/OrderStatusQuery.php b/core/lib/Thelia/Model/Base/OrderStatusQuery.php
new file mode 100644
index 000000000..07fcdb8dc
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/OrderStatusQuery.php
@@ -0,0 +1,752 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildOrderStatus|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = OrderStatusTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(OrderStatusTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildOrderStatus A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CODE, CREATED_AT, UPDATED_AT FROM order_status WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildOrderStatus();
+ $obj->hydrate($row);
+ OrderStatusTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildOrderStatus|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(OrderStatusTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(OrderStatusTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(OrderStatusTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(OrderStatusTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusTableMap::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(OrderStatusTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(OrderStatusTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(OrderStatusTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(OrderStatusTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(OrderStatusTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Order object
+ *
+ * @param \Thelia\Model\Order|ObjectCollection $order the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function filterByOrder($order, $comparison = null)
+ {
+ if ($order instanceof \Thelia\Model\Order) {
+ return $this
+ ->addUsingAlias(OrderStatusTableMap::ID, $order->getStatusId(), $comparison);
+ } elseif ($order instanceof ObjectCollection) {
+ return $this
+ ->useOrderQuery()
+ ->filterByPrimaryKeys($order->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Order relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Order');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Order');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Order relation Order object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinOrder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\OrderStatusI18n object
+ *
+ * @param \Thelia\Model\OrderStatusI18n|ObjectCollection $orderStatusI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function filterByOrderStatusI18n($orderStatusI18n, $comparison = null)
+ {
+ if ($orderStatusI18n instanceof \Thelia\Model\OrderStatusI18n) {
+ return $this
+ ->addUsingAlias(OrderStatusTableMap::ID, $orderStatusI18n->getId(), $comparison);
+ } elseif ($orderStatusI18n instanceof ObjectCollection) {
+ return $this
+ ->useOrderStatusI18nQuery()
+ ->filterByPrimaryKeys($orderStatusI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByOrderStatusI18n() only accepts arguments of type \Thelia\Model\OrderStatusI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the OrderStatusI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function joinOrderStatusI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('OrderStatusI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'OrderStatusI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the OrderStatusI18n relation OrderStatusI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\OrderStatusI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useOrderStatusI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinOrderStatusI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderStatusI18n', '\Thelia\Model\OrderStatusI18nQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildOrderStatus $orderStatus Object to remove from the list of results
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function prune($orderStatus = null)
+ {
+ if ($orderStatus) {
+ $this->addUsingAlias(OrderStatusTableMap::ID, $orderStatus->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the order_status table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ OrderStatusTableMap::clearInstancePool();
+ OrderStatusTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildOrderStatus or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildOrderStatus object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(OrderStatusTableMap::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->beginTransaction();
+
+
+ OrderStatusTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ OrderStatusTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(OrderStatusTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(OrderStatusTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(OrderStatusTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(OrderStatusTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(OrderStatusTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(OrderStatusTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'OrderStatusI18n';
+
+ return $this
+ ->joinOrderStatusI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildOrderStatusQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('OrderStatusI18n');
+ $this->with['OrderStatusI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildOrderStatusI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'OrderStatusI18n', '\Thelia\Model\OrderStatusI18nQuery');
+ }
+
+} // OrderStatusQuery
diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php
new file mode 100644
index 000000000..29769aef9
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Product.php
@@ -0,0 +1,6798 @@
+newness = 0;
+ $this->promo = 0;
+ $this->quantity = 0;
+ $this->visible = 0;
+ $this->version = 0;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\Product object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Product instance. If
+ * obj is an instance of Product, delegates to
+ * equals(Product). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Product The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Product The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [tax_rule_id] column value.
+ *
+ * @return int
+ */
+ public function getTaxRuleId()
+ {
+
+ return $this->tax_rule_id;
+ }
+
+ /**
+ * Get the [ref] column value.
+ *
+ * @return string
+ */
+ public function getRef()
+ {
+
+ return $this->ref;
+ }
+
+ /**
+ * Get the [price] column value.
+ *
+ * @return double
+ */
+ public function getPrice()
+ {
+
+ return $this->price;
+ }
+
+ /**
+ * Get the [price2] column value.
+ *
+ * @return double
+ */
+ public function getPrice2()
+ {
+
+ return $this->price2;
+ }
+
+ /**
+ * Get the [ecotax] column value.
+ *
+ * @return double
+ */
+ public function getEcotax()
+ {
+
+ return $this->ecotax;
+ }
+
+ /**
+ * Get the [newness] column value.
+ *
+ * @return int
+ */
+ public function getNewness()
+ {
+
+ return $this->newness;
+ }
+
+ /**
+ * Get the [promo] column value.
+ *
+ * @return int
+ */
+ public function getPromo()
+ {
+
+ return $this->promo;
+ }
+
+ /**
+ * Get the [quantity] column value.
+ *
+ * @return int
+ */
+ public function getQuantity()
+ {
+
+ return $this->quantity;
+ }
+
+ /**
+ * Get the [visible] column value.
+ *
+ * @return int
+ */
+ public function getVisible()
+ {
+
+ return $this->visible;
+ }
+
+ /**
+ * Get the [weight] column value.
+ *
+ * @return double
+ */
+ public function getWeight()
+ {
+
+ return $this->weight;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getVersionCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->version_created_at;
+ } else {
+ return $this->version_created_at !== null ? $this->version_created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ProductTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [tax_rule_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setTaxRuleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->tax_rule_id !== $v) {
+ $this->tax_rule_id = $v;
+ $this->modifiedColumns[] = ProductTableMap::TAX_RULE_ID;
+ }
+
+ if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) {
+ $this->aTaxRule = null;
+ }
+
+
+ return $this;
+ } // setTaxRuleId()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->ref !== $v) {
+ $this->ref = $v;
+ $this->modifiedColumns[] = ProductTableMap::REF;
+ }
+
+
+ return $this;
+ } // setRef()
+
+ /**
+ * Set the value of [price] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setPrice($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->price !== $v) {
+ $this->price = $v;
+ $this->modifiedColumns[] = ProductTableMap::PRICE;
+ }
+
+
+ return $this;
+ } // setPrice()
+
+ /**
+ * Set the value of [price2] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setPrice2($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->price2 !== $v) {
+ $this->price2 = $v;
+ $this->modifiedColumns[] = ProductTableMap::PRICE2;
+ }
+
+
+ return $this;
+ } // setPrice2()
+
+ /**
+ * Set the value of [ecotax] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setEcotax($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->ecotax !== $v) {
+ $this->ecotax = $v;
+ $this->modifiedColumns[] = ProductTableMap::ECOTAX;
+ }
+
+
+ return $this;
+ } // setEcotax()
+
+ /**
+ * Set the value of [newness] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setNewness($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->newness !== $v) {
+ $this->newness = $v;
+ $this->modifiedColumns[] = ProductTableMap::NEWNESS;
+ }
+
+
+ return $this;
+ } // setNewness()
+
+ /**
+ * Set the value of [promo] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setPromo($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->promo !== $v) {
+ $this->promo = $v;
+ $this->modifiedColumns[] = ProductTableMap::PROMO;
+ }
+
+
+ return $this;
+ } // setPromo()
+
+ /**
+ * Set the value of [quantity] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setQuantity($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->quantity !== $v) {
+ $this->quantity = $v;
+ $this->modifiedColumns[] = ProductTableMap::QUANTITY;
+ }
+
+
+ return $this;
+ } // setQuantity()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setVisible($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->visible !== $v) {
+ $this->visible = $v;
+ $this->modifiedColumns[] = ProductTableMap::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [weight] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setWeight($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->weight !== $v) {
+ $this->weight = $v;
+ $this->modifiedColumns[] = ProductTableMap::WEIGHT;
+ }
+
+
+ return $this;
+ } // setWeight()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = ProductTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = ProductTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = ProductTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = ProductTableMap::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ if ($dt !== $this->version_created_at) {
+ $this->version_created_at = $dt;
+ $this->modifiedColumns[] = ProductTableMap::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = ProductTableMap::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->newness !== 0) {
+ return false;
+ }
+
+ if ($this->promo !== 0) {
+ return false;
+ }
+
+ if ($this->quantity !== 0) {
+ return false;
+ }
+
+ if ($this->visible !== 0) {
+ return false;
+ }
+
+ if ($this->version !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductTableMap::translateFieldName('TaxRuleId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->tax_rule_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->ref = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->price = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductTableMap::translateFieldName('Price2', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->price2 = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductTableMap::translateFieldName('Ecotax', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->ecotax = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductTableMap::translateFieldName('Newness', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->newness = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductTableMap::translateFieldName('Promo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->promo = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->quantity = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->visible = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : ProductTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->weight = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : ProductTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : ProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : ProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : ProductTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : ProductTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : ProductTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version_created_by = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 17; // 17 = ProductTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Product object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aTaxRule !== null && $this->tax_rule_id !== $this->aTaxRule->getId()) {
+ $this->aTaxRule = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ProductTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildProductQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aTaxRule = null;
+ $this->collProductCategories = null;
+
+ $this->collFeatureProds = null;
+
+ $this->collStocks = null;
+
+ $this->collContentAssocs = null;
+
+ $this->collImages = null;
+
+ $this->collDocuments = null;
+
+ $this->collAccessoriesRelatedByProductId = null;
+
+ $this->collAccessoriesRelatedByAccessory = null;
+
+ $this->collRewritings = null;
+
+ $this->collProductI18ns = null;
+
+ $this->collProductVersions = null;
+
+ $this->collCategories = null;
+ $this->collProductsRelatedByAccessory = null;
+ $this->collProductsRelatedByProductId = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Product::setDeleted()
+ * @see Product::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildProductQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ // versionable behavior
+ if ($this->isVersioningNecessary()) {
+ $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1);
+ if (!$this->isColumnModified(ProductTableMap::VERSION_CREATED_AT)) {
+ $this->setVersionCreatedAt(time());
+ }
+ $createVersion = true; // for postSave hook
+ }
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(ProductTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(ProductTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(ProductTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ // versionable behavior
+ if (isset($createVersion)) {
+ $this->addVersion($con);
+ }
+ ProductTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aTaxRule !== null) {
+ if ($this->aTaxRule->isModified() || $this->aTaxRule->isNew()) {
+ $affectedRows += $this->aTaxRule->save($con);
+ }
+ $this->setTaxRule($this->aTaxRule);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->categoriesScheduledForDeletion !== null) {
+ if (!$this->categoriesScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->categoriesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($pk, $remotePk);
+ }
+
+ ProductCategoryQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->categoriesScheduledForDeletion = null;
+ }
+
+ foreach ($this->getCategories() as $category) {
+ if ($category->isModified()) {
+ $category->save($con);
+ }
+ }
+ } elseif ($this->collCategories) {
+ foreach ($this->collCategories as $category) {
+ if ($category->isModified()) {
+ $category->save($con);
+ }
+ }
+ }
+
+ if ($this->productsRelatedByAccessoryScheduledForDeletion !== null) {
+ if (!$this->productsRelatedByAccessoryScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->productsRelatedByAccessoryScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($pk, $remotePk);
+ }
+
+ AccessoryRelatedByProductIdQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->productsRelatedByAccessoryScheduledForDeletion = null;
+ }
+
+ foreach ($this->getProductsRelatedByAccessory() as $productRelatedByAccessory) {
+ if ($productRelatedByAccessory->isModified()) {
+ $productRelatedByAccessory->save($con);
+ }
+ }
+ } elseif ($this->collProductsRelatedByAccessory) {
+ foreach ($this->collProductsRelatedByAccessory as $productRelatedByAccessory) {
+ if ($productRelatedByAccessory->isModified()) {
+ $productRelatedByAccessory->save($con);
+ }
+ }
+ }
+
+ if ($this->productsRelatedByProductIdScheduledForDeletion !== null) {
+ if (!$this->productsRelatedByProductIdScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->productsRelatedByProductIdScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($pk, $remotePk);
+ }
+
+ AccessoryRelatedByAccessoryQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->productsRelatedByProductIdScheduledForDeletion = null;
+ }
+
+ foreach ($this->getProductsRelatedByProductId() as $productRelatedByProductId) {
+ if ($productRelatedByProductId->isModified()) {
+ $productRelatedByProductId->save($con);
+ }
+ }
+ } elseif ($this->collProductsRelatedByProductId) {
+ foreach ($this->collProductsRelatedByProductId as $productRelatedByProductId) {
+ if ($productRelatedByProductId->isModified()) {
+ $productRelatedByProductId->save($con);
+ }
+ }
+ }
+
+ if ($this->productCategoriesScheduledForDeletion !== null) {
+ if (!$this->productCategoriesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ProductCategoryQuery::create()
+ ->filterByPrimaryKeys($this->productCategoriesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->productCategoriesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collProductCategories !== null) {
+ foreach ($this->collProductCategories as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->featureProdsScheduledForDeletion !== null) {
+ if (!$this->featureProdsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\FeatureProdQuery::create()
+ ->filterByPrimaryKeys($this->featureProdsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->featureProdsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collFeatureProds !== null) {
+ foreach ($this->collFeatureProds as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->stocksScheduledForDeletion !== null) {
+ if (!$this->stocksScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\StockQuery::create()
+ ->filterByPrimaryKeys($this->stocksScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->stocksScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collStocks !== null) {
+ foreach ($this->collStocks as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->contentAssocsScheduledForDeletion !== null) {
+ if (!$this->contentAssocsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ContentAssocQuery::create()
+ ->filterByPrimaryKeys($this->contentAssocsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->contentAssocsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collContentAssocs !== null) {
+ foreach ($this->collContentAssocs as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->imagesScheduledForDeletion !== null) {
+ if (!$this->imagesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ImageQuery::create()
+ ->filterByPrimaryKeys($this->imagesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->imagesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collImages !== null) {
+ foreach ($this->collImages as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->documentsScheduledForDeletion !== null) {
+ if (!$this->documentsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\DocumentQuery::create()
+ ->filterByPrimaryKeys($this->documentsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->documentsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collDocuments !== null) {
+ foreach ($this->collDocuments as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->accessoriesRelatedByProductIdScheduledForDeletion !== null) {
+ if (!$this->accessoriesRelatedByProductIdScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\AccessoryQuery::create()
+ ->filterByPrimaryKeys($this->accessoriesRelatedByProductIdScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->accessoriesRelatedByProductIdScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAccessoriesRelatedByProductId !== null) {
+ foreach ($this->collAccessoriesRelatedByProductId as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->accessoriesRelatedByAccessoryScheduledForDeletion !== null) {
+ if (!$this->accessoriesRelatedByAccessoryScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\AccessoryQuery::create()
+ ->filterByPrimaryKeys($this->accessoriesRelatedByAccessoryScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->accessoriesRelatedByAccessoryScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collAccessoriesRelatedByAccessory !== null) {
+ foreach ($this->collAccessoriesRelatedByAccessory as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->rewritingsScheduledForDeletion !== null) {
+ if (!$this->rewritingsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\RewritingQuery::create()
+ ->filterByPrimaryKeys($this->rewritingsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->rewritingsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collRewritings !== null) {
+ foreach ($this->collRewritings as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->productI18nsScheduledForDeletion !== null) {
+ if (!$this->productI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ProductI18nQuery::create()
+ ->filterByPrimaryKeys($this->productI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->productI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collProductI18ns !== null) {
+ foreach ($this->collProductI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->productVersionsScheduledForDeletion !== null) {
+ if (!$this->productVersionsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ProductVersionQuery::create()
+ ->filterByPrimaryKeys($this->productVersionsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->productVersionsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collProductVersions !== null) {
+ foreach ($this->collProductVersions as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ProductTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProductTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ProductTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ProductTableMap::TAX_RULE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'TAX_RULE_ID';
+ }
+ if ($this->isColumnModified(ProductTableMap::REF)) {
+ $modifiedColumns[':p' . $index++] = 'REF';
+ }
+ if ($this->isColumnModified(ProductTableMap::PRICE)) {
+ $modifiedColumns[':p' . $index++] = 'PRICE';
+ }
+ if ($this->isColumnModified(ProductTableMap::PRICE2)) {
+ $modifiedColumns[':p' . $index++] = 'PRICE2';
+ }
+ if ($this->isColumnModified(ProductTableMap::ECOTAX)) {
+ $modifiedColumns[':p' . $index++] = 'ECOTAX';
+ }
+ if ($this->isColumnModified(ProductTableMap::NEWNESS)) {
+ $modifiedColumns[':p' . $index++] = 'NEWNESS';
+ }
+ if ($this->isColumnModified(ProductTableMap::PROMO)) {
+ $modifiedColumns[':p' . $index++] = 'PROMO';
+ }
+ if ($this->isColumnModified(ProductTableMap::QUANTITY)) {
+ $modifiedColumns[':p' . $index++] = 'QUANTITY';
+ }
+ if ($this->isColumnModified(ProductTableMap::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = 'VISIBLE';
+ }
+ if ($this->isColumnModified(ProductTableMap::WEIGHT)) {
+ $modifiedColumns[':p' . $index++] = 'WEIGHT';
+ }
+ if ($this->isColumnModified(ProductTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(ProductTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(ProductTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+ if ($this->isColumnModified(ProductTableMap::VERSION)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION';
+ }
+ if ($this->isColumnModified(ProductTableMap::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT';
+ }
+ if ($this->isColumnModified(ProductTableMap::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO product (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'TAX_RULE_ID':
+ $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT);
+ break;
+ case 'REF':
+ $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
+ break;
+ case 'PRICE':
+ $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR);
+ break;
+ case 'PRICE2':
+ $stmt->bindValue($identifier, $this->price2, PDO::PARAM_STR);
+ break;
+ case 'ECOTAX':
+ $stmt->bindValue($identifier, $this->ecotax, PDO::PARAM_STR);
+ break;
+ case 'NEWNESS':
+ $stmt->bindValue($identifier, $this->newness, PDO::PARAM_INT);
+ break;
+ case 'PROMO':
+ $stmt->bindValue($identifier, $this->promo, PDO::PARAM_INT);
+ break;
+ case 'QUANTITY':
+ $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_INT);
+ break;
+ case 'VISIBLE':
+ $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
+ break;
+ case 'WEIGHT':
+ $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case 'VERSION_CREATED_AT':
+ $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION_CREATED_BY':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ProductTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getTaxRuleId();
+ break;
+ case 2:
+ return $this->getRef();
+ break;
+ case 3:
+ return $this->getPrice();
+ break;
+ case 4:
+ return $this->getPrice2();
+ break;
+ case 5:
+ return $this->getEcotax();
+ break;
+ case 6:
+ return $this->getNewness();
+ break;
+ case 7:
+ return $this->getPromo();
+ break;
+ case 8:
+ return $this->getQuantity();
+ break;
+ case 9:
+ return $this->getVisible();
+ break;
+ case 10:
+ return $this->getWeight();
+ break;
+ case 11:
+ return $this->getPosition();
+ break;
+ case 12:
+ return $this->getCreatedAt();
+ break;
+ case 13:
+ return $this->getUpdatedAt();
+ break;
+ case 14:
+ return $this->getVersion();
+ break;
+ case 15:
+ return $this->getVersionCreatedAt();
+ break;
+ case 16:
+ return $this->getVersionCreatedBy();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Product'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Product'][$this->getPrimaryKey()] = true;
+ $keys = ProductTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getTaxRuleId(),
+ $keys[2] => $this->getRef(),
+ $keys[3] => $this->getPrice(),
+ $keys[4] => $this->getPrice2(),
+ $keys[5] => $this->getEcotax(),
+ $keys[6] => $this->getNewness(),
+ $keys[7] => $this->getPromo(),
+ $keys[8] => $this->getQuantity(),
+ $keys[9] => $this->getVisible(),
+ $keys[10] => $this->getWeight(),
+ $keys[11] => $this->getPosition(),
+ $keys[12] => $this->getCreatedAt(),
+ $keys[13] => $this->getUpdatedAt(),
+ $keys[14] => $this->getVersion(),
+ $keys[15] => $this->getVersionCreatedAt(),
+ $keys[16] => $this->getVersionCreatedBy(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aTaxRule) {
+ $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->collProductCategories) {
+ $result['ProductCategories'] = $this->collProductCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collFeatureProds) {
+ $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collStocks) {
+ $result['Stocks'] = $this->collStocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collContentAssocs) {
+ $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collImages) {
+ $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collDocuments) {
+ $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collAccessoriesRelatedByProductId) {
+ $result['AccessoriesRelatedByProductId'] = $this->collAccessoriesRelatedByProductId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collAccessoriesRelatedByAccessory) {
+ $result['AccessoriesRelatedByAccessory'] = $this->collAccessoriesRelatedByAccessory->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collRewritings) {
+ $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collProductI18ns) {
+ $result['ProductI18ns'] = $this->collProductI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collProductVersions) {
+ $result['ProductVersions'] = $this->collProductVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ProductTableMap::translateFieldName($name, $type, TableMap::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->setTaxRuleId($value);
+ break;
+ case 2:
+ $this->setRef($value);
+ break;
+ case 3:
+ $this->setPrice($value);
+ break;
+ case 4:
+ $this->setPrice2($value);
+ break;
+ case 5:
+ $this->setEcotax($value);
+ break;
+ case 6:
+ $this->setNewness($value);
+ break;
+ case 7:
+ $this->setPromo($value);
+ break;
+ case 8:
+ $this->setQuantity($value);
+ break;
+ case 9:
+ $this->setVisible($value);
+ break;
+ case 10:
+ $this->setWeight($value);
+ break;
+ case 11:
+ $this->setPosition($value);
+ break;
+ case 12:
+ $this->setCreatedAt($value);
+ break;
+ case 13:
+ $this->setUpdatedAt($value);
+ break;
+ case 14:
+ $this->setVersion($value);
+ break;
+ case 15:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 16:
+ $this->setVersionCreatedBy($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ProductTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setTaxRuleId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setRef($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setPrice($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPrice2($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setEcotax($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setNewness($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setPromo($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setQuantity($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setVisible($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setWeight($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setPosition($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]);
+ if (array_key_exists($keys[14], $arr)) $this->setVersion($arr[$keys[14]]);
+ if (array_key_exists($keys[15], $arr)) $this->setVersionCreatedAt($arr[$keys[15]]);
+ if (array_key_exists($keys[16], $arr)) $this->setVersionCreatedBy($arr[$keys[16]]);
+ }
+
+ /**
+ * 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(ProductTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ProductTableMap::ID)) $criteria->add(ProductTableMap::ID, $this->id);
+ if ($this->isColumnModified(ProductTableMap::TAX_RULE_ID)) $criteria->add(ProductTableMap::TAX_RULE_ID, $this->tax_rule_id);
+ if ($this->isColumnModified(ProductTableMap::REF)) $criteria->add(ProductTableMap::REF, $this->ref);
+ if ($this->isColumnModified(ProductTableMap::PRICE)) $criteria->add(ProductTableMap::PRICE, $this->price);
+ if ($this->isColumnModified(ProductTableMap::PRICE2)) $criteria->add(ProductTableMap::PRICE2, $this->price2);
+ if ($this->isColumnModified(ProductTableMap::ECOTAX)) $criteria->add(ProductTableMap::ECOTAX, $this->ecotax);
+ if ($this->isColumnModified(ProductTableMap::NEWNESS)) $criteria->add(ProductTableMap::NEWNESS, $this->newness);
+ if ($this->isColumnModified(ProductTableMap::PROMO)) $criteria->add(ProductTableMap::PROMO, $this->promo);
+ if ($this->isColumnModified(ProductTableMap::QUANTITY)) $criteria->add(ProductTableMap::QUANTITY, $this->quantity);
+ if ($this->isColumnModified(ProductTableMap::VISIBLE)) $criteria->add(ProductTableMap::VISIBLE, $this->visible);
+ if ($this->isColumnModified(ProductTableMap::WEIGHT)) $criteria->add(ProductTableMap::WEIGHT, $this->weight);
+ if ($this->isColumnModified(ProductTableMap::POSITION)) $criteria->add(ProductTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(ProductTableMap::CREATED_AT)) $criteria->add(ProductTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ProductTableMap::UPDATED_AT)) $criteria->add(ProductTableMap::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(ProductTableMap::VERSION)) $criteria->add(ProductTableMap::VERSION, $this->version);
+ if ($this->isColumnModified(ProductTableMap::VERSION_CREATED_AT)) $criteria->add(ProductTableMap::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(ProductTableMap::VERSION_CREATED_BY)) $criteria->add(ProductTableMap::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(ProductTableMap::DATABASE_NAME);
+ $criteria->add(ProductTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Product (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setTaxRuleId($this->getTaxRuleId());
+ $copyObj->setRef($this->getRef());
+ $copyObj->setPrice($this->getPrice());
+ $copyObj->setPrice2($this->getPrice2());
+ $copyObj->setEcotax($this->getEcotax());
+ $copyObj->setNewness($this->getNewness());
+ $copyObj->setPromo($this->getPromo());
+ $copyObj->setQuantity($this->getQuantity());
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setWeight($this->getWeight());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+
+ 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->getProductCategories() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addProductCategory($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getFeatureProds() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addFeatureProd($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getStocks() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addStock($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getContentAssocs() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addContentAssoc($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getImages() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addImage($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getDocuments() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addDocument($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getAccessoriesRelatedByProductId() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAccessoryRelatedByProductId($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getAccessoriesRelatedByAccessory() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addAccessoryRelatedByAccessory($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getRewritings() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addRewriting($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getProductI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addProductI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getProductVersions() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addProductVersion($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Product 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildTaxRule object.
+ *
+ * @param ChildTaxRule $v
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setTaxRule(ChildTaxRule $v = null)
+ {
+ if ($v === null) {
+ $this->setTaxRuleId(NULL);
+ } else {
+ $this->setTaxRuleId($v->getId());
+ }
+
+ $this->aTaxRule = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildTaxRule object, it will not be re-added.
+ if ($v !== null) {
+ $v->addProduct($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildTaxRule object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildTaxRule The associated ChildTaxRule object.
+ * @throws PropelException
+ */
+ public function getTaxRule(ConnectionInterface $con = null)
+ {
+ if ($this->aTaxRule === null && ($this->tax_rule_id !== null)) {
+ $this->aTaxRule = ChildTaxRuleQuery::create()->findPk($this->tax_rule_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aTaxRule->addProducts($this);
+ */
+ }
+
+ return $this->aTaxRule;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('ProductCategory' == $relationName) {
+ return $this->initProductCategories();
+ }
+ if ('FeatureProd' == $relationName) {
+ return $this->initFeatureProds();
+ }
+ if ('Stock' == $relationName) {
+ return $this->initStocks();
+ }
+ if ('ContentAssoc' == $relationName) {
+ return $this->initContentAssocs();
+ }
+ if ('Image' == $relationName) {
+ return $this->initImages();
+ }
+ if ('Document' == $relationName) {
+ return $this->initDocuments();
+ }
+ if ('AccessoryRelatedByProductId' == $relationName) {
+ return $this->initAccessoriesRelatedByProductId();
+ }
+ if ('AccessoryRelatedByAccessory' == $relationName) {
+ return $this->initAccessoriesRelatedByAccessory();
+ }
+ if ('Rewriting' == $relationName) {
+ return $this->initRewritings();
+ }
+ if ('ProductI18n' == $relationName) {
+ return $this->initProductI18ns();
+ }
+ if ('ProductVersion' == $relationName) {
+ return $this->initProductVersions();
+ }
+ }
+
+ /**
+ * Clears out the collProductCategories collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addProductCategories()
+ */
+ public function clearProductCategories()
+ {
+ $this->collProductCategories = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collProductCategories collection loaded partially.
+ */
+ public function resetPartialProductCategories($v = true)
+ {
+ $this->collProductCategoriesPartial = $v;
+ }
+
+ /**
+ * Initializes the collProductCategories collection.
+ *
+ * By default this just sets the collProductCategories collection to an empty array (like clearcollProductCategories());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initProductCategories($overrideExisting = true)
+ {
+ if (null !== $this->collProductCategories && !$overrideExisting) {
+ return;
+ }
+ $this->collProductCategories = new ObjectCollection();
+ $this->collProductCategories->setModel('\Thelia\Model\ProductCategory');
+ }
+
+ /**
+ * Gets an array of ChildProductCategory objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildProductCategory[] List of ChildProductCategory objects
+ * @throws PropelException
+ */
+ public function getProductCategories($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collProductCategoriesPartial && !$this->isNew();
+ if (null === $this->collProductCategories || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProductCategories) {
+ // return empty collection
+ $this->initProductCategories();
+ } else {
+ $collProductCategories = ChildProductCategoryQuery::create(null, $criteria)
+ ->filterByProduct($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collProductCategoriesPartial && count($collProductCategories)) {
+ $this->initProductCategories(false);
+
+ foreach ($collProductCategories as $obj) {
+ if (false == $this->collProductCategories->contains($obj)) {
+ $this->collProductCategories->append($obj);
+ }
+ }
+
+ $this->collProductCategoriesPartial = true;
+ }
+
+ $collProductCategories->getInternalIterator()->rewind();
+
+ return $collProductCategories;
+ }
+
+ if ($partial && $this->collProductCategories) {
+ foreach ($this->collProductCategories as $obj) {
+ if ($obj->isNew()) {
+ $collProductCategories[] = $obj;
+ }
+ }
+ }
+
+ $this->collProductCategories = $collProductCategories;
+ $this->collProductCategoriesPartial = false;
+ }
+ }
+
+ return $this->collProductCategories;
+ }
+
+ /**
+ * Sets a collection of ProductCategory objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $productCategories A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setProductCategories(Collection $productCategories, ConnectionInterface $con = null)
+ {
+ $productCategoriesToDelete = $this->getProductCategories(new Criteria(), $con)->diff($productCategories);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->productCategoriesScheduledForDeletion = clone $productCategoriesToDelete;
+
+ foreach ($productCategoriesToDelete as $productCategoryRemoved) {
+ $productCategoryRemoved->setProduct(null);
+ }
+
+ $this->collProductCategories = null;
+ foreach ($productCategories as $productCategory) {
+ $this->addProductCategory($productCategory);
+ }
+
+ $this->collProductCategories = $productCategories;
+ $this->collProductCategoriesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ProductCategory objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ProductCategory objects.
+ * @throws PropelException
+ */
+ public function countProductCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collProductCategoriesPartial && !$this->isNew();
+ if (null === $this->collProductCategories || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProductCategories) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getProductCategories());
+ }
+
+ $query = ChildProductCategoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProduct($this)
+ ->count($con);
+ }
+
+ return count($this->collProductCategories);
+ }
+
+ /**
+ * Method called to associate a ChildProductCategory object to this object
+ * through the ChildProductCategory foreign key attribute.
+ *
+ * @param ChildProductCategory $l ChildProductCategory
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function addProductCategory(ChildProductCategory $l)
+ {
+ if ($this->collProductCategories === null) {
+ $this->initProductCategories();
+ $this->collProductCategoriesPartial = true;
+ }
+
+ if (!in_array($l, $this->collProductCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddProductCategory($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ProductCategory $productCategory The productCategory object to add.
+ */
+ protected function doAddProductCategory($productCategory)
+ {
+ $this->collProductCategories[]= $productCategory;
+ $productCategory->setProduct($this);
+ }
+
+ /**
+ * @param ProductCategory $productCategory The productCategory object to remove.
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeProductCategory($productCategory)
+ {
+ if ($this->getProductCategories()->contains($productCategory)) {
+ $this->collProductCategories->remove($this->collProductCategories->search($productCategory));
+ if (null === $this->productCategoriesScheduledForDeletion) {
+ $this->productCategoriesScheduledForDeletion = clone $this->collProductCategories;
+ $this->productCategoriesScheduledForDeletion->clear();
+ }
+ $this->productCategoriesScheduledForDeletion[]= clone $productCategory;
+ $productCategory->setProduct(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related ProductCategories 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildProductCategory[] List of ChildProductCategory objects
+ */
+ public function getProductCategoriesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildProductCategoryQuery::create(null, $criteria);
+ $query->joinWith('Category', $joinBehavior);
+
+ return $this->getProductCategories($query, $con);
+ }
+
+ /**
+ * Clears out the collFeatureProds collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addFeatureProds()
+ */
+ public function clearFeatureProds()
+ {
+ $this->collFeatureProds = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collFeatureProds collection loaded partially.
+ */
+ public function resetPartialFeatureProds($v = true)
+ {
+ $this->collFeatureProdsPartial = $v;
+ }
+
+ /**
+ * Initializes the collFeatureProds collection.
+ *
+ * By default this just sets the collFeatureProds collection to an empty array (like clearcollFeatureProds());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initFeatureProds($overrideExisting = true)
+ {
+ if (null !== $this->collFeatureProds && !$overrideExisting) {
+ return;
+ }
+ $this->collFeatureProds = new ObjectCollection();
+ $this->collFeatureProds->setModel('\Thelia\Model\FeatureProd');
+ }
+
+ /**
+ * Gets an array of ChildFeatureProd objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects
+ * @throws PropelException
+ */
+ public function getFeatureProds($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureProdsPartial && !$this->isNew();
+ if (null === $this->collFeatureProds || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureProds) {
+ // return empty collection
+ $this->initFeatureProds();
+ } else {
+ $collFeatureProds = ChildFeatureProdQuery::create(null, $criteria)
+ ->filterByProduct($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) {
+ $this->initFeatureProds(false);
+
+ foreach ($collFeatureProds as $obj) {
+ if (false == $this->collFeatureProds->contains($obj)) {
+ $this->collFeatureProds->append($obj);
+ }
+ }
+
+ $this->collFeatureProdsPartial = true;
+ }
+
+ $collFeatureProds->getInternalIterator()->rewind();
+
+ return $collFeatureProds;
+ }
+
+ if ($partial && $this->collFeatureProds) {
+ foreach ($this->collFeatureProds as $obj) {
+ if ($obj->isNew()) {
+ $collFeatureProds[] = $obj;
+ }
+ }
+ }
+
+ $this->collFeatureProds = $collFeatureProds;
+ $this->collFeatureProdsPartial = false;
+ }
+ }
+
+ return $this->collFeatureProds;
+ }
+
+ /**
+ * Sets a collection of FeatureProd objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $featureProds A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setFeatureProds(Collection $featureProds, ConnectionInterface $con = null)
+ {
+ $featureProdsToDelete = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds);
+
+
+ $this->featureProdsScheduledForDeletion = $featureProdsToDelete;
+
+ foreach ($featureProdsToDelete as $featureProdRemoved) {
+ $featureProdRemoved->setProduct(null);
+ }
+
+ $this->collFeatureProds = null;
+ foreach ($featureProds as $featureProd) {
+ $this->addFeatureProd($featureProd);
+ }
+
+ $this->collFeatureProds = $featureProds;
+ $this->collFeatureProdsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related FeatureProd objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related FeatureProd objects.
+ * @throws PropelException
+ */
+ public function countFeatureProds(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collFeatureProdsPartial && !$this->isNew();
+ if (null === $this->collFeatureProds || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collFeatureProds) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getFeatureProds());
+ }
+
+ $query = ChildFeatureProdQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProduct($this)
+ ->count($con);
+ }
+
+ return count($this->collFeatureProds);
+ }
+
+ /**
+ * Method called to associate a ChildFeatureProd object to this object
+ * through the ChildFeatureProd foreign key attribute.
+ *
+ * @param ChildFeatureProd $l ChildFeatureProd
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function addFeatureProd(ChildFeatureProd $l)
+ {
+ if ($this->collFeatureProds === null) {
+ $this->initFeatureProds();
+ $this->collFeatureProdsPartial = true;
+ }
+
+ if (!in_array($l, $this->collFeatureProds->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddFeatureProd($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param FeatureProd $featureProd The featureProd object to add.
+ */
+ protected function doAddFeatureProd($featureProd)
+ {
+ $this->collFeatureProds[]= $featureProd;
+ $featureProd->setProduct($this);
+ }
+
+ /**
+ * @param FeatureProd $featureProd The featureProd object to remove.
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeFeatureProd($featureProd)
+ {
+ if ($this->getFeatureProds()->contains($featureProd)) {
+ $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd));
+ if (null === $this->featureProdsScheduledForDeletion) {
+ $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds;
+ $this->featureProdsScheduledForDeletion->clear();
+ }
+ $this->featureProdsScheduledForDeletion[]= clone $featureProd;
+ $featureProd->setProduct(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related FeatureProds 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects
+ */
+ public function getFeatureProdsJoinFeature($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildFeatureProdQuery::create(null, $criteria);
+ $query->joinWith('Feature', $joinBehavior);
+
+ return $this->getFeatureProds($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related FeatureProds 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects
+ */
+ public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildFeatureProdQuery::create(null, $criteria);
+ $query->joinWith('FeatureAv', $joinBehavior);
+
+ return $this->getFeatureProds($query, $con);
+ }
+
+ /**
+ * Clears out the collStocks collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addStocks()
+ */
+ public function clearStocks()
+ {
+ $this->collStocks = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collStocks collection loaded partially.
+ */
+ public function resetPartialStocks($v = true)
+ {
+ $this->collStocksPartial = $v;
+ }
+
+ /**
+ * Initializes the collStocks collection.
+ *
+ * By default this just sets the collStocks collection to an empty array (like clearcollStocks());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initStocks($overrideExisting = true)
+ {
+ if (null !== $this->collStocks && !$overrideExisting) {
+ return;
+ }
+ $this->collStocks = new ObjectCollection();
+ $this->collStocks->setModel('\Thelia\Model\Stock');
+ }
+
+ /**
+ * Gets an array of ChildStock objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildStock[] List of ChildStock objects
+ * @throws PropelException
+ */
+ public function getStocks($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collStocksPartial && !$this->isNew();
+ if (null === $this->collStocks || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collStocks) {
+ // return empty collection
+ $this->initStocks();
+ } else {
+ $collStocks = ChildStockQuery::create(null, $criteria)
+ ->filterByProduct($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collStocksPartial && count($collStocks)) {
+ $this->initStocks(false);
+
+ foreach ($collStocks as $obj) {
+ if (false == $this->collStocks->contains($obj)) {
+ $this->collStocks->append($obj);
+ }
+ }
+
+ $this->collStocksPartial = true;
+ }
+
+ $collStocks->getInternalIterator()->rewind();
+
+ return $collStocks;
+ }
+
+ if ($partial && $this->collStocks) {
+ foreach ($this->collStocks as $obj) {
+ if ($obj->isNew()) {
+ $collStocks[] = $obj;
+ }
+ }
+ }
+
+ $this->collStocks = $collStocks;
+ $this->collStocksPartial = false;
+ }
+ }
+
+ return $this->collStocks;
+ }
+
+ /**
+ * Sets a collection of Stock objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $stocks A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setStocks(Collection $stocks, ConnectionInterface $con = null)
+ {
+ $stocksToDelete = $this->getStocks(new Criteria(), $con)->diff($stocks);
+
+
+ $this->stocksScheduledForDeletion = $stocksToDelete;
+
+ foreach ($stocksToDelete as $stockRemoved) {
+ $stockRemoved->setProduct(null);
+ }
+
+ $this->collStocks = null;
+ foreach ($stocks as $stock) {
+ $this->addStock($stock);
+ }
+
+ $this->collStocks = $stocks;
+ $this->collStocksPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Stock objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Stock objects.
+ * @throws PropelException
+ */
+ public function countStocks(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collStocksPartial && !$this->isNew();
+ if (null === $this->collStocks || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collStocks) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getStocks());
+ }
+
+ $query = ChildStockQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProduct($this)
+ ->count($con);
+ }
+
+ return count($this->collStocks);
+ }
+
+ /**
+ * Method called to associate a ChildStock object to this object
+ * through the ChildStock foreign key attribute.
+ *
+ * @param ChildStock $l ChildStock
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function addStock(ChildStock $l)
+ {
+ if ($this->collStocks === null) {
+ $this->initStocks();
+ $this->collStocksPartial = true;
+ }
+
+ if (!in_array($l, $this->collStocks->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddStock($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Stock $stock The stock object to add.
+ */
+ protected function doAddStock($stock)
+ {
+ $this->collStocks[]= $stock;
+ $stock->setProduct($this);
+ }
+
+ /**
+ * @param Stock $stock The stock object to remove.
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeStock($stock)
+ {
+ if ($this->getStocks()->contains($stock)) {
+ $this->collStocks->remove($this->collStocks->search($stock));
+ if (null === $this->stocksScheduledForDeletion) {
+ $this->stocksScheduledForDeletion = clone $this->collStocks;
+ $this->stocksScheduledForDeletion->clear();
+ }
+ $this->stocksScheduledForDeletion[]= clone $stock;
+ $stock->setProduct(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related Stocks 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildStock[] List of ChildStock objects
+ */
+ public function getStocksJoinCombination($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildStockQuery::create(null, $criteria);
+ $query->joinWith('Combination', $joinBehavior);
+
+ return $this->getStocks($query, $con);
+ }
+
+ /**
+ * Clears out the collContentAssocs collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addContentAssocs()
+ */
+ public function clearContentAssocs()
+ {
+ $this->collContentAssocs = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collContentAssocs collection loaded partially.
+ */
+ public function resetPartialContentAssocs($v = true)
+ {
+ $this->collContentAssocsPartial = $v;
+ }
+
+ /**
+ * Initializes the collContentAssocs collection.
+ *
+ * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initContentAssocs($overrideExisting = true)
+ {
+ if (null !== $this->collContentAssocs && !$overrideExisting) {
+ return;
+ }
+ $this->collContentAssocs = new ObjectCollection();
+ $this->collContentAssocs->setModel('\Thelia\Model\ContentAssoc');
+ }
+
+ /**
+ * Gets an array of ChildContentAssoc objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects
+ * @throws PropelException
+ */
+ public function getContentAssocs($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collContentAssocsPartial && !$this->isNew();
+ if (null === $this->collContentAssocs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentAssocs) {
+ // return empty collection
+ $this->initContentAssocs();
+ } else {
+ $collContentAssocs = ChildContentAssocQuery::create(null, $criteria)
+ ->filterByProduct($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) {
+ $this->initContentAssocs(false);
+
+ foreach ($collContentAssocs as $obj) {
+ if (false == $this->collContentAssocs->contains($obj)) {
+ $this->collContentAssocs->append($obj);
+ }
+ }
+
+ $this->collContentAssocsPartial = true;
+ }
+
+ $collContentAssocs->getInternalIterator()->rewind();
+
+ return $collContentAssocs;
+ }
+
+ if ($partial && $this->collContentAssocs) {
+ foreach ($this->collContentAssocs as $obj) {
+ if ($obj->isNew()) {
+ $collContentAssocs[] = $obj;
+ }
+ }
+ }
+
+ $this->collContentAssocs = $collContentAssocs;
+ $this->collContentAssocsPartial = false;
+ }
+ }
+
+ return $this->collContentAssocs;
+ }
+
+ /**
+ * Sets a collection of ContentAssoc objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $contentAssocs A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setContentAssocs(Collection $contentAssocs, ConnectionInterface $con = null)
+ {
+ $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs);
+
+
+ $this->contentAssocsScheduledForDeletion = $contentAssocsToDelete;
+
+ foreach ($contentAssocsToDelete as $contentAssocRemoved) {
+ $contentAssocRemoved->setProduct(null);
+ }
+
+ $this->collContentAssocs = null;
+ foreach ($contentAssocs as $contentAssoc) {
+ $this->addContentAssoc($contentAssoc);
+ }
+
+ $this->collContentAssocs = $contentAssocs;
+ $this->collContentAssocsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ContentAssoc objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ContentAssoc objects.
+ * @throws PropelException
+ */
+ public function countContentAssocs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collContentAssocsPartial && !$this->isNew();
+ if (null === $this->collContentAssocs || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collContentAssocs) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getContentAssocs());
+ }
+
+ $query = ChildContentAssocQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProduct($this)
+ ->count($con);
+ }
+
+ return count($this->collContentAssocs);
+ }
+
+ /**
+ * Method called to associate a ChildContentAssoc object to this object
+ * through the ChildContentAssoc foreign key attribute.
+ *
+ * @param ChildContentAssoc $l ChildContentAssoc
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function addContentAssoc(ChildContentAssoc $l)
+ {
+ if ($this->collContentAssocs === null) {
+ $this->initContentAssocs();
+ $this->collContentAssocsPartial = true;
+ }
+
+ if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddContentAssoc($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ContentAssoc $contentAssoc The contentAssoc object to add.
+ */
+ protected function doAddContentAssoc($contentAssoc)
+ {
+ $this->collContentAssocs[]= $contentAssoc;
+ $contentAssoc->setProduct($this);
+ }
+
+ /**
+ * @param ContentAssoc $contentAssoc The contentAssoc object to remove.
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeContentAssoc($contentAssoc)
+ {
+ if ($this->getContentAssocs()->contains($contentAssoc)) {
+ $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc));
+ if (null === $this->contentAssocsScheduledForDeletion) {
+ $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs;
+ $this->contentAssocsScheduledForDeletion->clear();
+ }
+ $this->contentAssocsScheduledForDeletion[]= $contentAssoc;
+ $contentAssoc->setProduct(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related ContentAssocs 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects
+ */
+ public function getContentAssocsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildContentAssocQuery::create(null, $criteria);
+ $query->joinWith('Category', $joinBehavior);
+
+ return $this->getContentAssocs($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related ContentAssocs 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects
+ */
+ public function getContentAssocsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildContentAssocQuery::create(null, $criteria);
+ $query->joinWith('Content', $joinBehavior);
+
+ return $this->getContentAssocs($query, $con);
+ }
+
+ /**
+ * Clears out the collImages collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addImages()
+ */
+ public function clearImages()
+ {
+ $this->collImages = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collImages collection loaded partially.
+ */
+ public function resetPartialImages($v = true)
+ {
+ $this->collImagesPartial = $v;
+ }
+
+ /**
+ * Initializes the collImages collection.
+ *
+ * By default this just sets the collImages collection to an empty array (like clearcollImages());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initImages($overrideExisting = true)
+ {
+ if (null !== $this->collImages && !$overrideExisting) {
+ return;
+ }
+ $this->collImages = new ObjectCollection();
+ $this->collImages->setModel('\Thelia\Model\Image');
+ }
+
+ /**
+ * Gets an array of ChildImage objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildImage[] List of ChildImage objects
+ * @throws PropelException
+ */
+ public function getImages($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collImagesPartial && !$this->isNew();
+ if (null === $this->collImages || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collImages) {
+ // return empty collection
+ $this->initImages();
+ } else {
+ $collImages = ChildImageQuery::create(null, $criteria)
+ ->filterByProduct($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collImagesPartial && count($collImages)) {
+ $this->initImages(false);
+
+ foreach ($collImages as $obj) {
+ if (false == $this->collImages->contains($obj)) {
+ $this->collImages->append($obj);
+ }
+ }
+
+ $this->collImagesPartial = true;
+ }
+
+ $collImages->getInternalIterator()->rewind();
+
+ return $collImages;
+ }
+
+ if ($partial && $this->collImages) {
+ foreach ($this->collImages as $obj) {
+ if ($obj->isNew()) {
+ $collImages[] = $obj;
+ }
+ }
+ }
+
+ $this->collImages = $collImages;
+ $this->collImagesPartial = false;
+ }
+ }
+
+ return $this->collImages;
+ }
+
+ /**
+ * Sets a collection of Image objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $images A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setImages(Collection $images, ConnectionInterface $con = null)
+ {
+ $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images);
+
+
+ $this->imagesScheduledForDeletion = $imagesToDelete;
+
+ foreach ($imagesToDelete as $imageRemoved) {
+ $imageRemoved->setProduct(null);
+ }
+
+ $this->collImages = null;
+ foreach ($images as $image) {
+ $this->addImage($image);
+ }
+
+ $this->collImages = $images;
+ $this->collImagesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Image objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Image objects.
+ * @throws PropelException
+ */
+ public function countImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collImagesPartial && !$this->isNew();
+ if (null === $this->collImages || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collImages) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getImages());
+ }
+
+ $query = ChildImageQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProduct($this)
+ ->count($con);
+ }
+
+ return count($this->collImages);
+ }
+
+ /**
+ * Method called to associate a ChildImage object to this object
+ * through the ChildImage foreign key attribute.
+ *
+ * @param ChildImage $l ChildImage
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function addImage(ChildImage $l)
+ {
+ if ($this->collImages === null) {
+ $this->initImages();
+ $this->collImagesPartial = true;
+ }
+
+ if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddImage($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Image $image The image object to add.
+ */
+ protected function doAddImage($image)
+ {
+ $this->collImages[]= $image;
+ $image->setProduct($this);
+ }
+
+ /**
+ * @param Image $image The image object to remove.
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeImage($image)
+ {
+ if ($this->getImages()->contains($image)) {
+ $this->collImages->remove($this->collImages->search($image));
+ if (null === $this->imagesScheduledForDeletion) {
+ $this->imagesScheduledForDeletion = clone $this->collImages;
+ $this->imagesScheduledForDeletion->clear();
+ }
+ $this->imagesScheduledForDeletion[]= $image;
+ $image->setProduct(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related Images 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildImage[] List of ChildImage objects
+ */
+ public function getImagesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildImageQuery::create(null, $criteria);
+ $query->joinWith('Category', $joinBehavior);
+
+ return $this->getImages($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related Images 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildImage[] List of ChildImage objects
+ */
+ public function getImagesJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildImageQuery::create(null, $criteria);
+ $query->joinWith('Content', $joinBehavior);
+
+ return $this->getImages($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related Images 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildImage[] List of ChildImage objects
+ */
+ public function getImagesJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildImageQuery::create(null, $criteria);
+ $query->joinWith('Folder', $joinBehavior);
+
+ return $this->getImages($query, $con);
+ }
+
+ /**
+ * Clears out the collDocuments collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addDocuments()
+ */
+ public function clearDocuments()
+ {
+ $this->collDocuments = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collDocuments collection loaded partially.
+ */
+ public function resetPartialDocuments($v = true)
+ {
+ $this->collDocumentsPartial = $v;
+ }
+
+ /**
+ * Initializes the collDocuments collection.
+ *
+ * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initDocuments($overrideExisting = true)
+ {
+ if (null !== $this->collDocuments && !$overrideExisting) {
+ return;
+ }
+ $this->collDocuments = new ObjectCollection();
+ $this->collDocuments->setModel('\Thelia\Model\Document');
+ }
+
+ /**
+ * Gets an array of ChildDocument objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ * @throws PropelException
+ */
+ public function getDocuments($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collDocumentsPartial && !$this->isNew();
+ if (null === $this->collDocuments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocuments) {
+ // return empty collection
+ $this->initDocuments();
+ } else {
+ $collDocuments = ChildDocumentQuery::create(null, $criteria)
+ ->filterByProduct($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collDocumentsPartial && count($collDocuments)) {
+ $this->initDocuments(false);
+
+ foreach ($collDocuments as $obj) {
+ if (false == $this->collDocuments->contains($obj)) {
+ $this->collDocuments->append($obj);
+ }
+ }
+
+ $this->collDocumentsPartial = true;
+ }
+
+ $collDocuments->getInternalIterator()->rewind();
+
+ return $collDocuments;
+ }
+
+ if ($partial && $this->collDocuments) {
+ foreach ($this->collDocuments as $obj) {
+ if ($obj->isNew()) {
+ $collDocuments[] = $obj;
+ }
+ }
+ }
+
+ $this->collDocuments = $collDocuments;
+ $this->collDocumentsPartial = false;
+ }
+ }
+
+ return $this->collDocuments;
+ }
+
+ /**
+ * Sets a collection of Document objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $documents A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setDocuments(Collection $documents, ConnectionInterface $con = null)
+ {
+ $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents);
+
+
+ $this->documentsScheduledForDeletion = $documentsToDelete;
+
+ foreach ($documentsToDelete as $documentRemoved) {
+ $documentRemoved->setProduct(null);
+ }
+
+ $this->collDocuments = null;
+ foreach ($documents as $document) {
+ $this->addDocument($document);
+ }
+
+ $this->collDocuments = $documents;
+ $this->collDocumentsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Document objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Document objects.
+ * @throws PropelException
+ */
+ public function countDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collDocumentsPartial && !$this->isNew();
+ if (null === $this->collDocuments || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collDocuments) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getDocuments());
+ }
+
+ $query = ChildDocumentQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProduct($this)
+ ->count($con);
+ }
+
+ return count($this->collDocuments);
+ }
+
+ /**
+ * Method called to associate a ChildDocument object to this object
+ * through the ChildDocument foreign key attribute.
+ *
+ * @param ChildDocument $l ChildDocument
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function addDocument(ChildDocument $l)
+ {
+ if ($this->collDocuments === null) {
+ $this->initDocuments();
+ $this->collDocumentsPartial = true;
+ }
+
+ if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddDocument($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Document $document The document object to add.
+ */
+ protected function doAddDocument($document)
+ {
+ $this->collDocuments[]= $document;
+ $document->setProduct($this);
+ }
+
+ /**
+ * @param Document $document The document object to remove.
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeDocument($document)
+ {
+ if ($this->getDocuments()->contains($document)) {
+ $this->collDocuments->remove($this->collDocuments->search($document));
+ if (null === $this->documentsScheduledForDeletion) {
+ $this->documentsScheduledForDeletion = clone $this->collDocuments;
+ $this->documentsScheduledForDeletion->clear();
+ }
+ $this->documentsScheduledForDeletion[]= $document;
+ $document->setProduct(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related Documents 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ */
+ public function getDocumentsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildDocumentQuery::create(null, $criteria);
+ $query->joinWith('Category', $joinBehavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related Documents 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ */
+ public function getDocumentsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildDocumentQuery::create(null, $criteria);
+ $query->joinWith('Content', $joinBehavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related Documents 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildDocument[] List of ChildDocument objects
+ */
+ public function getDocumentsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildDocumentQuery::create(null, $criteria);
+ $query->joinWith('Folder', $joinBehavior);
+
+ return $this->getDocuments($query, $con);
+ }
+
+ /**
+ * Clears out the collAccessoriesRelatedByProductId collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAccessoriesRelatedByProductId()
+ */
+ public function clearAccessoriesRelatedByProductId()
+ {
+ $this->collAccessoriesRelatedByProductId = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collAccessoriesRelatedByProductId collection loaded partially.
+ */
+ public function resetPartialAccessoriesRelatedByProductId($v = true)
+ {
+ $this->collAccessoriesRelatedByProductIdPartial = $v;
+ }
+
+ /**
+ * Initializes the collAccessoriesRelatedByProductId collection.
+ *
+ * By default this just sets the collAccessoriesRelatedByProductId collection to an empty array (like clearcollAccessoriesRelatedByProductId());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAccessoriesRelatedByProductId($overrideExisting = true)
+ {
+ if (null !== $this->collAccessoriesRelatedByProductId && !$overrideExisting) {
+ return;
+ }
+ $this->collAccessoriesRelatedByProductId = new ObjectCollection();
+ $this->collAccessoriesRelatedByProductId->setModel('\Thelia\Model\Accessory');
+ }
+
+ /**
+ * Gets an array of ChildAccessory objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildAccessory[] List of ChildAccessory objects
+ * @throws PropelException
+ */
+ public function getAccessoriesRelatedByProductId($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAccessoriesRelatedByProductIdPartial && !$this->isNew();
+ if (null === $this->collAccessoriesRelatedByProductId || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAccessoriesRelatedByProductId) {
+ // return empty collection
+ $this->initAccessoriesRelatedByProductId();
+ } else {
+ $collAccessoriesRelatedByProductId = ChildAccessoryQuery::create(null, $criteria)
+ ->filterByProductRelatedByProductId($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collAccessoriesRelatedByProductIdPartial && count($collAccessoriesRelatedByProductId)) {
+ $this->initAccessoriesRelatedByProductId(false);
+
+ foreach ($collAccessoriesRelatedByProductId as $obj) {
+ if (false == $this->collAccessoriesRelatedByProductId->contains($obj)) {
+ $this->collAccessoriesRelatedByProductId->append($obj);
+ }
+ }
+
+ $this->collAccessoriesRelatedByProductIdPartial = true;
+ }
+
+ $collAccessoriesRelatedByProductId->getInternalIterator()->rewind();
+
+ return $collAccessoriesRelatedByProductId;
+ }
+
+ if ($partial && $this->collAccessoriesRelatedByProductId) {
+ foreach ($this->collAccessoriesRelatedByProductId as $obj) {
+ if ($obj->isNew()) {
+ $collAccessoriesRelatedByProductId[] = $obj;
+ }
+ }
+ }
+
+ $this->collAccessoriesRelatedByProductId = $collAccessoriesRelatedByProductId;
+ $this->collAccessoriesRelatedByProductIdPartial = false;
+ }
+ }
+
+ return $this->collAccessoriesRelatedByProductId;
+ }
+
+ /**
+ * Sets a collection of AccessoryRelatedByProductId objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $accessoriesRelatedByProductId A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setAccessoriesRelatedByProductId(Collection $accessoriesRelatedByProductId, ConnectionInterface $con = null)
+ {
+ $accessoriesRelatedByProductIdToDelete = $this->getAccessoriesRelatedByProductId(new Criteria(), $con)->diff($accessoriesRelatedByProductId);
+
+
+ $this->accessoriesRelatedByProductIdScheduledForDeletion = $accessoriesRelatedByProductIdToDelete;
+
+ foreach ($accessoriesRelatedByProductIdToDelete as $accessoryRelatedByProductIdRemoved) {
+ $accessoryRelatedByProductIdRemoved->setProductRelatedByProductId(null);
+ }
+
+ $this->collAccessoriesRelatedByProductId = null;
+ foreach ($accessoriesRelatedByProductId as $accessoryRelatedByProductId) {
+ $this->addAccessoryRelatedByProductId($accessoryRelatedByProductId);
+ }
+
+ $this->collAccessoriesRelatedByProductId = $accessoriesRelatedByProductId;
+ $this->collAccessoriesRelatedByProductIdPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Accessory objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Accessory objects.
+ * @throws PropelException
+ */
+ public function countAccessoriesRelatedByProductId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAccessoriesRelatedByProductIdPartial && !$this->isNew();
+ if (null === $this->collAccessoriesRelatedByProductId || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAccessoriesRelatedByProductId) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getAccessoriesRelatedByProductId());
+ }
+
+ $query = ChildAccessoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProductRelatedByProductId($this)
+ ->count($con);
+ }
+
+ return count($this->collAccessoriesRelatedByProductId);
+ }
+
+ /**
+ * Method called to associate a ChildAccessory object to this object
+ * through the ChildAccessory foreign key attribute.
+ *
+ * @param ChildAccessory $l ChildAccessory
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function addAccessoryRelatedByProductId(ChildAccessory $l)
+ {
+ if ($this->collAccessoriesRelatedByProductId === null) {
+ $this->initAccessoriesRelatedByProductId();
+ $this->collAccessoriesRelatedByProductIdPartial = true;
+ }
+
+ if (!in_array($l, $this->collAccessoriesRelatedByProductId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddAccessoryRelatedByProductId($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AccessoryRelatedByProductId $accessoryRelatedByProductId The accessoryRelatedByProductId object to add.
+ */
+ protected function doAddAccessoryRelatedByProductId($accessoryRelatedByProductId)
+ {
+ $this->collAccessoriesRelatedByProductId[]= $accessoryRelatedByProductId;
+ $accessoryRelatedByProductId->setProductRelatedByProductId($this);
+ }
+
+ /**
+ * @param AccessoryRelatedByProductId $accessoryRelatedByProductId The accessoryRelatedByProductId object to remove.
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeAccessoryRelatedByProductId($accessoryRelatedByProductId)
+ {
+ if ($this->getAccessoriesRelatedByProductId()->contains($accessoryRelatedByProductId)) {
+ $this->collAccessoriesRelatedByProductId->remove($this->collAccessoriesRelatedByProductId->search($accessoryRelatedByProductId));
+ if (null === $this->accessoriesRelatedByProductIdScheduledForDeletion) {
+ $this->accessoriesRelatedByProductIdScheduledForDeletion = clone $this->collAccessoriesRelatedByProductId;
+ $this->accessoriesRelatedByProductIdScheduledForDeletion->clear();
+ }
+ $this->accessoriesRelatedByProductIdScheduledForDeletion[]= clone $accessoryRelatedByProductId;
+ $accessoryRelatedByProductId->setProductRelatedByProductId(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collAccessoriesRelatedByAccessory collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addAccessoriesRelatedByAccessory()
+ */
+ public function clearAccessoriesRelatedByAccessory()
+ {
+ $this->collAccessoriesRelatedByAccessory = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collAccessoriesRelatedByAccessory collection loaded partially.
+ */
+ public function resetPartialAccessoriesRelatedByAccessory($v = true)
+ {
+ $this->collAccessoriesRelatedByAccessoryPartial = $v;
+ }
+
+ /**
+ * Initializes the collAccessoriesRelatedByAccessory collection.
+ *
+ * By default this just sets the collAccessoriesRelatedByAccessory collection to an empty array (like clearcollAccessoriesRelatedByAccessory());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initAccessoriesRelatedByAccessory($overrideExisting = true)
+ {
+ if (null !== $this->collAccessoriesRelatedByAccessory && !$overrideExisting) {
+ return;
+ }
+ $this->collAccessoriesRelatedByAccessory = new ObjectCollection();
+ $this->collAccessoriesRelatedByAccessory->setModel('\Thelia\Model\Accessory');
+ }
+
+ /**
+ * Gets an array of ChildAccessory objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildAccessory[] List of ChildAccessory objects
+ * @throws PropelException
+ */
+ public function getAccessoriesRelatedByAccessory($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAccessoriesRelatedByAccessoryPartial && !$this->isNew();
+ if (null === $this->collAccessoriesRelatedByAccessory || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAccessoriesRelatedByAccessory) {
+ // return empty collection
+ $this->initAccessoriesRelatedByAccessory();
+ } else {
+ $collAccessoriesRelatedByAccessory = ChildAccessoryQuery::create(null, $criteria)
+ ->filterByProductRelatedByAccessory($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collAccessoriesRelatedByAccessoryPartial && count($collAccessoriesRelatedByAccessory)) {
+ $this->initAccessoriesRelatedByAccessory(false);
+
+ foreach ($collAccessoriesRelatedByAccessory as $obj) {
+ if (false == $this->collAccessoriesRelatedByAccessory->contains($obj)) {
+ $this->collAccessoriesRelatedByAccessory->append($obj);
+ }
+ }
+
+ $this->collAccessoriesRelatedByAccessoryPartial = true;
+ }
+
+ $collAccessoriesRelatedByAccessory->getInternalIterator()->rewind();
+
+ return $collAccessoriesRelatedByAccessory;
+ }
+
+ if ($partial && $this->collAccessoriesRelatedByAccessory) {
+ foreach ($this->collAccessoriesRelatedByAccessory as $obj) {
+ if ($obj->isNew()) {
+ $collAccessoriesRelatedByAccessory[] = $obj;
+ }
+ }
+ }
+
+ $this->collAccessoriesRelatedByAccessory = $collAccessoriesRelatedByAccessory;
+ $this->collAccessoriesRelatedByAccessoryPartial = false;
+ }
+ }
+
+ return $this->collAccessoriesRelatedByAccessory;
+ }
+
+ /**
+ * Sets a collection of AccessoryRelatedByAccessory objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $accessoriesRelatedByAccessory A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setAccessoriesRelatedByAccessory(Collection $accessoriesRelatedByAccessory, ConnectionInterface $con = null)
+ {
+ $accessoriesRelatedByAccessoryToDelete = $this->getAccessoriesRelatedByAccessory(new Criteria(), $con)->diff($accessoriesRelatedByAccessory);
+
+
+ $this->accessoriesRelatedByAccessoryScheduledForDeletion = $accessoriesRelatedByAccessoryToDelete;
+
+ foreach ($accessoriesRelatedByAccessoryToDelete as $accessoryRelatedByAccessoryRemoved) {
+ $accessoryRelatedByAccessoryRemoved->setProductRelatedByAccessory(null);
+ }
+
+ $this->collAccessoriesRelatedByAccessory = null;
+ foreach ($accessoriesRelatedByAccessory as $accessoryRelatedByAccessory) {
+ $this->addAccessoryRelatedByAccessory($accessoryRelatedByAccessory);
+ }
+
+ $this->collAccessoriesRelatedByAccessory = $accessoriesRelatedByAccessory;
+ $this->collAccessoriesRelatedByAccessoryPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Accessory objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Accessory objects.
+ * @throws PropelException
+ */
+ public function countAccessoriesRelatedByAccessory(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collAccessoriesRelatedByAccessoryPartial && !$this->isNew();
+ if (null === $this->collAccessoriesRelatedByAccessory || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collAccessoriesRelatedByAccessory) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getAccessoriesRelatedByAccessory());
+ }
+
+ $query = ChildAccessoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProductRelatedByAccessory($this)
+ ->count($con);
+ }
+
+ return count($this->collAccessoriesRelatedByAccessory);
+ }
+
+ /**
+ * Method called to associate a ChildAccessory object to this object
+ * through the ChildAccessory foreign key attribute.
+ *
+ * @param ChildAccessory $l ChildAccessory
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function addAccessoryRelatedByAccessory(ChildAccessory $l)
+ {
+ if ($this->collAccessoriesRelatedByAccessory === null) {
+ $this->initAccessoriesRelatedByAccessory();
+ $this->collAccessoriesRelatedByAccessoryPartial = true;
+ }
+
+ if (!in_array($l, $this->collAccessoriesRelatedByAccessory->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddAccessoryRelatedByAccessory($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param AccessoryRelatedByAccessory $accessoryRelatedByAccessory The accessoryRelatedByAccessory object to add.
+ */
+ protected function doAddAccessoryRelatedByAccessory($accessoryRelatedByAccessory)
+ {
+ $this->collAccessoriesRelatedByAccessory[]= $accessoryRelatedByAccessory;
+ $accessoryRelatedByAccessory->setProductRelatedByAccessory($this);
+ }
+
+ /**
+ * @param AccessoryRelatedByAccessory $accessoryRelatedByAccessory The accessoryRelatedByAccessory object to remove.
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeAccessoryRelatedByAccessory($accessoryRelatedByAccessory)
+ {
+ if ($this->getAccessoriesRelatedByAccessory()->contains($accessoryRelatedByAccessory)) {
+ $this->collAccessoriesRelatedByAccessory->remove($this->collAccessoriesRelatedByAccessory->search($accessoryRelatedByAccessory));
+ if (null === $this->accessoriesRelatedByAccessoryScheduledForDeletion) {
+ $this->accessoriesRelatedByAccessoryScheduledForDeletion = clone $this->collAccessoriesRelatedByAccessory;
+ $this->accessoriesRelatedByAccessoryScheduledForDeletion->clear();
+ }
+ $this->accessoriesRelatedByAccessoryScheduledForDeletion[]= clone $accessoryRelatedByAccessory;
+ $accessoryRelatedByAccessory->setProductRelatedByAccessory(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collRewritings collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addRewritings()
+ */
+ public function clearRewritings()
+ {
+ $this->collRewritings = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collRewritings collection loaded partially.
+ */
+ public function resetPartialRewritings($v = true)
+ {
+ $this->collRewritingsPartial = $v;
+ }
+
+ /**
+ * Initializes the collRewritings collection.
+ *
+ * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initRewritings($overrideExisting = true)
+ {
+ if (null !== $this->collRewritings && !$overrideExisting) {
+ return;
+ }
+ $this->collRewritings = new ObjectCollection();
+ $this->collRewritings->setModel('\Thelia\Model\Rewriting');
+ }
+
+ /**
+ * Gets an array of ChildRewriting objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ * @throws PropelException
+ */
+ public function getRewritings($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ // return empty collection
+ $this->initRewritings();
+ } else {
+ $collRewritings = ChildRewritingQuery::create(null, $criteria)
+ ->filterByProduct($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collRewritingsPartial && count($collRewritings)) {
+ $this->initRewritings(false);
+
+ foreach ($collRewritings as $obj) {
+ if (false == $this->collRewritings->contains($obj)) {
+ $this->collRewritings->append($obj);
+ }
+ }
+
+ $this->collRewritingsPartial = true;
+ }
+
+ $collRewritings->getInternalIterator()->rewind();
+
+ return $collRewritings;
+ }
+
+ if ($partial && $this->collRewritings) {
+ foreach ($this->collRewritings as $obj) {
+ if ($obj->isNew()) {
+ $collRewritings[] = $obj;
+ }
+ }
+ }
+
+ $this->collRewritings = $collRewritings;
+ $this->collRewritingsPartial = false;
+ }
+ }
+
+ return $this->collRewritings;
+ }
+
+ /**
+ * Sets a collection of Rewriting objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $rewritings A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setRewritings(Collection $rewritings, ConnectionInterface $con = null)
+ {
+ $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings);
+
+
+ $this->rewritingsScheduledForDeletion = $rewritingsToDelete;
+
+ foreach ($rewritingsToDelete as $rewritingRemoved) {
+ $rewritingRemoved->setProduct(null);
+ }
+
+ $this->collRewritings = null;
+ foreach ($rewritings as $rewriting) {
+ $this->addRewriting($rewriting);
+ }
+
+ $this->collRewritings = $rewritings;
+ $this->collRewritingsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Rewriting objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Rewriting objects.
+ * @throws PropelException
+ */
+ public function countRewritings(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collRewritingsPartial && !$this->isNew();
+ if (null === $this->collRewritings || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collRewritings) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getRewritings());
+ }
+
+ $query = ChildRewritingQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProduct($this)
+ ->count($con);
+ }
+
+ return count($this->collRewritings);
+ }
+
+ /**
+ * Method called to associate a ChildRewriting object to this object
+ * through the ChildRewriting foreign key attribute.
+ *
+ * @param ChildRewriting $l ChildRewriting
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function addRewriting(ChildRewriting $l)
+ {
+ if ($this->collRewritings === null) {
+ $this->initRewritings();
+ $this->collRewritingsPartial = true;
+ }
+
+ if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddRewriting($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Rewriting $rewriting The rewriting object to add.
+ */
+ protected function doAddRewriting($rewriting)
+ {
+ $this->collRewritings[]= $rewriting;
+ $rewriting->setProduct($this);
+ }
+
+ /**
+ * @param Rewriting $rewriting The rewriting object to remove.
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeRewriting($rewriting)
+ {
+ if ($this->getRewritings()->contains($rewriting)) {
+ $this->collRewritings->remove($this->collRewritings->search($rewriting));
+ if (null === $this->rewritingsScheduledForDeletion) {
+ $this->rewritingsScheduledForDeletion = clone $this->collRewritings;
+ $this->rewritingsScheduledForDeletion->clear();
+ }
+ $this->rewritingsScheduledForDeletion[]= $rewriting;
+ $rewriting->setProduct(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related Rewritings 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ */
+ public function getRewritingsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildRewritingQuery::create(null, $criteria);
+ $query->joinWith('Category', $joinBehavior);
+
+ return $this->getRewritings($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related Rewritings 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ */
+ public function getRewritingsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildRewritingQuery::create(null, $criteria);
+ $query->joinWith('Folder', $joinBehavior);
+
+ return $this->getRewritings($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Product is new, it will return
+ * an empty collection; or if this Product has previously
+ * been saved, it will retrieve related Rewritings 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 Product.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildRewriting[] List of ChildRewriting objects
+ */
+ public function getRewritingsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildRewritingQuery::create(null, $criteria);
+ $query->joinWith('Content', $joinBehavior);
+
+ return $this->getRewritings($query, $con);
+ }
+
+ /**
+ * Clears out the collProductI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addProductI18ns()
+ */
+ public function clearProductI18ns()
+ {
+ $this->collProductI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collProductI18ns collection loaded partially.
+ */
+ public function resetPartialProductI18ns($v = true)
+ {
+ $this->collProductI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collProductI18ns collection.
+ *
+ * By default this just sets the collProductI18ns collection to an empty array (like clearcollProductI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initProductI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collProductI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collProductI18ns = new ObjectCollection();
+ $this->collProductI18ns->setModel('\Thelia\Model\ProductI18n');
+ }
+
+ /**
+ * Gets an array of ChildProductI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildProductI18n[] List of ChildProductI18n objects
+ * @throws PropelException
+ */
+ public function getProductI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collProductI18nsPartial && !$this->isNew();
+ if (null === $this->collProductI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProductI18ns) {
+ // return empty collection
+ $this->initProductI18ns();
+ } else {
+ $collProductI18ns = ChildProductI18nQuery::create(null, $criteria)
+ ->filterByProduct($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collProductI18nsPartial && count($collProductI18ns)) {
+ $this->initProductI18ns(false);
+
+ foreach ($collProductI18ns as $obj) {
+ if (false == $this->collProductI18ns->contains($obj)) {
+ $this->collProductI18ns->append($obj);
+ }
+ }
+
+ $this->collProductI18nsPartial = true;
+ }
+
+ $collProductI18ns->getInternalIterator()->rewind();
+
+ return $collProductI18ns;
+ }
+
+ if ($partial && $this->collProductI18ns) {
+ foreach ($this->collProductI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collProductI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collProductI18ns = $collProductI18ns;
+ $this->collProductI18nsPartial = false;
+ }
+ }
+
+ return $this->collProductI18ns;
+ }
+
+ /**
+ * Sets a collection of ProductI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $productI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setProductI18ns(Collection $productI18ns, ConnectionInterface $con = null)
+ {
+ $productI18nsToDelete = $this->getProductI18ns(new Criteria(), $con)->diff($productI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->productI18nsScheduledForDeletion = clone $productI18nsToDelete;
+
+ foreach ($productI18nsToDelete as $productI18nRemoved) {
+ $productI18nRemoved->setProduct(null);
+ }
+
+ $this->collProductI18ns = null;
+ foreach ($productI18ns as $productI18n) {
+ $this->addProductI18n($productI18n);
+ }
+
+ $this->collProductI18ns = $productI18ns;
+ $this->collProductI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ProductI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ProductI18n objects.
+ * @throws PropelException
+ */
+ public function countProductI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collProductI18nsPartial && !$this->isNew();
+ if (null === $this->collProductI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProductI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getProductI18ns());
+ }
+
+ $query = ChildProductI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProduct($this)
+ ->count($con);
+ }
+
+ return count($this->collProductI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildProductI18n object to this object
+ * through the ChildProductI18n foreign key attribute.
+ *
+ * @param ChildProductI18n $l ChildProductI18n
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function addProductI18n(ChildProductI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collProductI18ns === null) {
+ $this->initProductI18ns();
+ $this->collProductI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collProductI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddProductI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ProductI18n $productI18n The productI18n object to add.
+ */
+ protected function doAddProductI18n($productI18n)
+ {
+ $this->collProductI18ns[]= $productI18n;
+ $productI18n->setProduct($this);
+ }
+
+ /**
+ * @param ProductI18n $productI18n The productI18n object to remove.
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeProductI18n($productI18n)
+ {
+ if ($this->getProductI18ns()->contains($productI18n)) {
+ $this->collProductI18ns->remove($this->collProductI18ns->search($productI18n));
+ if (null === $this->productI18nsScheduledForDeletion) {
+ $this->productI18nsScheduledForDeletion = clone $this->collProductI18ns;
+ $this->productI18nsScheduledForDeletion->clear();
+ }
+ $this->productI18nsScheduledForDeletion[]= clone $productI18n;
+ $productI18n->setProduct(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collProductVersions collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addProductVersions()
+ */
+ public function clearProductVersions()
+ {
+ $this->collProductVersions = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collProductVersions collection loaded partially.
+ */
+ public function resetPartialProductVersions($v = true)
+ {
+ $this->collProductVersionsPartial = $v;
+ }
+
+ /**
+ * Initializes the collProductVersions collection.
+ *
+ * By default this just sets the collProductVersions collection to an empty array (like clearcollProductVersions());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initProductVersions($overrideExisting = true)
+ {
+ if (null !== $this->collProductVersions && !$overrideExisting) {
+ return;
+ }
+ $this->collProductVersions = new ObjectCollection();
+ $this->collProductVersions->setModel('\Thelia\Model\ProductVersion');
+ }
+
+ /**
+ * Gets an array of ChildProductVersion objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildProductVersion[] List of ChildProductVersion objects
+ * @throws PropelException
+ */
+ public function getProductVersions($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collProductVersionsPartial && !$this->isNew();
+ if (null === $this->collProductVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProductVersions) {
+ // return empty collection
+ $this->initProductVersions();
+ } else {
+ $collProductVersions = ChildProductVersionQuery::create(null, $criteria)
+ ->filterByProduct($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collProductVersionsPartial && count($collProductVersions)) {
+ $this->initProductVersions(false);
+
+ foreach ($collProductVersions as $obj) {
+ if (false == $this->collProductVersions->contains($obj)) {
+ $this->collProductVersions->append($obj);
+ }
+ }
+
+ $this->collProductVersionsPartial = true;
+ }
+
+ $collProductVersions->getInternalIterator()->rewind();
+
+ return $collProductVersions;
+ }
+
+ if ($partial && $this->collProductVersions) {
+ foreach ($this->collProductVersions as $obj) {
+ if ($obj->isNew()) {
+ $collProductVersions[] = $obj;
+ }
+ }
+ }
+
+ $this->collProductVersions = $collProductVersions;
+ $this->collProductVersionsPartial = false;
+ }
+ }
+
+ return $this->collProductVersions;
+ }
+
+ /**
+ * Sets a collection of ProductVersion objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $productVersions A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setProductVersions(Collection $productVersions, ConnectionInterface $con = null)
+ {
+ $productVersionsToDelete = $this->getProductVersions(new Criteria(), $con)->diff($productVersions);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->productVersionsScheduledForDeletion = clone $productVersionsToDelete;
+
+ foreach ($productVersionsToDelete as $productVersionRemoved) {
+ $productVersionRemoved->setProduct(null);
+ }
+
+ $this->collProductVersions = null;
+ foreach ($productVersions as $productVersion) {
+ $this->addProductVersion($productVersion);
+ }
+
+ $this->collProductVersions = $productVersions;
+ $this->collProductVersionsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ProductVersion objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ProductVersion objects.
+ * @throws PropelException
+ */
+ public function countProductVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collProductVersionsPartial && !$this->isNew();
+ if (null === $this->collProductVersions || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProductVersions) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getProductVersions());
+ }
+
+ $query = ChildProductVersionQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProduct($this)
+ ->count($con);
+ }
+
+ return count($this->collProductVersions);
+ }
+
+ /**
+ * Method called to associate a ChildProductVersion object to this object
+ * through the ChildProductVersion foreign key attribute.
+ *
+ * @param ChildProductVersion $l ChildProductVersion
+ * @return \Thelia\Model\Product The current object (for fluent API support)
+ */
+ public function addProductVersion(ChildProductVersion $l)
+ {
+ if ($this->collProductVersions === null) {
+ $this->initProductVersions();
+ $this->collProductVersionsPartial = true;
+ }
+
+ if (!in_array($l, $this->collProductVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddProductVersion($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ProductVersion $productVersion The productVersion object to add.
+ */
+ protected function doAddProductVersion($productVersion)
+ {
+ $this->collProductVersions[]= $productVersion;
+ $productVersion->setProduct($this);
+ }
+
+ /**
+ * @param ProductVersion $productVersion The productVersion object to remove.
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeProductVersion($productVersion)
+ {
+ if ($this->getProductVersions()->contains($productVersion)) {
+ $this->collProductVersions->remove($this->collProductVersions->search($productVersion));
+ if (null === $this->productVersionsScheduledForDeletion) {
+ $this->productVersionsScheduledForDeletion = clone $this->collProductVersions;
+ $this->productVersionsScheduledForDeletion->clear();
+ }
+ $this->productVersionsScheduledForDeletion[]= clone $productVersion;
+ $productVersion->setProduct(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collCategories collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addCategories()
+ */
+ public function clearCategories()
+ {
+ $this->collCategories = null; // important to set this to NULL since that means it is uninitialized
+ $this->collCategoriesPartial = null;
+ }
+
+ /**
+ * Initializes the collCategories collection.
+ *
+ * By default this just sets the collCategories collection to an empty collection (like clearCategories());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initCategories()
+ {
+ $this->collCategories = new ObjectCollection();
+ $this->collCategories->setModel('\Thelia\Model\Category');
+ }
+
+ /**
+ * Gets a collection of ChildCategory objects related by a many-to-many relationship
+ * to the current object by way of the product_category cross-reference table.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return ObjectCollection|ChildCategory[] List of ChildCategory objects
+ */
+ public function getCategories($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collCategories || null !== $criteria) {
+ if ($this->isNew() && null === $this->collCategories) {
+ // return empty collection
+ $this->initCategories();
+ } else {
+ $collCategories = ChildCategoryQuery::create(null, $criteria)
+ ->filterByProduct($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collCategories;
+ }
+ $this->collCategories = $collCategories;
+ }
+ }
+
+ return $this->collCategories;
+ }
+
+ /**
+ * Sets a collection of Category objects related by a many-to-many relationship
+ * to the current object by way of the product_category cross-reference table.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $categories A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setCategories(Collection $categories, ConnectionInterface $con = null)
+ {
+ $this->clearCategories();
+ $currentCategories = $this->getCategories();
+
+ $this->categoriesScheduledForDeletion = $currentCategories->diff($categories);
+
+ foreach ($categories as $category) {
+ if (!$currentCategories->contains($category)) {
+ $this->doAddCategory($category);
+ }
+ }
+
+ $this->collCategories = $categories;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildCategory objects related by a many-to-many relationship
+ * to the current object by way of the product_category cross-reference table.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param boolean $distinct Set to true to force count distinct
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return int the number of related ChildCategory objects
+ */
+ public function countCategories($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collCategories || null !== $criteria) {
+ if ($this->isNew() && null === $this->collCategories) {
+ return 0;
+ } else {
+ $query = ChildCategoryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProduct($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collCategories);
+ }
+ }
+
+ /**
+ * Associate a ChildCategory object to this object
+ * through the product_category cross reference table.
+ *
+ * @param ChildCategory $category The ChildProductCategory object to relate
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function addCategory(ChildCategory $category)
+ {
+ if ($this->collCategories === null) {
+ $this->initCategories();
+ }
+
+ if (!$this->collCategories->contains($category)) { // only add it if the **same** object is not already associated
+ $this->doAddCategory($category);
+ $this->collCategories[] = $category;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Category $category The category object to add.
+ */
+ protected function doAddCategory($category)
+ {
+ $productCategory = new ChildProductCategory();
+ $productCategory->setCategory($category);
+ $this->addProductCategory($productCategory);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$category->getProducts()->contains($this)) {
+ $foreignCollection = $category->getProducts();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildCategory object to this object
+ * through the product_category cross reference table.
+ *
+ * @param ChildCategory $category The ChildProductCategory object to relate
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeCategory(ChildCategory $category)
+ {
+ if ($this->getCategories()->contains($category)) {
+ $this->collCategories->remove($this->collCategories->search($category));
+
+ if (null === $this->categoriesScheduledForDeletion) {
+ $this->categoriesScheduledForDeletion = clone $this->collCategories;
+ $this->categoriesScheduledForDeletion->clear();
+ }
+
+ $this->categoriesScheduledForDeletion[] = $category;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collProductsRelatedByAccessory collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addProductsRelatedByAccessory()
+ */
+ public function clearProductsRelatedByAccessory()
+ {
+ $this->collProductsRelatedByAccessory = null; // important to set this to NULL since that means it is uninitialized
+ $this->collProductsRelatedByAccessoryPartial = null;
+ }
+
+ /**
+ * Initializes the collProductsRelatedByAccessory collection.
+ *
+ * By default this just sets the collProductsRelatedByAccessory collection to an empty collection (like clearProductsRelatedByAccessory());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initProductsRelatedByAccessory()
+ {
+ $this->collProductsRelatedByAccessory = new ObjectCollection();
+ $this->collProductsRelatedByAccessory->setModel('\Thelia\Model\Product');
+ }
+
+ /**
+ * Gets a collection of ChildProduct objects related by a many-to-many relationship
+ * to the current object by way of the accessory cross-reference table.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return ObjectCollection|ChildProduct[] List of ChildProduct objects
+ */
+ public function getProductsRelatedByAccessory($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collProductsRelatedByAccessory || null !== $criteria) {
+ if ($this->isNew() && null === $this->collProductsRelatedByAccessory) {
+ // return empty collection
+ $this->initProductsRelatedByAccessory();
+ } else {
+ $collProductsRelatedByAccessory = ChildProductQuery::create(null, $criteria)
+ ->filterByProductRelatedByProductId($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collProductsRelatedByAccessory;
+ }
+ $this->collProductsRelatedByAccessory = $collProductsRelatedByAccessory;
+ }
+ }
+
+ return $this->collProductsRelatedByAccessory;
+ }
+
+ /**
+ * Sets a collection of Product objects related by a many-to-many relationship
+ * to the current object by way of the accessory cross-reference table.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $productsRelatedByAccessory A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setProductsRelatedByAccessory(Collection $productsRelatedByAccessory, ConnectionInterface $con = null)
+ {
+ $this->clearProductsRelatedByAccessory();
+ $currentProductsRelatedByAccessory = $this->getProductsRelatedByAccessory();
+
+ $this->productsRelatedByAccessoryScheduledForDeletion = $currentProductsRelatedByAccessory->diff($productsRelatedByAccessory);
+
+ foreach ($productsRelatedByAccessory as $productRelatedByAccessory) {
+ if (!$currentProductsRelatedByAccessory->contains($productRelatedByAccessory)) {
+ $this->doAddProductRelatedByAccessory($productRelatedByAccessory);
+ }
+ }
+
+ $this->collProductsRelatedByAccessory = $productsRelatedByAccessory;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildProduct objects related by a many-to-many relationship
+ * to the current object by way of the accessory cross-reference table.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param boolean $distinct Set to true to force count distinct
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return int the number of related ChildProduct objects
+ */
+ public function countProductsRelatedByAccessory($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collProductsRelatedByAccessory || null !== $criteria) {
+ if ($this->isNew() && null === $this->collProductsRelatedByAccessory) {
+ return 0;
+ } else {
+ $query = ChildProductQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProductRelatedByProductId($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collProductsRelatedByAccessory);
+ }
+ }
+
+ /**
+ * Associate a ChildProduct object to this object
+ * through the accessory cross reference table.
+ *
+ * @param ChildProduct $product The ChildAccessory object to relate
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function addProductRelatedByAccessory(ChildProduct $product)
+ {
+ if ($this->collProductsRelatedByAccessory === null) {
+ $this->initProductsRelatedByAccessory();
+ }
+
+ if (!$this->collProductsRelatedByAccessory->contains($product)) { // only add it if the **same** object is not already associated
+ $this->doAddProductRelatedByAccessory($product);
+ $this->collProductsRelatedByAccessory[] = $product;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ProductRelatedByAccessory $productRelatedByAccessory The productRelatedByAccessory object to add.
+ */
+ protected function doAddProductRelatedByAccessory($productRelatedByAccessory)
+ {
+ $accessory = new ChildAccessory();
+ $accessory->setProductRelatedByAccessory($productRelatedByAccessory);
+ $this->addAccessoryRelatedByProductId($accessory);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$productRelatedByAccessory->getProductsRelatedByProductId()->contains($this)) {
+ $foreignCollection = $productRelatedByAccessory->getProductsRelatedByProductId();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildProduct object to this object
+ * through the accessory cross reference table.
+ *
+ * @param ChildProduct $product The ChildAccessory object to relate
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeProductRelatedByAccessory(ChildProduct $product)
+ {
+ if ($this->getProductsRelatedByAccessory()->contains($product)) {
+ $this->collProductsRelatedByAccessory->remove($this->collProductsRelatedByAccessory->search($product));
+
+ if (null === $this->productsRelatedByAccessoryScheduledForDeletion) {
+ $this->productsRelatedByAccessoryScheduledForDeletion = clone $this->collProductsRelatedByAccessory;
+ $this->productsRelatedByAccessoryScheduledForDeletion->clear();
+ }
+
+ $this->productsRelatedByAccessoryScheduledForDeletion[] = $product;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collProductsRelatedByProductId collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addProductsRelatedByProductId()
+ */
+ public function clearProductsRelatedByProductId()
+ {
+ $this->collProductsRelatedByProductId = null; // important to set this to NULL since that means it is uninitialized
+ $this->collProductsRelatedByProductIdPartial = null;
+ }
+
+ /**
+ * Initializes the collProductsRelatedByProductId collection.
+ *
+ * By default this just sets the collProductsRelatedByProductId collection to an empty collection (like clearProductsRelatedByProductId());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initProductsRelatedByProductId()
+ {
+ $this->collProductsRelatedByProductId = new ObjectCollection();
+ $this->collProductsRelatedByProductId->setModel('\Thelia\Model\Product');
+ }
+
+ /**
+ * Gets a collection of ChildProduct objects related by a many-to-many relationship
+ * to the current object by way of the accessory cross-reference table.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildProduct is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return ObjectCollection|ChildProduct[] List of ChildProduct objects
+ */
+ public function getProductsRelatedByProductId($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collProductsRelatedByProductId || null !== $criteria) {
+ if ($this->isNew() && null === $this->collProductsRelatedByProductId) {
+ // return empty collection
+ $this->initProductsRelatedByProductId();
+ } else {
+ $collProductsRelatedByProductId = ChildProductQuery::create(null, $criteria)
+ ->filterByProductRelatedByAccessory($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collProductsRelatedByProductId;
+ }
+ $this->collProductsRelatedByProductId = $collProductsRelatedByProductId;
+ }
+ }
+
+ return $this->collProductsRelatedByProductId;
+ }
+
+ /**
+ * Sets a collection of Product objects related by a many-to-many relationship
+ * to the current object by way of the accessory cross-reference table.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $productsRelatedByProductId A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setProductsRelatedByProductId(Collection $productsRelatedByProductId, ConnectionInterface $con = null)
+ {
+ $this->clearProductsRelatedByProductId();
+ $currentProductsRelatedByProductId = $this->getProductsRelatedByProductId();
+
+ $this->productsRelatedByProductIdScheduledForDeletion = $currentProductsRelatedByProductId->diff($productsRelatedByProductId);
+
+ foreach ($productsRelatedByProductId as $productRelatedByProductId) {
+ if (!$currentProductsRelatedByProductId->contains($productRelatedByProductId)) {
+ $this->doAddProductRelatedByProductId($productRelatedByProductId);
+ }
+ }
+
+ $this->collProductsRelatedByProductId = $productsRelatedByProductId;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildProduct objects related by a many-to-many relationship
+ * to the current object by way of the accessory cross-reference table.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param boolean $distinct Set to true to force count distinct
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return int the number of related ChildProduct objects
+ */
+ public function countProductsRelatedByProductId($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collProductsRelatedByProductId || null !== $criteria) {
+ if ($this->isNew() && null === $this->collProductsRelatedByProductId) {
+ return 0;
+ } else {
+ $query = ChildProductQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByProductRelatedByAccessory($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collProductsRelatedByProductId);
+ }
+ }
+
+ /**
+ * Associate a ChildProduct object to this object
+ * through the accessory cross reference table.
+ *
+ * @param ChildProduct $product The ChildAccessory object to relate
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function addProductRelatedByProductId(ChildProduct $product)
+ {
+ if ($this->collProductsRelatedByProductId === null) {
+ $this->initProductsRelatedByProductId();
+ }
+
+ if (!$this->collProductsRelatedByProductId->contains($product)) { // only add it if the **same** object is not already associated
+ $this->doAddProductRelatedByProductId($product);
+ $this->collProductsRelatedByProductId[] = $product;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ProductRelatedByProductId $productRelatedByProductId The productRelatedByProductId object to add.
+ */
+ protected function doAddProductRelatedByProductId($productRelatedByProductId)
+ {
+ $accessory = new ChildAccessory();
+ $accessory->setProductRelatedByProductId($productRelatedByProductId);
+ $this->addAccessoryRelatedByAccessory($accessory);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$productRelatedByProductId->getProductsRelatedByAccessory()->contains($this)) {
+ $foreignCollection = $productRelatedByProductId->getProductsRelatedByAccessory();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildProduct object to this object
+ * through the accessory cross reference table.
+ *
+ * @param ChildProduct $product The ChildAccessory object to relate
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeProductRelatedByProductId(ChildProduct $product)
+ {
+ if ($this->getProductsRelatedByProductId()->contains($product)) {
+ $this->collProductsRelatedByProductId->remove($this->collProductsRelatedByProductId->search($product));
+
+ if (null === $this->productsRelatedByProductIdScheduledForDeletion) {
+ $this->productsRelatedByProductIdScheduledForDeletion = clone $this->collProductsRelatedByProductId;
+ $this->productsRelatedByProductIdScheduledForDeletion->clear();
+ }
+
+ $this->productsRelatedByProductIdScheduledForDeletion[] = $product;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->tax_rule_id = null;
+ $this->ref = null;
+ $this->price = null;
+ $this->price2 = null;
+ $this->ecotax = null;
+ $this->newness = null;
+ $this->promo = null;
+ $this->quantity = null;
+ $this->visible = null;
+ $this->weight = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collProductCategories) {
+ foreach ($this->collProductCategories as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collFeatureProds) {
+ foreach ($this->collFeatureProds as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collStocks) {
+ foreach ($this->collStocks as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collContentAssocs) {
+ foreach ($this->collContentAssocs as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collImages) {
+ foreach ($this->collImages as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collDocuments) {
+ foreach ($this->collDocuments as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAccessoriesRelatedByProductId) {
+ foreach ($this->collAccessoriesRelatedByProductId as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collAccessoriesRelatedByAccessory) {
+ foreach ($this->collAccessoriesRelatedByAccessory as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collRewritings) {
+ foreach ($this->collRewritings as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collProductI18ns) {
+ foreach ($this->collProductI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collProductVersions) {
+ foreach ($this->collProductVersions as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collCategories) {
+ foreach ($this->collCategories as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collProductsRelatedByAccessory) {
+ foreach ($this->collProductsRelatedByAccessory as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collProductsRelatedByProductId) {
+ foreach ($this->collProductsRelatedByProductId as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collProductCategories instanceof Collection) {
+ $this->collProductCategories->clearIterator();
+ }
+ $this->collProductCategories = null;
+ if ($this->collFeatureProds instanceof Collection) {
+ $this->collFeatureProds->clearIterator();
+ }
+ $this->collFeatureProds = null;
+ if ($this->collStocks instanceof Collection) {
+ $this->collStocks->clearIterator();
+ }
+ $this->collStocks = null;
+ if ($this->collContentAssocs instanceof Collection) {
+ $this->collContentAssocs->clearIterator();
+ }
+ $this->collContentAssocs = null;
+ if ($this->collImages instanceof Collection) {
+ $this->collImages->clearIterator();
+ }
+ $this->collImages = null;
+ if ($this->collDocuments instanceof Collection) {
+ $this->collDocuments->clearIterator();
+ }
+ $this->collDocuments = null;
+ if ($this->collAccessoriesRelatedByProductId instanceof Collection) {
+ $this->collAccessoriesRelatedByProductId->clearIterator();
+ }
+ $this->collAccessoriesRelatedByProductId = null;
+ if ($this->collAccessoriesRelatedByAccessory instanceof Collection) {
+ $this->collAccessoriesRelatedByAccessory->clearIterator();
+ }
+ $this->collAccessoriesRelatedByAccessory = null;
+ if ($this->collRewritings instanceof Collection) {
+ $this->collRewritings->clearIterator();
+ }
+ $this->collRewritings = null;
+ if ($this->collProductI18ns instanceof Collection) {
+ $this->collProductI18ns->clearIterator();
+ }
+ $this->collProductI18ns = null;
+ if ($this->collProductVersions instanceof Collection) {
+ $this->collProductVersions->clearIterator();
+ }
+ $this->collProductVersions = null;
+ if ($this->collCategories instanceof Collection) {
+ $this->collCategories->clearIterator();
+ }
+ $this->collCategories = null;
+ if ($this->collProductsRelatedByAccessory instanceof Collection) {
+ $this->collProductsRelatedByAccessory->clearIterator();
+ }
+ $this->collProductsRelatedByAccessory = null;
+ if ($this->collProductsRelatedByProductId instanceof Collection) {
+ $this->collProductsRelatedByProductId->clearIterator();
+ }
+ $this->collProductsRelatedByProductId = null;
+ $this->aTaxRule = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ProductTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = ProductTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildProductI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collProductI18ns) {
+ foreach ($this->collProductI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildProductI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildProductI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addProductI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildProductI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collProductI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collProductI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildProductI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ProductI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ProductI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ProductI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ProductI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ // versionable behavior
+
+ /**
+ * Enforce a new Version of this object upon next save.
+ *
+ * @return \Thelia\Model\Product
+ */
+ public function enforceVersioning()
+ {
+ $this->enforceVersion = true;
+
+ return $this;
+ }
+
+ /**
+ * Checks whether the current state must be recorded as a version
+ *
+ * @return boolean
+ */
+ public function isVersioningNecessary($con = null)
+ {
+ if ($this->alreadyInSave) {
+ return false;
+ }
+
+ if ($this->enforceVersion) {
+ return true;
+ }
+
+ if (ChildProductQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Creates a version of the current object and saves it.
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ChildProductVersion A version object
+ */
+ public function addVersion($con = null)
+ {
+ $this->enforceVersion = false;
+
+ $version = new ChildProductVersion();
+ $version->setId($this->getId());
+ $version->setTaxRuleId($this->getTaxRuleId());
+ $version->setRef($this->getRef());
+ $version->setPrice($this->getPrice());
+ $version->setPrice2($this->getPrice2());
+ $version->setEcotax($this->getEcotax());
+ $version->setNewness($this->getNewness());
+ $version->setPromo($this->getPromo());
+ $version->setQuantity($this->getQuantity());
+ $version->setVisible($this->getVisible());
+ $version->setWeight($this->getWeight());
+ $version->setPosition($this->getPosition());
+ $version->setCreatedAt($this->getCreatedAt());
+ $version->setUpdatedAt($this->getUpdatedAt());
+ $version->setVersion($this->getVersion());
+ $version->setVersionCreatedAt($this->getVersionCreatedAt());
+ $version->setVersionCreatedBy($this->getVersionCreatedBy());
+ $version->setProduct($this);
+ $version->save($con);
+
+ return $version;
+ }
+
+ /**
+ * Sets the properties of the current object to the value they had at a specific version
+ *
+ * @param integer $versionNumber The version number to read
+ * @param ConnectionInterface $con The connection to use
+ *
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function toVersion($versionNumber, $con = null)
+ {
+ $version = $this->getOneVersion($versionNumber, $con);
+ if (!$version) {
+ throw new PropelException(sprintf('No ChildProduct object found with version %d', $version));
+ }
+ $this->populateFromVersion($version, $con);
+
+ return $this;
+ }
+
+ /**
+ * Sets the properties of the current object to the value they had at a specific version
+ *
+ * @param ChildProductVersion $version The version object to use
+ * @param ConnectionInterface $con the connection to use
+ * @param array $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects.
+ *
+ * @return ChildProduct The current object (for fluent API support)
+ */
+ public function populateFromVersion($version, $con = null, &$loadedObjects = array())
+ {
+ $loadedObjects['ChildProduct'][$version->getId()][$version->getVersion()] = $this;
+ $this->setId($version->getId());
+ $this->setTaxRuleId($version->getTaxRuleId());
+ $this->setRef($version->getRef());
+ $this->setPrice($version->getPrice());
+ $this->setPrice2($version->getPrice2());
+ $this->setEcotax($version->getEcotax());
+ $this->setNewness($version->getNewness());
+ $this->setPromo($version->getPromo());
+ $this->setQuantity($version->getQuantity());
+ $this->setVisible($version->getVisible());
+ $this->setWeight($version->getWeight());
+ $this->setPosition($version->getPosition());
+ $this->setCreatedAt($version->getCreatedAt());
+ $this->setUpdatedAt($version->getUpdatedAt());
+ $this->setVersion($version->getVersion());
+ $this->setVersionCreatedAt($version->getVersionCreatedAt());
+ $this->setVersionCreatedBy($version->getVersionCreatedBy());
+
+ return $this;
+ }
+
+ /**
+ * Gets the latest persisted version number for the current object
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return integer
+ */
+ public function getLastVersionNumber($con = null)
+ {
+ $v = ChildProductVersionQuery::create()
+ ->filterByProduct($this)
+ ->orderByVersion('desc')
+ ->findOne($con);
+ if (!$v) {
+ return 0;
+ }
+
+ return $v->getVersion();
+ }
+
+ /**
+ * Checks whether the current object is the latest one
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return Boolean
+ */
+ public function isLastVersion($con = null)
+ {
+ return $this->getLastVersionNumber($con) == $this->getVersion();
+ }
+
+ /**
+ * Retrieves a version object for this entity and a version number
+ *
+ * @param integer $versionNumber The version number to read
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ChildProductVersion A version object
+ */
+ public function getOneVersion($versionNumber, $con = null)
+ {
+ return ChildProductVersionQuery::create()
+ ->filterByProduct($this)
+ ->filterByVersion($versionNumber)
+ ->findOne($con);
+ }
+
+ /**
+ * Gets all the versions of this object, in incremental order
+ *
+ * @param ConnectionInterface $con the connection to use
+ *
+ * @return ObjectCollection A list of ChildProductVersion objects
+ */
+ public function getAllVersions($con = null)
+ {
+ $criteria = new Criteria();
+ $criteria->addAscendingOrderByColumn(ProductVersionTableMap::VERSION);
+
+ return $this->getProductVersions($criteria, $con);
+ }
+
+ /**
+ * Compares the current object with another of its version.
+ *
+ * print_r($book->compareVersion(1));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $versionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param ConnectionInterface $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersion($versionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->toArray();
+ $toVersion = $this->getOneVersion($versionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Compares two versions of the current object.
+ *
+ * print_r($book->compareVersions(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param integer $fromVersionNumber
+ * @param integer $toVersionNumber
+ * @param string $keys Main key used for the result diff (versions|columns)
+ * @param ConnectionInterface $con the connection to use
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ public function compareVersions($fromVersionNumber, $toVersionNumber, $keys = 'columns', $con = null, $ignoredColumns = array())
+ {
+ $fromVersion = $this->getOneVersion($fromVersionNumber, $con)->toArray();
+ $toVersion = $this->getOneVersion($toVersionNumber, $con)->toArray();
+
+ return $this->computeDiff($fromVersion, $toVersion, $keys, $ignoredColumns);
+ }
+
+ /**
+ * Computes the diff between two versions.
+ *
+ * print_r($book->computeDiff(1, 2));
+ * => array(
+ * '1' => array('Title' => 'Book title at version 1'),
+ * '2' => array('Title' => 'Book title at version 2')
+ * );
+ *
+ *
+ * @param array $fromVersion An array representing the original version.
+ * @param array $toVersion An array representing the destination version.
+ * @param string $keys Main key used for the result diff (versions|columns).
+ * @param array $ignoredColumns The columns to exclude from the diff.
+ *
+ * @return array A list of differences
+ */
+ protected function computeDiff($fromVersion, $toVersion, $keys = 'columns', $ignoredColumns = array())
+ {
+ $fromVersionNumber = $fromVersion['Version'];
+ $toVersionNumber = $toVersion['Version'];
+ $ignoredColumns = array_merge(array(
+ 'Version',
+ 'VersionCreatedAt',
+ 'VersionCreatedBy',
+ ), $ignoredColumns);
+ $diff = array();
+ foreach ($fromVersion as $key => $value) {
+ if (in_array($key, $ignoredColumns)) {
+ continue;
+ }
+ if ($toVersion[$key] != $value) {
+ switch ($keys) {
+ case 'versions':
+ $diff[$fromVersionNumber][$key] = $value;
+ $diff[$toVersionNumber][$key] = $toVersion[$key];
+ break;
+ default:
+ $diff[$key] = array(
+ $fromVersionNumber => $value,
+ $toVersionNumber => $toVersion[$key],
+ );
+ break;
+ }
+ }
+ }
+
+ return $diff;
+ }
+ /**
+ * retrieve the last $number versions.
+ *
+ * @param Integer $number the number of record to return.
+ * @return PropelCollection|array \Thelia\Model\ProductVersion[] List of \Thelia\Model\ProductVersion objects
+ */
+ public function getLastVersions($number = 10, $criteria = null, $con = null)
+ {
+ $criteria = ChildProductVersionQuery::create(null, $criteria);
+ $criteria->addDescendingOrderByColumn(ProductVersionTableMap::VERSION);
+ $criteria->limit($number);
+
+ return $this->getProductVersions($criteria, $con);
+ }
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ProductCategory.php b/core/lib/Thelia/Model/Base/ProductCategory.php
new file mode 100644
index 000000000..74affb0c0
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ProductCategory.php
@@ -0,0 +1,1433 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another ProductCategory instance. If
+ * obj is an instance of ProductCategory, delegates to
+ * equals(ProductCategory). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return ProductCategory The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return ProductCategory The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+
+ return $this->category_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ProductCategory The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = ProductCategoryTableMap::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ProductCategory The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = ProductCategoryTableMap::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\ProductCategory The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = ProductCategoryTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\ProductCategory The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = ProductCategoryTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductCategoryTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->product_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductCategoryTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->category_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductCategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductCategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = ProductCategoryTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\ProductCategory object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ProductCategoryTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildProductCategoryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aProduct = null;
+ $this->aCategory = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see ProductCategory::setDeleted()
+ * @see ProductCategory::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductCategoryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildProductCategoryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductCategoryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(ProductCategoryTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(ProductCategoryTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(ProductCategoryTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ProductCategoryTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ProductCategoryTableMap::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'PRODUCT_ID';
+ }
+ if ($this->isColumnModified(ProductCategoryTableMap::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CATEGORY_ID';
+ }
+ if ($this->isColumnModified(ProductCategoryTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(ProductCategoryTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO product_category (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'PRODUCT_ID':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case 'CATEGORY_ID':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ProductCategoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getProductId();
+ break;
+ case 1:
+ return $this->getCategoryId();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ProductCategory'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ProductCategory'][serialize($this->getPrimaryKey())] = true;
+ $keys = ProductCategoryTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getProductId(),
+ $keys[1] => $this->getCategoryId(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ProductCategoryTableMap::translateFieldName($name, $type, TableMap::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->setProductId($value);
+ break;
+ case 1:
+ $this->setCategoryId($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ProductCategoryTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setProductId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * 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(ProductCategoryTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ProductCategoryTableMap::PRODUCT_ID)) $criteria->add(ProductCategoryTableMap::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(ProductCategoryTableMap::CATEGORY_ID)) $criteria->add(ProductCategoryTableMap::CATEGORY_ID, $this->category_id);
+ if ($this->isColumnModified(ProductCategoryTableMap::CREATED_AT)) $criteria->add(ProductCategoryTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ProductCategoryTableMap::UPDATED_AT)) $criteria->add(ProductCategoryTableMap::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(ProductCategoryTableMap::DATABASE_NAME);
+ $criteria->add(ProductCategoryTableMap::PRODUCT_ID, $this->product_id);
+ $criteria->add(ProductCategoryTableMap::CATEGORY_ID, $this->category_id);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getProductId();
+ $pks[1] = $this->getCategoryId();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setProductId($keys[0]);
+ $this->setCategoryId($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getProductId()) && (null === $this->getCategoryId());
+ }
+
+ /**
+ * 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 \Thelia\Model\ProductCategory (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setCategoryId($this->getCategoryId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\ProductCategory 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildProduct object.
+ *
+ * @param ChildProduct $v
+ * @return \Thelia\Model\ProductCategory The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(ChildProduct $v = null)
+ {
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
+ }
+
+ $this->aProduct = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildProduct object, it will not be re-added.
+ if ($v !== null) {
+ $v->addProductCategory($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildProduct object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildProduct The associated ChildProduct object.
+ * @throws PropelException
+ */
+ public function getProduct(ConnectionInterface $con = null)
+ {
+ if ($this->aProduct === null && ($this->product_id !== null)) {
+ $this->aProduct = ChildProductQuery::create()->findPk($this->product_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aProduct->addProductCategories($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCategory object.
+ *
+ * @param ChildCategory $v
+ * @return \Thelia\Model\ProductCategory The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCategory(ChildCategory $v = null)
+ {
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
+ }
+
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCategory object, it will not be re-added.
+ if ($v !== null) {
+ $v->addProductCategory($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCategory object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCategory The associated ChildCategory object.
+ * @throws PropelException
+ */
+ public function getCategory(ConnectionInterface $con = null)
+ {
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCategory->addProductCategories($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->product_id = null;
+ $this->category_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aProduct = null;
+ $this->aCategory = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ProductCategoryTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildProductCategory The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = ProductCategoryTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ProductCategoryQuery.php b/core/lib/Thelia/Model/Base/ProductCategoryQuery.php
new file mode 100644
index 000000000..fd40e93c7
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ProductCategoryQuery.php
@@ -0,0 +1,728 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$product_id, $category_id] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildProductCategory|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ProductCategoryTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ProductCategoryTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildProductCategory A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT PRODUCT_ID, CATEGORY_ID, CREATED_AT, UPDATED_AT FROM product_category WHERE PRODUCT_ID = :p0 AND CATEGORY_ID = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildProductCategory();
+ $obj->hydrate($row);
+ ProductCategoryTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildProductCategory|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(ProductCategoryTableMap::PRODUCT_ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(ProductCategoryTableMap::CATEGORY_ID, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(ProductCategoryTableMap::PRODUCT_ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(ProductCategoryTableMap::CATEGORY_ID, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(ProductCategoryTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(ProductCategoryTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductCategoryTableMap::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId)) {
+ $useMinMax = false;
+ if (isset($categoryId['min'])) {
+ $this->addUsingAlias(ProductCategoryTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($categoryId['max'])) {
+ $this->addUsingAlias(ProductCategoryTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductCategoryTableMap::CATEGORY_ID, $categoryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ProductCategoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ProductCategoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductCategoryTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ProductCategoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ProductCategoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductCategoryTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Product object
+ *
+ * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function filterByProduct($product, $comparison = null)
+ {
+ if ($product instanceof \Thelia\Model\Product) {
+ return $this
+ ->addUsingAlias(ProductCategoryTableMap::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ProductCategoryTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Product relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Product');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Product');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Product relation Product object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
+ */
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Category object
+ *
+ * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function filterByCategory($category, $comparison = null)
+ {
+ if ($category instanceof \Thelia\Model\Category) {
+ return $this
+ ->addUsingAlias(ProductCategoryTableMap::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ProductCategoryTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Category relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Category');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Category');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Category relation Category object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildProductCategory $productCategory Object to remove from the list of results
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function prune($productCategory = null)
+ {
+ if ($productCategory) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(ProductCategoryTableMap::PRODUCT_ID), $productCategory->getProductId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(ProductCategoryTableMap::CATEGORY_ID), $productCategory->getCategoryId(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the product_category table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductCategoryTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ProductCategoryTableMap::clearInstancePool();
+ ProductCategoryTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildProductCategory or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildProductCategory object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductCategoryTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductCategoryTableMap::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->beginTransaction();
+
+
+ ProductCategoryTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ProductCategoryTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ProductCategoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ProductCategoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ProductCategoryTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ProductCategoryTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ProductCategoryTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildProductCategoryQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ProductCategoryTableMap::CREATED_AT);
+ }
+
+} // ProductCategoryQuery
diff --git a/core/lib/Thelia/Model/Base/ProductI18n.php b/core/lib/Thelia/Model/Base/ProductI18n.php
new file mode 100644
index 000000000..7b6e65976
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ProductI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\ProductI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another ProductI18n instance. If
+ * obj is an instance of ProductI18n, delegates to
+ * equals(ProductI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return ProductI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return ProductI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ProductI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ProductI18nTableMap::ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ProductI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = ProductI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ProductI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = ProductI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ProductI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = ProductI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ProductI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = ProductI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ProductI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = ProductI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = ProductI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\ProductI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aProduct !== null && $this->id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ProductI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildProductI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aProduct = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see ProductI18n::setDeleted()
+ * @see ProductI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildProductI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ProductI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ProductI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ProductI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(ProductI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(ProductI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(ProductI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(ProductI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO product_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ProductI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ProductI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ProductI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = ProductI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ProductI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ProductI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(ProductI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ProductI18nTableMap::ID)) $criteria->add(ProductI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(ProductI18nTableMap::LOCALE)) $criteria->add(ProductI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(ProductI18nTableMap::TITLE)) $criteria->add(ProductI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(ProductI18nTableMap::DESCRIPTION)) $criteria->add(ProductI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(ProductI18nTableMap::CHAPO)) $criteria->add(ProductI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(ProductI18nTableMap::POSTSCRIPTUM)) $criteria->add(ProductI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(ProductI18nTableMap::DATABASE_NAME);
+ $criteria->add(ProductI18nTableMap::ID, $this->id);
+ $criteria->add(ProductI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\ProductI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\ProductI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildProduct object.
+ *
+ * @param ChildProduct $v
+ * @return \Thelia\Model\ProductI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(ChildProduct $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aProduct = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildProduct object, it will not be re-added.
+ if ($v !== null) {
+ $v->addProductI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildProduct object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildProduct The associated ChildProduct object.
+ * @throws PropelException
+ */
+ public function getProduct(ConnectionInterface $con = null)
+ {
+ if ($this->aProduct === null && ($this->id !== null)) {
+ $this->aProduct = ChildProductQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aProduct->addProductI18ns($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aProduct = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ProductI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ProductI18nQuery.php b/core/lib/Thelia/Model/Base/ProductI18nQuery.php
new file mode 100644
index 000000000..d64c95892
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ProductI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildProductI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ProductI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ProductI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildProductI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM product_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildProductI18n();
+ $obj->hydrate($row);
+ ProductI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildProductI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildProductI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(ProductI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(ProductI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildProductI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(ProductI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(ProductI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ProductI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ProductI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Product object
+ *
+ * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductI18nQuery The current query, for fluid interface
+ */
+ public function filterByProduct($product, $comparison = null)
+ {
+ if ($product instanceof \Thelia\Model\Product) {
+ return $this
+ ->addUsingAlias(ProductI18nTableMap::ID, $product->getId(), $comparison);
+ } elseif ($product instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ProductI18nTableMap::ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Product relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductI18nQuery The current query, for fluid interface
+ */
+ public function joinProduct($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Product');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Product');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Product relation Product object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
+ */
+ public function useProductQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildProductI18n $productI18n Object to remove from the list of results
+ *
+ * @return ChildProductI18nQuery The current query, for fluid interface
+ */
+ public function prune($productI18n = null)
+ {
+ if ($productI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(ProductI18nTableMap::ID), $productI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(ProductI18nTableMap::LOCALE), $productI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the product_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ProductI18nTableMap::clearInstancePool();
+ ProductI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildProductI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildProductI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductI18nTableMap::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->beginTransaction();
+
+
+ ProductI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ProductI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // ProductI18nQuery
diff --git a/core/lib/Thelia/Model/Base/ProductQuery.php b/core/lib/Thelia/Model/Base/ProductQuery.php
new file mode 100644
index 000000000..c4f2ce371
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ProductQuery.php
@@ -0,0 +1,2187 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildProduct|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ProductTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ProductTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildProduct A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, TAX_RULE_ID, REF, PRICE, PRICE2, ECOTAX, NEWNESS, PROMO, QUANTITY, VISIBLE, WEIGHT, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM product WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildProduct();
+ $obj->hydrate($row);
+ ProductTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildProduct|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ProductTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ProductTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ProductTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ProductTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the tax_rule_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByTaxRuleId(1234); // WHERE tax_rule_id = 1234
+ * $query->filterByTaxRuleId(array(12, 34)); // WHERE tax_rule_id IN (12, 34)
+ * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12
+ *
+ *
+ * @see filterByTaxRule()
+ *
+ * @param mixed $taxRuleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByTaxRuleId($taxRuleId = null, $comparison = null)
+ {
+ if (is_array($taxRuleId)) {
+ $useMinMax = false;
+ if (isset($taxRuleId['min'])) {
+ $this->addUsingAlias(ProductTableMap::TAX_RULE_ID, $taxRuleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($taxRuleId['max'])) {
+ $this->addUsingAlias(ProductTableMap::TAX_RULE_ID, $taxRuleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::TAX_RULE_ID, $taxRuleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
+ * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $ref The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByRef($ref = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($ref)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $ref)) {
+ $ref = str_replace('*', '%', $ref);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::REF, $ref, $comparison);
+ }
+
+ /**
+ * Filter the query on the price column
+ *
+ * Example usage:
+ *
+ * $query->filterByPrice(1234); // WHERE price = 1234
+ * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34)
+ * $query->filterByPrice(array('min' => 12)); // WHERE price > 12
+ *
+ *
+ * @param mixed $price The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByPrice($price = null, $comparison = null)
+ {
+ if (is_array($price)) {
+ $useMinMax = false;
+ if (isset($price['min'])) {
+ $this->addUsingAlias(ProductTableMap::PRICE, $price['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($price['max'])) {
+ $this->addUsingAlias(ProductTableMap::PRICE, $price['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::PRICE, $price, $comparison);
+ }
+
+ /**
+ * Filter the query on the price2 column
+ *
+ * Example usage:
+ *
+ * $query->filterByPrice2(1234); // WHERE price2 = 1234
+ * $query->filterByPrice2(array(12, 34)); // WHERE price2 IN (12, 34)
+ * $query->filterByPrice2(array('min' => 12)); // WHERE price2 > 12
+ *
+ *
+ * @param mixed $price2 The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByPrice2($price2 = null, $comparison = null)
+ {
+ if (is_array($price2)) {
+ $useMinMax = false;
+ if (isset($price2['min'])) {
+ $this->addUsingAlias(ProductTableMap::PRICE2, $price2['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($price2['max'])) {
+ $this->addUsingAlias(ProductTableMap::PRICE2, $price2['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::PRICE2, $price2, $comparison);
+ }
+
+ /**
+ * Filter the query on the ecotax column
+ *
+ * Example usage:
+ *
+ * $query->filterByEcotax(1234); // WHERE ecotax = 1234
+ * $query->filterByEcotax(array(12, 34)); // WHERE ecotax IN (12, 34)
+ * $query->filterByEcotax(array('min' => 12)); // WHERE ecotax > 12
+ *
+ *
+ * @param mixed $ecotax The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByEcotax($ecotax = null, $comparison = null)
+ {
+ if (is_array($ecotax)) {
+ $useMinMax = false;
+ if (isset($ecotax['min'])) {
+ $this->addUsingAlias(ProductTableMap::ECOTAX, $ecotax['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($ecotax['max'])) {
+ $this->addUsingAlias(ProductTableMap::ECOTAX, $ecotax['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::ECOTAX, $ecotax, $comparison);
+ }
+
+ /**
+ * Filter the query on the newness column
+ *
+ * Example usage:
+ *
+ * $query->filterByNewness(1234); // WHERE newness = 1234
+ * $query->filterByNewness(array(12, 34)); // WHERE newness IN (12, 34)
+ * $query->filterByNewness(array('min' => 12)); // WHERE newness > 12
+ *
+ *
+ * @param mixed $newness The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByNewness($newness = null, $comparison = null)
+ {
+ if (is_array($newness)) {
+ $useMinMax = false;
+ if (isset($newness['min'])) {
+ $this->addUsingAlias(ProductTableMap::NEWNESS, $newness['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($newness['max'])) {
+ $this->addUsingAlias(ProductTableMap::NEWNESS, $newness['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::NEWNESS, $newness, $comparison);
+ }
+
+ /**
+ * Filter the query on the promo column
+ *
+ * Example usage:
+ *
+ * $query->filterByPromo(1234); // WHERE promo = 1234
+ * $query->filterByPromo(array(12, 34)); // WHERE promo IN (12, 34)
+ * $query->filterByPromo(array('min' => 12)); // WHERE promo > 12
+ *
+ *
+ * @param mixed $promo The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByPromo($promo = null, $comparison = null)
+ {
+ if (is_array($promo)) {
+ $useMinMax = false;
+ if (isset($promo['min'])) {
+ $this->addUsingAlias(ProductTableMap::PROMO, $promo['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($promo['max'])) {
+ $this->addUsingAlias(ProductTableMap::PROMO, $promo['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::PROMO, $promo, $comparison);
+ }
+
+ /**
+ * Filter the query on the quantity column
+ *
+ * Example usage:
+ *
+ * $query->filterByQuantity(1234); // WHERE quantity = 1234
+ * $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34)
+ * $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12
+ *
+ *
+ * @param mixed $quantity The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByQuantity($quantity = null, $comparison = null)
+ {
+ if (is_array($quantity)) {
+ $useMinMax = false;
+ if (isset($quantity['min'])) {
+ $this->addUsingAlias(ProductTableMap::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($quantity['max'])) {
+ $this->addUsingAlias(ProductTableMap::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::QUANTITY, $quantity, $comparison);
+ }
+
+ /**
+ * Filter the query on the visible column
+ *
+ * Example usage:
+ *
+ * $query->filterByVisible(1234); // WHERE visible = 1234
+ * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
+ * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
+ *
+ *
+ * @param mixed $visible The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByVisible($visible = null, $comparison = null)
+ {
+ if (is_array($visible)) {
+ $useMinMax = false;
+ if (isset($visible['min'])) {
+ $this->addUsingAlias(ProductTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(ProductTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::VISIBLE, $visible, $comparison);
+ }
+
+ /**
+ * Filter the query on the weight column
+ *
+ * Example usage:
+ *
+ * $query->filterByWeight(1234); // WHERE weight = 1234
+ * $query->filterByWeight(array(12, 34)); // WHERE weight IN (12, 34)
+ * $query->filterByWeight(array('min' => 12)); // WHERE weight > 12
+ *
+ *
+ * @param mixed $weight The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByWeight($weight = null, $comparison = null)
+ {
+ if (is_array($weight)) {
+ $useMinMax = false;
+ if (isset($weight['min'])) {
+ $this->addUsingAlias(ProductTableMap::WEIGHT, $weight['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($weight['max'])) {
+ $this->addUsingAlias(ProductTableMap::WEIGHT, $weight['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::WEIGHT, $weight, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(ProductTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(ProductTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ProductTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ProductTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ProductTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ProductTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(ProductTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(ProductTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(ProductTableMap::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(ProductTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\TaxRule object
+ *
+ * @param \Thelia\Model\TaxRule|ObjectCollection $taxRule The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByTaxRule($taxRule, $comparison = null)
+ {
+ if ($taxRule instanceof \Thelia\Model\TaxRule) {
+ return $this
+ ->addUsingAlias(ProductTableMap::TAX_RULE_ID, $taxRule->getId(), $comparison);
+ } elseif ($taxRule instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ProductTableMap::TAX_RULE_ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByTaxRule() only accepts arguments of type \Thelia\Model\TaxRule or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxRule relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function joinTaxRule($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxRule');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'TaxRule');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxRule relation TaxRule object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\TaxRuleQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxRuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinTaxRule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxRule', '\Thelia\Model\TaxRuleQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ProductCategory object
+ *
+ * @param \Thelia\Model\ProductCategory|ObjectCollection $productCategory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByProductCategory($productCategory, $comparison = null)
+ {
+ if ($productCategory instanceof \Thelia\Model\ProductCategory) {
+ return $this
+ ->addUsingAlias(ProductTableMap::ID, $productCategory->getProductId(), $comparison);
+ } elseif ($productCategory instanceof ObjectCollection) {
+ return $this
+ ->useProductCategoryQuery()
+ ->filterByPrimaryKeys($productCategory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByProductCategory() only accepts arguments of type \Thelia\Model\ProductCategory or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ProductCategory relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function joinProductCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ProductCategory');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ProductCategory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ProductCategory relation ProductCategory object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductCategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useProductCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinProductCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ProductCategory', '\Thelia\Model\ProductCategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\FeatureProd object
+ *
+ * @param \Thelia\Model\FeatureProd|ObjectCollection $featureProd the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByFeatureProd($featureProd, $comparison = null)
+ {
+ if ($featureProd instanceof \Thelia\Model\FeatureProd) {
+ return $this
+ ->addUsingAlias(ProductTableMap::ID, $featureProd->getProductId(), $comparison);
+ } elseif ($featureProd instanceof ObjectCollection) {
+ return $this
+ ->useFeatureProdQuery()
+ ->filterByPrimaryKeys($featureProd->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByFeatureProd() only accepts arguments of type \Thelia\Model\FeatureProd or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the FeatureProd relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function joinFeatureProd($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('FeatureProd');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'FeatureProd');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the FeatureProd relation FeatureProd object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FeatureProdQuery A secondary query class using the current class as primary query
+ */
+ public function useFeatureProdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinFeatureProd($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'FeatureProd', '\Thelia\Model\FeatureProdQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Stock object
+ *
+ * @param \Thelia\Model\Stock|ObjectCollection $stock the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByStock($stock, $comparison = null)
+ {
+ if ($stock instanceof \Thelia\Model\Stock) {
+ return $this
+ ->addUsingAlias(ProductTableMap::ID, $stock->getProductId(), $comparison);
+ } elseif ($stock instanceof ObjectCollection) {
+ return $this
+ ->useStockQuery()
+ ->filterByPrimaryKeys($stock->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByStock() only accepts arguments of type \Thelia\Model\Stock or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Stock relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function joinStock($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Stock');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Stock');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Stock relation Stock object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\StockQuery A secondary query class using the current class as primary query
+ */
+ public function useStockQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinStock($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ContentAssoc object
+ *
+ * @param \Thelia\Model\ContentAssoc|ObjectCollection $contentAssoc the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByContentAssoc($contentAssoc, $comparison = null)
+ {
+ if ($contentAssoc instanceof \Thelia\Model\ContentAssoc) {
+ return $this
+ ->addUsingAlias(ProductTableMap::ID, $contentAssoc->getProductId(), $comparison);
+ } elseif ($contentAssoc instanceof ObjectCollection) {
+ return $this
+ ->useContentAssocQuery()
+ ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByContentAssoc() only accepts arguments of type \Thelia\Model\ContentAssoc or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ContentAssoc relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ContentAssoc');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ContentAssoc');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ContentAssoc relation ContentAssoc object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query
+ */
+ public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinContentAssoc($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Image object
+ *
+ * @param \Thelia\Model\Image|ObjectCollection $image the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByImage($image, $comparison = null)
+ {
+ if ($image instanceof \Thelia\Model\Image) {
+ return $this
+ ->addUsingAlias(ProductTableMap::ID, $image->getProductId(), $comparison);
+ } elseif ($image instanceof ObjectCollection) {
+ return $this
+ ->useImageQuery()
+ ->filterByPrimaryKeys($image->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Image relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Image');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Image');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Image relation Image object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query
+ */
+ public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinImage($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Document object
+ *
+ * @param \Thelia\Model\Document|ObjectCollection $document the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByDocument($document, $comparison = null)
+ {
+ if ($document instanceof \Thelia\Model\Document) {
+ return $this
+ ->addUsingAlias(ProductTableMap::ID, $document->getProductId(), $comparison);
+ } elseif ($document instanceof ObjectCollection) {
+ return $this
+ ->useDocumentQuery()
+ ->filterByPrimaryKeys($document->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Document relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Document');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Document');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Document relation Document object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query
+ */
+ public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinDocument($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Accessory object
+ *
+ * @param \Thelia\Model\Accessory|ObjectCollection $accessory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByAccessoryRelatedByProductId($accessory, $comparison = null)
+ {
+ if ($accessory instanceof \Thelia\Model\Accessory) {
+ return $this
+ ->addUsingAlias(ProductTableMap::ID, $accessory->getProductId(), $comparison);
+ } elseif ($accessory instanceof ObjectCollection) {
+ return $this
+ ->useAccessoryRelatedByProductIdQuery()
+ ->filterByPrimaryKeys($accessory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAccessoryRelatedByProductId() only accepts arguments of type \Thelia\Model\Accessory or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AccessoryRelatedByProductId relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function joinAccessoryRelatedByProductId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AccessoryRelatedByProductId');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AccessoryRelatedByProductId');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AccessoryRelatedByProductId relation Accessory object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AccessoryQuery A secondary query class using the current class as primary query
+ */
+ public function useAccessoryRelatedByProductIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAccessoryRelatedByProductId($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AccessoryRelatedByProductId', '\Thelia\Model\AccessoryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Accessory object
+ *
+ * @param \Thelia\Model\Accessory|ObjectCollection $accessory the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByAccessoryRelatedByAccessory($accessory, $comparison = null)
+ {
+ if ($accessory instanceof \Thelia\Model\Accessory) {
+ return $this
+ ->addUsingAlias(ProductTableMap::ID, $accessory->getAccessory(), $comparison);
+ } elseif ($accessory instanceof ObjectCollection) {
+ return $this
+ ->useAccessoryRelatedByAccessoryQuery()
+ ->filterByPrimaryKeys($accessory->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByAccessoryRelatedByAccessory() only accepts arguments of type \Thelia\Model\Accessory or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the AccessoryRelatedByAccessory relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function joinAccessoryRelatedByAccessory($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('AccessoryRelatedByAccessory');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'AccessoryRelatedByAccessory');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the AccessoryRelatedByAccessory relation Accessory object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\AccessoryQuery A secondary query class using the current class as primary query
+ */
+ public function useAccessoryRelatedByAccessoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinAccessoryRelatedByAccessory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'AccessoryRelatedByAccessory', '\Thelia\Model\AccessoryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Rewriting object
+ *
+ * @param \Thelia\Model\Rewriting|ObjectCollection $rewriting the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByRewriting($rewriting, $comparison = null)
+ {
+ if ($rewriting instanceof \Thelia\Model\Rewriting) {
+ return $this
+ ->addUsingAlias(ProductTableMap::ID, $rewriting->getProductId(), $comparison);
+ } elseif ($rewriting instanceof ObjectCollection) {
+ return $this
+ ->useRewritingQuery()
+ ->filterByPrimaryKeys($rewriting->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByRewriting() only accepts arguments of type \Thelia\Model\Rewriting or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Rewriting relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Rewriting');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Rewriting');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Rewriting relation Rewriting object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query
+ */
+ public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinRewriting($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ProductI18n object
+ *
+ * @param \Thelia\Model\ProductI18n|ObjectCollection $productI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByProductI18n($productI18n, $comparison = null)
+ {
+ if ($productI18n instanceof \Thelia\Model\ProductI18n) {
+ return $this
+ ->addUsingAlias(ProductTableMap::ID, $productI18n->getId(), $comparison);
+ } elseif ($productI18n instanceof ObjectCollection) {
+ return $this
+ ->useProductI18nQuery()
+ ->filterByPrimaryKeys($productI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByProductI18n() only accepts arguments of type \Thelia\Model\ProductI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ProductI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function joinProductI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ProductI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ProductI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ProductI18n relation ProductI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useProductI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinProductI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ProductI18n', '\Thelia\Model\ProductI18nQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ProductVersion object
+ *
+ * @param \Thelia\Model\ProductVersion|ObjectCollection $productVersion the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByProductVersion($productVersion, $comparison = null)
+ {
+ if ($productVersion instanceof \Thelia\Model\ProductVersion) {
+ return $this
+ ->addUsingAlias(ProductTableMap::ID, $productVersion->getId(), $comparison);
+ } elseif ($productVersion instanceof ObjectCollection) {
+ return $this
+ ->useProductVersionQuery()
+ ->filterByPrimaryKeys($productVersion->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByProductVersion() only accepts arguments of type \Thelia\Model\ProductVersion or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ProductVersion relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function joinProductVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ProductVersion');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ProductVersion');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ProductVersion relation ProductVersion object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductVersionQuery A secondary query class using the current class as primary query
+ */
+ public function useProductVersionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinProductVersion($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ProductVersion', '\Thelia\Model\ProductVersionQuery');
+ }
+
+ /**
+ * Filter the query by a related Category object
+ * using the product_category table as cross reference
+ *
+ * @param Category $category the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByCategory($category, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useProductCategoryQuery()
+ ->filterByCategory($category, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Filter the query by a related Product object
+ * using the accessory table as cross reference
+ *
+ * @param Product $product the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByProductRelatedByAccessory($product, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useAccessoryRelatedByProductIdQuery()
+ ->filterByProductRelatedByAccessory($product, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Filter the query by a related Product object
+ * using the accessory table as cross reference
+ *
+ * @param Product $product the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function filterByProductRelatedByProductId($product, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useAccessoryRelatedByAccessoryQuery()
+ ->filterByProductRelatedByProductId($product, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildProduct $product Object to remove from the list of results
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function prune($product = null)
+ {
+ if ($product) {
+ $this->addUsingAlias(ProductTableMap::ID, $product->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the product table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ProductTableMap::clearInstancePool();
+ ProductTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildProduct or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildProduct object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductTableMap::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->beginTransaction();
+
+
+ ProductTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ProductTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ProductTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ProductTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ProductTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ProductTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ProductTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ProductTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'ProductI18n';
+
+ return $this
+ ->joinProductI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildProductQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('ProductI18n');
+ $this->with['ProductI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildProductI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ProductI18n', '\Thelia\Model\ProductI18nQuery');
+ }
+
+ // versionable behavior
+
+ /**
+ * Checks whether versioning is enabled
+ *
+ * @return boolean
+ */
+ static public function isVersioningEnabled()
+ {
+ return self::$isVersioningEnabled;
+ }
+
+ /**
+ * Enables versioning
+ */
+ static public function enableVersioning()
+ {
+ self::$isVersioningEnabled = true;
+ }
+
+ /**
+ * Disables versioning
+ */
+ static public function disableVersioning()
+ {
+ self::$isVersioningEnabled = false;
+ }
+
+} // ProductQuery
diff --git a/core/lib/Thelia/Model/Base/ProductVersion.php b/core/lib/Thelia/Model/Base/ProductVersion.php
new file mode 100644
index 000000000..4351460a5
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ProductVersion.php
@@ -0,0 +1,2139 @@
+newness = 0;
+ $this->promo = 0;
+ $this->quantity = 0;
+ $this->visible = 0;
+ $this->version = 0;
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\ProductVersion object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another ProductVersion instance. If
+ * obj is an instance of ProductVersion, delegates to
+ * equals(ProductVersion). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return ProductVersion The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return ProductVersion The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [tax_rule_id] column value.
+ *
+ * @return int
+ */
+ public function getTaxRuleId()
+ {
+
+ return $this->tax_rule_id;
+ }
+
+ /**
+ * Get the [ref] column value.
+ *
+ * @return string
+ */
+ public function getRef()
+ {
+
+ return $this->ref;
+ }
+
+ /**
+ * Get the [price] column value.
+ *
+ * @return double
+ */
+ public function getPrice()
+ {
+
+ return $this->price;
+ }
+
+ /**
+ * Get the [price2] column value.
+ *
+ * @return double
+ */
+ public function getPrice2()
+ {
+
+ return $this->price2;
+ }
+
+ /**
+ * Get the [ecotax] column value.
+ *
+ * @return double
+ */
+ public function getEcotax()
+ {
+
+ return $this->ecotax;
+ }
+
+ /**
+ * Get the [newness] column value.
+ *
+ * @return int
+ */
+ public function getNewness()
+ {
+
+ return $this->newness;
+ }
+
+ /**
+ * Get the [promo] column value.
+ *
+ * @return int
+ */
+ public function getPromo()
+ {
+
+ return $this->promo;
+ }
+
+ /**
+ * Get the [quantity] column value.
+ *
+ * @return int
+ */
+ public function getQuantity()
+ {
+
+ return $this->quantity;
+ }
+
+ /**
+ * Get the [visible] column value.
+ *
+ * @return int
+ */
+ public function getVisible()
+ {
+
+ return $this->visible;
+ }
+
+ /**
+ * Get the [weight] column value.
+ *
+ * @return double
+ */
+ public function getWeight()
+ {
+
+ return $this->weight;
+ }
+
+ /**
+ * Get the [position] column value.
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+
+ return $this->position;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version] column value.
+ *
+ * @return int
+ */
+ public function getVersion()
+ {
+
+ return $this->version;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [version_created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getVersionCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->version_created_at;
+ } else {
+ return $this->version_created_at !== null ? $this->version_created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [version_created_by] column value.
+ *
+ * @return string
+ */
+ public function getVersionCreatedBy()
+ {
+
+ return $this->version_created_by;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ProductVersionTableMap::ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [tax_rule_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setTaxRuleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->tax_rule_id !== $v) {
+ $this->tax_rule_id = $v;
+ $this->modifiedColumns[] = ProductVersionTableMap::TAX_RULE_ID;
+ }
+
+
+ return $this;
+ } // setTaxRuleId()
+
+ /**
+ * Set the value of [ref] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setRef($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->ref !== $v) {
+ $this->ref = $v;
+ $this->modifiedColumns[] = ProductVersionTableMap::REF;
+ }
+
+
+ return $this;
+ } // setRef()
+
+ /**
+ * Set the value of [price] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setPrice($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->price !== $v) {
+ $this->price = $v;
+ $this->modifiedColumns[] = ProductVersionTableMap::PRICE;
+ }
+
+
+ return $this;
+ } // setPrice()
+
+ /**
+ * Set the value of [price2] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setPrice2($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->price2 !== $v) {
+ $this->price2 = $v;
+ $this->modifiedColumns[] = ProductVersionTableMap::PRICE2;
+ }
+
+
+ return $this;
+ } // setPrice2()
+
+ /**
+ * Set the value of [ecotax] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setEcotax($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->ecotax !== $v) {
+ $this->ecotax = $v;
+ $this->modifiedColumns[] = ProductVersionTableMap::ECOTAX;
+ }
+
+
+ return $this;
+ } // setEcotax()
+
+ /**
+ * Set the value of [newness] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setNewness($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->newness !== $v) {
+ $this->newness = $v;
+ $this->modifiedColumns[] = ProductVersionTableMap::NEWNESS;
+ }
+
+
+ return $this;
+ } // setNewness()
+
+ /**
+ * Set the value of [promo] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setPromo($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->promo !== $v) {
+ $this->promo = $v;
+ $this->modifiedColumns[] = ProductVersionTableMap::PROMO;
+ }
+
+
+ return $this;
+ } // setPromo()
+
+ /**
+ * Set the value of [quantity] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setQuantity($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->quantity !== $v) {
+ $this->quantity = $v;
+ $this->modifiedColumns[] = ProductVersionTableMap::QUANTITY;
+ }
+
+
+ return $this;
+ } // setQuantity()
+
+ /**
+ * Set the value of [visible] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setVisible($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->visible !== $v) {
+ $this->visible = $v;
+ $this->modifiedColumns[] = ProductVersionTableMap::VISIBLE;
+ }
+
+
+ return $this;
+ } // setVisible()
+
+ /**
+ * Set the value of [weight] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setWeight($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->weight !== $v) {
+ $this->weight = $v;
+ $this->modifiedColumns[] = ProductVersionTableMap::WEIGHT;
+ }
+
+
+ return $this;
+ } // setWeight()
+
+ /**
+ * Set the value of [position] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setPosition($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->position !== $v) {
+ $this->position = $v;
+ $this->modifiedColumns[] = ProductVersionTableMap::POSITION;
+ }
+
+
+ return $this;
+ } // setPosition()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = ProductVersionTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = ProductVersionTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Set the value of [version] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setVersion($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->version !== $v) {
+ $this->version = $v;
+ $this->modifiedColumns[] = ProductVersionTableMap::VERSION;
+ }
+
+
+ return $this;
+ } // setVersion()
+
+ /**
+ * Sets the value of [version_created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->version_created_at !== null || $dt !== null) {
+ if ($dt !== $this->version_created_at) {
+ $this->version_created_at = $dt;
+ $this->modifiedColumns[] = ProductVersionTableMap::VERSION_CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setVersionCreatedAt()
+
+ /**
+ * Set the value of [version_created_by] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ */
+ public function setVersionCreatedBy($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->version_created_by !== $v) {
+ $this->version_created_by = $v;
+ $this->modifiedColumns[] = ProductVersionTableMap::VERSION_CREATED_BY;
+ }
+
+
+ return $this;
+ } // setVersionCreatedBy()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->newness !== 0) {
+ return false;
+ }
+
+ if ($this->promo !== 0) {
+ return false;
+ }
+
+ if ($this->quantity !== 0) {
+ return false;
+ }
+
+ if ($this->visible !== 0) {
+ return false;
+ }
+
+ if ($this->version !== 0) {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductVersionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductVersionTableMap::translateFieldName('TaxRuleId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->tax_rule_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductVersionTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->ref = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductVersionTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->price = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductVersionTableMap::translateFieldName('Price2', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->price2 = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductVersionTableMap::translateFieldName('Ecotax', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->ecotax = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductVersionTableMap::translateFieldName('Newness', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->newness = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductVersionTableMap::translateFieldName('Promo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->promo = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductVersionTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->quantity = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductVersionTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->visible = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : ProductVersionTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->weight = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : ProductVersionTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->position = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : ProductVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : ProductVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : ProductVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : ProductVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : ProductVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->version_created_by = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 17; // 17 = ProductVersionTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\ProductVersion object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aProduct !== null && $this->id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ProductVersionTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildProductVersionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aProduct = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see ProductVersion::setDeleted()
+ * @see ProductVersion::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductVersionTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildProductVersionQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductVersionTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ProductVersionTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ProductVersionTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::TAX_RULE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'TAX_RULE_ID';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::REF)) {
+ $modifiedColumns[':p' . $index++] = 'REF';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::PRICE)) {
+ $modifiedColumns[':p' . $index++] = 'PRICE';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::PRICE2)) {
+ $modifiedColumns[':p' . $index++] = 'PRICE2';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::ECOTAX)) {
+ $modifiedColumns[':p' . $index++] = 'ECOTAX';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::NEWNESS)) {
+ $modifiedColumns[':p' . $index++] = 'NEWNESS';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::PROMO)) {
+ $modifiedColumns[':p' . $index++] = 'PROMO';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::QUANTITY)) {
+ $modifiedColumns[':p' . $index++] = 'QUANTITY';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::VISIBLE)) {
+ $modifiedColumns[':p' . $index++] = 'VISIBLE';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::WEIGHT)) {
+ $modifiedColumns[':p' . $index++] = 'WEIGHT';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::POSITION)) {
+ $modifiedColumns[':p' . $index++] = 'POSITION';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::VERSION)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::VERSION_CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT';
+ }
+ if ($this->isColumnModified(ProductVersionTableMap::VERSION_CREATED_BY)) {
+ $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO product_version (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'TAX_RULE_ID':
+ $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT);
+ break;
+ case 'REF':
+ $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
+ break;
+ case 'PRICE':
+ $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR);
+ break;
+ case 'PRICE2':
+ $stmt->bindValue($identifier, $this->price2, PDO::PARAM_STR);
+ break;
+ case 'ECOTAX':
+ $stmt->bindValue($identifier, $this->ecotax, PDO::PARAM_STR);
+ break;
+ case 'NEWNESS':
+ $stmt->bindValue($identifier, $this->newness, PDO::PARAM_INT);
+ break;
+ case 'PROMO':
+ $stmt->bindValue($identifier, $this->promo, PDO::PARAM_INT);
+ break;
+ case 'QUANTITY':
+ $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_INT);
+ break;
+ case 'VISIBLE':
+ $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT);
+ break;
+ case 'WEIGHT':
+ $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR);
+ break;
+ case 'POSITION':
+ $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION':
+ $stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
+ break;
+ case 'VERSION_CREATED_AT':
+ $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'VERSION_CREATED_BY':
+ $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ProductVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getTaxRuleId();
+ break;
+ case 2:
+ return $this->getRef();
+ break;
+ case 3:
+ return $this->getPrice();
+ break;
+ case 4:
+ return $this->getPrice2();
+ break;
+ case 5:
+ return $this->getEcotax();
+ break;
+ case 6:
+ return $this->getNewness();
+ break;
+ case 7:
+ return $this->getPromo();
+ break;
+ case 8:
+ return $this->getQuantity();
+ break;
+ case 9:
+ return $this->getVisible();
+ break;
+ case 10:
+ return $this->getWeight();
+ break;
+ case 11:
+ return $this->getPosition();
+ break;
+ case 12:
+ return $this->getCreatedAt();
+ break;
+ case 13:
+ return $this->getUpdatedAt();
+ break;
+ case 14:
+ return $this->getVersion();
+ break;
+ case 15:
+ return $this->getVersionCreatedAt();
+ break;
+ case 16:
+ return $this->getVersionCreatedBy();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ProductVersion'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ProductVersion'][serialize($this->getPrimaryKey())] = true;
+ $keys = ProductVersionTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getTaxRuleId(),
+ $keys[2] => $this->getRef(),
+ $keys[3] => $this->getPrice(),
+ $keys[4] => $this->getPrice2(),
+ $keys[5] => $this->getEcotax(),
+ $keys[6] => $this->getNewness(),
+ $keys[7] => $this->getPromo(),
+ $keys[8] => $this->getQuantity(),
+ $keys[9] => $this->getVisible(),
+ $keys[10] => $this->getWeight(),
+ $keys[11] => $this->getPosition(),
+ $keys[12] => $this->getCreatedAt(),
+ $keys[13] => $this->getUpdatedAt(),
+ $keys[14] => $this->getVersion(),
+ $keys[15] => $this->getVersionCreatedAt(),
+ $keys[16] => $this->getVersionCreatedBy(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ProductVersionTableMap::translateFieldName($name, $type, TableMap::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->setTaxRuleId($value);
+ break;
+ case 2:
+ $this->setRef($value);
+ break;
+ case 3:
+ $this->setPrice($value);
+ break;
+ case 4:
+ $this->setPrice2($value);
+ break;
+ case 5:
+ $this->setEcotax($value);
+ break;
+ case 6:
+ $this->setNewness($value);
+ break;
+ case 7:
+ $this->setPromo($value);
+ break;
+ case 8:
+ $this->setQuantity($value);
+ break;
+ case 9:
+ $this->setVisible($value);
+ break;
+ case 10:
+ $this->setWeight($value);
+ break;
+ case 11:
+ $this->setPosition($value);
+ break;
+ case 12:
+ $this->setCreatedAt($value);
+ break;
+ case 13:
+ $this->setUpdatedAt($value);
+ break;
+ case 14:
+ $this->setVersion($value);
+ break;
+ case 15:
+ $this->setVersionCreatedAt($value);
+ break;
+ case 16:
+ $this->setVersionCreatedBy($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ProductVersionTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setTaxRuleId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setRef($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setPrice($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setPrice2($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setEcotax($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setNewness($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setPromo($arr[$keys[7]]);
+ if (array_key_exists($keys[8], $arr)) $this->setQuantity($arr[$keys[8]]);
+ if (array_key_exists($keys[9], $arr)) $this->setVisible($arr[$keys[9]]);
+ if (array_key_exists($keys[10], $arr)) $this->setWeight($arr[$keys[10]]);
+ if (array_key_exists($keys[11], $arr)) $this->setPosition($arr[$keys[11]]);
+ if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]);
+ if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]);
+ if (array_key_exists($keys[14], $arr)) $this->setVersion($arr[$keys[14]]);
+ if (array_key_exists($keys[15], $arr)) $this->setVersionCreatedAt($arr[$keys[15]]);
+ if (array_key_exists($keys[16], $arr)) $this->setVersionCreatedBy($arr[$keys[16]]);
+ }
+
+ /**
+ * 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(ProductVersionTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ProductVersionTableMap::ID)) $criteria->add(ProductVersionTableMap::ID, $this->id);
+ if ($this->isColumnModified(ProductVersionTableMap::TAX_RULE_ID)) $criteria->add(ProductVersionTableMap::TAX_RULE_ID, $this->tax_rule_id);
+ if ($this->isColumnModified(ProductVersionTableMap::REF)) $criteria->add(ProductVersionTableMap::REF, $this->ref);
+ if ($this->isColumnModified(ProductVersionTableMap::PRICE)) $criteria->add(ProductVersionTableMap::PRICE, $this->price);
+ if ($this->isColumnModified(ProductVersionTableMap::PRICE2)) $criteria->add(ProductVersionTableMap::PRICE2, $this->price2);
+ if ($this->isColumnModified(ProductVersionTableMap::ECOTAX)) $criteria->add(ProductVersionTableMap::ECOTAX, $this->ecotax);
+ if ($this->isColumnModified(ProductVersionTableMap::NEWNESS)) $criteria->add(ProductVersionTableMap::NEWNESS, $this->newness);
+ if ($this->isColumnModified(ProductVersionTableMap::PROMO)) $criteria->add(ProductVersionTableMap::PROMO, $this->promo);
+ if ($this->isColumnModified(ProductVersionTableMap::QUANTITY)) $criteria->add(ProductVersionTableMap::QUANTITY, $this->quantity);
+ if ($this->isColumnModified(ProductVersionTableMap::VISIBLE)) $criteria->add(ProductVersionTableMap::VISIBLE, $this->visible);
+ if ($this->isColumnModified(ProductVersionTableMap::WEIGHT)) $criteria->add(ProductVersionTableMap::WEIGHT, $this->weight);
+ if ($this->isColumnModified(ProductVersionTableMap::POSITION)) $criteria->add(ProductVersionTableMap::POSITION, $this->position);
+ if ($this->isColumnModified(ProductVersionTableMap::CREATED_AT)) $criteria->add(ProductVersionTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ProductVersionTableMap::UPDATED_AT)) $criteria->add(ProductVersionTableMap::UPDATED_AT, $this->updated_at);
+ if ($this->isColumnModified(ProductVersionTableMap::VERSION)) $criteria->add(ProductVersionTableMap::VERSION, $this->version);
+ if ($this->isColumnModified(ProductVersionTableMap::VERSION_CREATED_AT)) $criteria->add(ProductVersionTableMap::VERSION_CREATED_AT, $this->version_created_at);
+ if ($this->isColumnModified(ProductVersionTableMap::VERSION_CREATED_BY)) $criteria->add(ProductVersionTableMap::VERSION_CREATED_BY, $this->version_created_by);
+
+ 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(ProductVersionTableMap::DATABASE_NAME);
+ $criteria->add(ProductVersionTableMap::ID, $this->id);
+ $criteria->add(ProductVersionTableMap::VERSION, $this->version);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getVersion();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setVersion($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getVersion());
+ }
+
+ /**
+ * 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 \Thelia\Model\ProductVersion (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setTaxRuleId($this->getTaxRuleId());
+ $copyObj->setRef($this->getRef());
+ $copyObj->setPrice($this->getPrice());
+ $copyObj->setPrice2($this->getPrice2());
+ $copyObj->setEcotax($this->getEcotax());
+ $copyObj->setNewness($this->getNewness());
+ $copyObj->setPromo($this->getPromo());
+ $copyObj->setQuantity($this->getQuantity());
+ $copyObj->setVisible($this->getVisible());
+ $copyObj->setWeight($this->getWeight());
+ $copyObj->setPosition($this->getPosition());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ $copyObj->setVersion($this->getVersion());
+ $copyObj->setVersionCreatedAt($this->getVersionCreatedAt());
+ $copyObj->setVersionCreatedBy($this->getVersionCreatedBy());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\ProductVersion 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildProduct object.
+ *
+ * @param ChildProduct $v
+ * @return \Thelia\Model\ProductVersion The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(ChildProduct $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aProduct = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildProduct object, it will not be re-added.
+ if ($v !== null) {
+ $v->addProductVersion($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildProduct object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildProduct The associated ChildProduct object.
+ * @throws PropelException
+ */
+ public function getProduct(ConnectionInterface $con = null)
+ {
+ if ($this->aProduct === null && ($this->id !== null)) {
+ $this->aProduct = ChildProductQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aProduct->addProductVersions($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->tax_rule_id = null;
+ $this->ref = null;
+ $this->price = null;
+ $this->price2 = null;
+ $this->ecotax = null;
+ $this->newness = null;
+ $this->promo = null;
+ $this->quantity = null;
+ $this->visible = null;
+ $this->weight = null;
+ $this->position = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->version = null;
+ $this->version_created_at = null;
+ $this->version_created_by = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aProduct = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ProductVersionTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ProductVersionQuery.php b/core/lib/Thelia/Model/Base/ProductVersionQuery.php
new file mode 100644
index 000000000..47f94eb9c
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ProductVersionQuery.php
@@ -0,0 +1,1144 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $version] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildProductVersion|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ProductVersionTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ProductVersionTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildProductVersion A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, TAX_RULE_ID, REF, PRICE, PRICE2, ECOTAX, NEWNESS, PROMO, QUANTITY, VISIBLE, WEIGHT, POSITION, CREATED_AT, UPDATED_AT, VERSION, VERSION_CREATED_AT, VERSION_CREATED_BY FROM product_version WHERE ID = :p0 AND VERSION = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildProductVersion();
+ $obj->hydrate($row);
+ ProductVersionTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildProductVersion|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(ProductVersionTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(ProductVersionTableMap::VERSION, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(ProductVersionTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(ProductVersionTableMap::VERSION, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the tax_rule_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByTaxRuleId(1234); // WHERE tax_rule_id = 1234
+ * $query->filterByTaxRuleId(array(12, 34)); // WHERE tax_rule_id IN (12, 34)
+ * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12
+ *
+ *
+ * @param mixed $taxRuleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByTaxRuleId($taxRuleId = null, $comparison = null)
+ {
+ if (is_array($taxRuleId)) {
+ $useMinMax = false;
+ if (isset($taxRuleId['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::TAX_RULE_ID, $taxRuleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($taxRuleId['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::TAX_RULE_ID, $taxRuleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::TAX_RULE_ID, $taxRuleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the ref column
+ *
+ * Example usage:
+ *
+ * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
+ * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
+ *
+ *
+ * @param string $ref The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByRef($ref = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($ref)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $ref)) {
+ $ref = str_replace('*', '%', $ref);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::REF, $ref, $comparison);
+ }
+
+ /**
+ * Filter the query on the price column
+ *
+ * Example usage:
+ *
+ * $query->filterByPrice(1234); // WHERE price = 1234
+ * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34)
+ * $query->filterByPrice(array('min' => 12)); // WHERE price > 12
+ *
+ *
+ * @param mixed $price The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrice($price = null, $comparison = null)
+ {
+ if (is_array($price)) {
+ $useMinMax = false;
+ if (isset($price['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::PRICE, $price['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($price['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::PRICE, $price['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::PRICE, $price, $comparison);
+ }
+
+ /**
+ * Filter the query on the price2 column
+ *
+ * Example usage:
+ *
+ * $query->filterByPrice2(1234); // WHERE price2 = 1234
+ * $query->filterByPrice2(array(12, 34)); // WHERE price2 IN (12, 34)
+ * $query->filterByPrice2(array('min' => 12)); // WHERE price2 > 12
+ *
+ *
+ * @param mixed $price2 The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByPrice2($price2 = null, $comparison = null)
+ {
+ if (is_array($price2)) {
+ $useMinMax = false;
+ if (isset($price2['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::PRICE2, $price2['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($price2['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::PRICE2, $price2['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::PRICE2, $price2, $comparison);
+ }
+
+ /**
+ * Filter the query on the ecotax column
+ *
+ * Example usage:
+ *
+ * $query->filterByEcotax(1234); // WHERE ecotax = 1234
+ * $query->filterByEcotax(array(12, 34)); // WHERE ecotax IN (12, 34)
+ * $query->filterByEcotax(array('min' => 12)); // WHERE ecotax > 12
+ *
+ *
+ * @param mixed $ecotax The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByEcotax($ecotax = null, $comparison = null)
+ {
+ if (is_array($ecotax)) {
+ $useMinMax = false;
+ if (isset($ecotax['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::ECOTAX, $ecotax['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($ecotax['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::ECOTAX, $ecotax['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::ECOTAX, $ecotax, $comparison);
+ }
+
+ /**
+ * Filter the query on the newness column
+ *
+ * Example usage:
+ *
+ * $query->filterByNewness(1234); // WHERE newness = 1234
+ * $query->filterByNewness(array(12, 34)); // WHERE newness IN (12, 34)
+ * $query->filterByNewness(array('min' => 12)); // WHERE newness > 12
+ *
+ *
+ * @param mixed $newness The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByNewness($newness = null, $comparison = null)
+ {
+ if (is_array($newness)) {
+ $useMinMax = false;
+ if (isset($newness['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::NEWNESS, $newness['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($newness['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::NEWNESS, $newness['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::NEWNESS, $newness, $comparison);
+ }
+
+ /**
+ * Filter the query on the promo column
+ *
+ * Example usage:
+ *
+ * $query->filterByPromo(1234); // WHERE promo = 1234
+ * $query->filterByPromo(array(12, 34)); // WHERE promo IN (12, 34)
+ * $query->filterByPromo(array('min' => 12)); // WHERE promo > 12
+ *
+ *
+ * @param mixed $promo The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByPromo($promo = null, $comparison = null)
+ {
+ if (is_array($promo)) {
+ $useMinMax = false;
+ if (isset($promo['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::PROMO, $promo['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($promo['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::PROMO, $promo['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::PROMO, $promo, $comparison);
+ }
+
+ /**
+ * Filter the query on the quantity column
+ *
+ * Example usage:
+ *
+ * $query->filterByQuantity(1234); // WHERE quantity = 1234
+ * $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34)
+ * $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12
+ *
+ *
+ * @param mixed $quantity The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByQuantity($quantity = null, $comparison = null)
+ {
+ if (is_array($quantity)) {
+ $useMinMax = false;
+ if (isset($quantity['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($quantity['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::QUANTITY, $quantity, $comparison);
+ }
+
+ /**
+ * Filter the query on the visible column
+ *
+ * Example usage:
+ *
+ * $query->filterByVisible(1234); // WHERE visible = 1234
+ * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34)
+ * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12
+ *
+ *
+ * @param mixed $visible The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByVisible($visible = null, $comparison = null)
+ {
+ if (is_array($visible)) {
+ $useMinMax = false;
+ if (isset($visible['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($visible['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::VISIBLE, $visible, $comparison);
+ }
+
+ /**
+ * Filter the query on the weight column
+ *
+ * Example usage:
+ *
+ * $query->filterByWeight(1234); // WHERE weight = 1234
+ * $query->filterByWeight(array(12, 34)); // WHERE weight IN (12, 34)
+ * $query->filterByWeight(array('min' => 12)); // WHERE weight > 12
+ *
+ *
+ * @param mixed $weight The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByWeight($weight = null, $comparison = null)
+ {
+ if (is_array($weight)) {
+ $useMinMax = false;
+ if (isset($weight['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::WEIGHT, $weight['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($weight['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::WEIGHT, $weight['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::WEIGHT, $weight, $comparison);
+ }
+
+ /**
+ * Filter the query on the position column
+ *
+ * Example usage:
+ *
+ * $query->filterByPosition(1234); // WHERE position = 1234
+ * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34)
+ * $query->filterByPosition(array('min' => 12)); // WHERE position > 12
+ *
+ *
+ * @param mixed $position The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByPosition($position = null, $comparison = null)
+ {
+ if (is_array($position)) {
+ $useMinMax = false;
+ if (isset($position['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($position['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::POSITION, $position, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersion(1234); // WHERE version = 1234
+ * $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
+ * $query->filterByVersion(array('min' => 12)); // WHERE version > 12
+ *
+ *
+ * @param mixed $version The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersion($version = null, $comparison = null)
+ {
+ if (is_array($version)) {
+ $useMinMax = false;
+ if (isset($version['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($version['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::VERSION, $version, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedAt('2011-03-14'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt('now'); // WHERE version_created_at = '2011-03-14'
+ * $query->filterByVersionCreatedAt(array('max' => 'yesterday')); // WHERE version_created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $versionCreatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedAt($versionCreatedAt = null, $comparison = null)
+ {
+ if (is_array($versionCreatedAt)) {
+ $useMinMax = false;
+ if (isset($versionCreatedAt['min'])) {
+ $this->addUsingAlias(ProductVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($versionCreatedAt['max'])) {
+ $this->addUsingAlias(ProductVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the version_created_by column
+ *
+ * Example usage:
+ *
+ * $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
+ * $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
+ *
+ *
+ * @param string $versionCreatedBy The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($versionCreatedBy)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $versionCreatedBy)) {
+ $versionCreatedBy = str_replace('*', '%', $versionCreatedBy);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ProductVersionTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Product object
+ *
+ * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function filterByProduct($product, $comparison = null)
+ {
+ if ($product instanceof \Thelia\Model\Product) {
+ return $this
+ ->addUsingAlias(ProductVersionTableMap::ID, $product->getId(), $comparison);
+ } elseif ($product instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ProductVersionTableMap::ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Product relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Product');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Product');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Product relation Product object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
+ */
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildProductVersion $productVersion Object to remove from the list of results
+ *
+ * @return ChildProductVersionQuery The current query, for fluid interface
+ */
+ public function prune($productVersion = null)
+ {
+ if ($productVersion) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(ProductVersionTableMap::ID), $productVersion->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(ProductVersionTableMap::VERSION), $productVersion->getVersion(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the product_version table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductVersionTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ProductVersionTableMap::clearInstancePool();
+ ProductVersionTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildProductVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildProductVersion object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductVersionTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ProductVersionTableMap::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->beginTransaction();
+
+
+ ProductVersionTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ProductVersionTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // ProductVersionQuery
diff --git a/core/lib/Thelia/Model/Base/Resource.php b/core/lib/Thelia/Model/Base/Resource.php
new file mode 100644
index 000000000..827de2643
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Resource.php
@@ -0,0 +1,2325 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Resource instance. If
+ * obj is an instance of Resource, delegates to
+ * equals(Resource). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Resource The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Resource The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Resource The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ResourceTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Resource The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = ResourceTableMap::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Resource The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = ResourceTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Resource The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = ResourceTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ResourceTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ResourceTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->code = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ResourceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ResourceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = ResourceTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Resource object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ResourceTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildResourceQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collGroupResources = null;
+
+ $this->collResourceI18ns = null;
+
+ $this->collGroups = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Resource::setDeleted()
+ * @see Resource::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ResourceTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildResourceQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ResourceTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(ResourceTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(ResourceTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(ResourceTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ResourceTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->groupsScheduledForDeletion !== null) {
+ if (!$this->groupsScheduledForDeletion->isEmpty()) {
+ $pks = array();
+ $pk = $this->getPrimaryKey();
+ foreach ($this->groupsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
+ $pks[] = array($remotePk, $pk);
+ }
+
+ GroupResourceQuery::create()
+ ->filterByPrimaryKeys($pks)
+ ->delete($con);
+ $this->groupsScheduledForDeletion = null;
+ }
+
+ foreach ($this->getGroups() as $group) {
+ if ($group->isModified()) {
+ $group->save($con);
+ }
+ }
+ } elseif ($this->collGroups) {
+ foreach ($this->collGroups as $group) {
+ if ($group->isModified()) {
+ $group->save($con);
+ }
+ }
+ }
+
+ if ($this->groupResourcesScheduledForDeletion !== null) {
+ if (!$this->groupResourcesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\GroupResourceQuery::create()
+ ->filterByPrimaryKeys($this->groupResourcesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->groupResourcesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collGroupResources !== null) {
+ foreach ($this->collGroupResources as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->resourceI18nsScheduledForDeletion !== null) {
+ if (!$this->resourceI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\ResourceI18nQuery::create()
+ ->filterByPrimaryKeys($this->resourceI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->resourceI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collResourceI18ns !== null) {
+ foreach ($this->collResourceI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = ResourceTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . ResourceTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ResourceTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ResourceTableMap::CODE)) {
+ $modifiedColumns[':p' . $index++] = 'CODE';
+ }
+ if ($this->isColumnModified(ResourceTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(ResourceTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO resource (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'CODE':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ResourceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getCode();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Resource'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Resource'][$this->getPrimaryKey()] = true;
+ $keys = ResourceTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collGroupResources) {
+ $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collResourceI18ns) {
+ $result['ResourceI18ns'] = $this->collResourceI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ResourceTableMap::translateFieldName($name, $type, TableMap::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->setCode($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ResourceTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * 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(ResourceTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ResourceTableMap::ID)) $criteria->add(ResourceTableMap::ID, $this->id);
+ if ($this->isColumnModified(ResourceTableMap::CODE)) $criteria->add(ResourceTableMap::CODE, $this->code);
+ if ($this->isColumnModified(ResourceTableMap::CREATED_AT)) $criteria->add(ResourceTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(ResourceTableMap::UPDATED_AT)) $criteria->add(ResourceTableMap::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(ResourceTableMap::DATABASE_NAME);
+ $criteria->add(ResourceTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Resource (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getGroupResources() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addGroupResource($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getResourceI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addResourceI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Resource 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('GroupResource' == $relationName) {
+ return $this->initGroupResources();
+ }
+ if ('ResourceI18n' == $relationName) {
+ return $this->initResourceI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collGroupResources collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addGroupResources()
+ */
+ public function clearGroupResources()
+ {
+ $this->collGroupResources = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collGroupResources collection loaded partially.
+ */
+ public function resetPartialGroupResources($v = true)
+ {
+ $this->collGroupResourcesPartial = $v;
+ }
+
+ /**
+ * Initializes the collGroupResources collection.
+ *
+ * By default this just sets the collGroupResources collection to an empty array (like clearcollGroupResources());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initGroupResources($overrideExisting = true)
+ {
+ if (null !== $this->collGroupResources && !$overrideExisting) {
+ return;
+ }
+ $this->collGroupResources = new ObjectCollection();
+ $this->collGroupResources->setModel('\Thelia\Model\GroupResource');
+ }
+
+ /**
+ * Gets an array of ChildGroupResource objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildResource is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildGroupResource[] List of ChildGroupResource objects
+ * @throws PropelException
+ */
+ public function getGroupResources($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collGroupResourcesPartial && !$this->isNew();
+ if (null === $this->collGroupResources || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupResources) {
+ // return empty collection
+ $this->initGroupResources();
+ } else {
+ $collGroupResources = ChildGroupResourceQuery::create(null, $criteria)
+ ->filterByResource($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collGroupResourcesPartial && count($collGroupResources)) {
+ $this->initGroupResources(false);
+
+ foreach ($collGroupResources as $obj) {
+ if (false == $this->collGroupResources->contains($obj)) {
+ $this->collGroupResources->append($obj);
+ }
+ }
+
+ $this->collGroupResourcesPartial = true;
+ }
+
+ $collGroupResources->getInternalIterator()->rewind();
+
+ return $collGroupResources;
+ }
+
+ if ($partial && $this->collGroupResources) {
+ foreach ($this->collGroupResources as $obj) {
+ if ($obj->isNew()) {
+ $collGroupResources[] = $obj;
+ }
+ }
+ }
+
+ $this->collGroupResources = $collGroupResources;
+ $this->collGroupResourcesPartial = false;
+ }
+ }
+
+ return $this->collGroupResources;
+ }
+
+ /**
+ * Sets a collection of GroupResource objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $groupResources A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildResource The current object (for fluent API support)
+ */
+ public function setGroupResources(Collection $groupResources, ConnectionInterface $con = null)
+ {
+ $groupResourcesToDelete = $this->getGroupResources(new Criteria(), $con)->diff($groupResources);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->groupResourcesScheduledForDeletion = clone $groupResourcesToDelete;
+
+ foreach ($groupResourcesToDelete as $groupResourceRemoved) {
+ $groupResourceRemoved->setResource(null);
+ }
+
+ $this->collGroupResources = null;
+ foreach ($groupResources as $groupResource) {
+ $this->addGroupResource($groupResource);
+ }
+
+ $this->collGroupResources = $groupResources;
+ $this->collGroupResourcesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related GroupResource objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related GroupResource objects.
+ * @throws PropelException
+ */
+ public function countGroupResources(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collGroupResourcesPartial && !$this->isNew();
+ if (null === $this->collGroupResources || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collGroupResources) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getGroupResources());
+ }
+
+ $query = ChildGroupResourceQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByResource($this)
+ ->count($con);
+ }
+
+ return count($this->collGroupResources);
+ }
+
+ /**
+ * Method called to associate a ChildGroupResource object to this object
+ * through the ChildGroupResource foreign key attribute.
+ *
+ * @param ChildGroupResource $l ChildGroupResource
+ * @return \Thelia\Model\Resource The current object (for fluent API support)
+ */
+ public function addGroupResource(ChildGroupResource $l)
+ {
+ if ($this->collGroupResources === null) {
+ $this->initGroupResources();
+ $this->collGroupResourcesPartial = true;
+ }
+
+ if (!in_array($l, $this->collGroupResources->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddGroupResource($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param GroupResource $groupResource The groupResource object to add.
+ */
+ protected function doAddGroupResource($groupResource)
+ {
+ $this->collGroupResources[]= $groupResource;
+ $groupResource->setResource($this);
+ }
+
+ /**
+ * @param GroupResource $groupResource The groupResource object to remove.
+ * @return ChildResource The current object (for fluent API support)
+ */
+ public function removeGroupResource($groupResource)
+ {
+ if ($this->getGroupResources()->contains($groupResource)) {
+ $this->collGroupResources->remove($this->collGroupResources->search($groupResource));
+ if (null === $this->groupResourcesScheduledForDeletion) {
+ $this->groupResourcesScheduledForDeletion = clone $this->collGroupResources;
+ $this->groupResourcesScheduledForDeletion->clear();
+ }
+ $this->groupResourcesScheduledForDeletion[]= clone $groupResource;
+ $groupResource->setResource(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Resource is new, it will return
+ * an empty collection; or if this Resource has previously
+ * been saved, it will retrieve related GroupResources 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 Resource.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildGroupResource[] List of ChildGroupResource objects
+ */
+ public function getGroupResourcesJoinGroup($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildGroupResourceQuery::create(null, $criteria);
+ $query->joinWith('Group', $joinBehavior);
+
+ return $this->getGroupResources($query, $con);
+ }
+
+ /**
+ * Clears out the collResourceI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addResourceI18ns()
+ */
+ public function clearResourceI18ns()
+ {
+ $this->collResourceI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collResourceI18ns collection loaded partially.
+ */
+ public function resetPartialResourceI18ns($v = true)
+ {
+ $this->collResourceI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collResourceI18ns collection.
+ *
+ * By default this just sets the collResourceI18ns collection to an empty array (like clearcollResourceI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initResourceI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collResourceI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collResourceI18ns = new ObjectCollection();
+ $this->collResourceI18ns->setModel('\Thelia\Model\ResourceI18n');
+ }
+
+ /**
+ * Gets an array of ChildResourceI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildResource is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildResourceI18n[] List of ChildResourceI18n objects
+ * @throws PropelException
+ */
+ public function getResourceI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collResourceI18nsPartial && !$this->isNew();
+ if (null === $this->collResourceI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collResourceI18ns) {
+ // return empty collection
+ $this->initResourceI18ns();
+ } else {
+ $collResourceI18ns = ChildResourceI18nQuery::create(null, $criteria)
+ ->filterByResource($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collResourceI18nsPartial && count($collResourceI18ns)) {
+ $this->initResourceI18ns(false);
+
+ foreach ($collResourceI18ns as $obj) {
+ if (false == $this->collResourceI18ns->contains($obj)) {
+ $this->collResourceI18ns->append($obj);
+ }
+ }
+
+ $this->collResourceI18nsPartial = true;
+ }
+
+ $collResourceI18ns->getInternalIterator()->rewind();
+
+ return $collResourceI18ns;
+ }
+
+ if ($partial && $this->collResourceI18ns) {
+ foreach ($this->collResourceI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collResourceI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collResourceI18ns = $collResourceI18ns;
+ $this->collResourceI18nsPartial = false;
+ }
+ }
+
+ return $this->collResourceI18ns;
+ }
+
+ /**
+ * Sets a collection of ResourceI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $resourceI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildResource The current object (for fluent API support)
+ */
+ public function setResourceI18ns(Collection $resourceI18ns, ConnectionInterface $con = null)
+ {
+ $resourceI18nsToDelete = $this->getResourceI18ns(new Criteria(), $con)->diff($resourceI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->resourceI18nsScheduledForDeletion = clone $resourceI18nsToDelete;
+
+ foreach ($resourceI18nsToDelete as $resourceI18nRemoved) {
+ $resourceI18nRemoved->setResource(null);
+ }
+
+ $this->collResourceI18ns = null;
+ foreach ($resourceI18ns as $resourceI18n) {
+ $this->addResourceI18n($resourceI18n);
+ }
+
+ $this->collResourceI18ns = $resourceI18ns;
+ $this->collResourceI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related ResourceI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related ResourceI18n objects.
+ * @throws PropelException
+ */
+ public function countResourceI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collResourceI18nsPartial && !$this->isNew();
+ if (null === $this->collResourceI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collResourceI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getResourceI18ns());
+ }
+
+ $query = ChildResourceI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByResource($this)
+ ->count($con);
+ }
+
+ return count($this->collResourceI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildResourceI18n object to this object
+ * through the ChildResourceI18n foreign key attribute.
+ *
+ * @param ChildResourceI18n $l ChildResourceI18n
+ * @return \Thelia\Model\Resource The current object (for fluent API support)
+ */
+ public function addResourceI18n(ChildResourceI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collResourceI18ns === null) {
+ $this->initResourceI18ns();
+ $this->collResourceI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collResourceI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddResourceI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ResourceI18n $resourceI18n The resourceI18n object to add.
+ */
+ protected function doAddResourceI18n($resourceI18n)
+ {
+ $this->collResourceI18ns[]= $resourceI18n;
+ $resourceI18n->setResource($this);
+ }
+
+ /**
+ * @param ResourceI18n $resourceI18n The resourceI18n object to remove.
+ * @return ChildResource The current object (for fluent API support)
+ */
+ public function removeResourceI18n($resourceI18n)
+ {
+ if ($this->getResourceI18ns()->contains($resourceI18n)) {
+ $this->collResourceI18ns->remove($this->collResourceI18ns->search($resourceI18n));
+ if (null === $this->resourceI18nsScheduledForDeletion) {
+ $this->resourceI18nsScheduledForDeletion = clone $this->collResourceI18ns;
+ $this->resourceI18nsScheduledForDeletion->clear();
+ }
+ $this->resourceI18nsScheduledForDeletion[]= clone $resourceI18n;
+ $resourceI18n->setResource(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collGroups collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addGroups()
+ */
+ public function clearGroups()
+ {
+ $this->collGroups = null; // important to set this to NULL since that means it is uninitialized
+ $this->collGroupsPartial = null;
+ }
+
+ /**
+ * Initializes the collGroups collection.
+ *
+ * By default this just sets the collGroups collection to an empty collection (like clearGroups());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @return void
+ */
+ public function initGroups()
+ {
+ $this->collGroups = new ObjectCollection();
+ $this->collGroups->setModel('\Thelia\Model\Group');
+ }
+
+ /**
+ * Gets a collection of ChildGroup objects related by a many-to-many relationship
+ * to the current object by way of the group_resource cross-reference table.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildResource is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return ObjectCollection|ChildGroup[] List of ChildGroup objects
+ */
+ public function getGroups($criteria = null, ConnectionInterface $con = null)
+ {
+ if (null === $this->collGroups || null !== $criteria) {
+ if ($this->isNew() && null === $this->collGroups) {
+ // return empty collection
+ $this->initGroups();
+ } else {
+ $collGroups = ChildGroupQuery::create(null, $criteria)
+ ->filterByResource($this)
+ ->find($con);
+ if (null !== $criteria) {
+ return $collGroups;
+ }
+ $this->collGroups = $collGroups;
+ }
+ }
+
+ return $this->collGroups;
+ }
+
+ /**
+ * Sets a collection of Group objects related by a many-to-many relationship
+ * to the current object by way of the group_resource cross-reference table.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $groups A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildResource The current object (for fluent API support)
+ */
+ public function setGroups(Collection $groups, ConnectionInterface $con = null)
+ {
+ $this->clearGroups();
+ $currentGroups = $this->getGroups();
+
+ $this->groupsScheduledForDeletion = $currentGroups->diff($groups);
+
+ foreach ($groups as $group) {
+ if (!$currentGroups->contains($group)) {
+ $this->doAddGroup($group);
+ }
+ }
+
+ $this->collGroups = $groups;
+
+ return $this;
+ }
+
+ /**
+ * Gets the number of ChildGroup objects related by a many-to-many relationship
+ * to the current object by way of the group_resource cross-reference table.
+ *
+ * @param Criteria $criteria Optional query object to filter the query
+ * @param boolean $distinct Set to true to force count distinct
+ * @param ConnectionInterface $con Optional connection object
+ *
+ * @return int the number of related ChildGroup objects
+ */
+ public function countGroups($criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ if (null === $this->collGroups || null !== $criteria) {
+ if ($this->isNew() && null === $this->collGroups) {
+ return 0;
+ } else {
+ $query = ChildGroupQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByResource($this)
+ ->count($con);
+ }
+ } else {
+ return count($this->collGroups);
+ }
+ }
+
+ /**
+ * Associate a ChildGroup object to this object
+ * through the group_resource cross reference table.
+ *
+ * @param ChildGroup $group The ChildGroupResource object to relate
+ * @return ChildResource The current object (for fluent API support)
+ */
+ public function addGroup(ChildGroup $group)
+ {
+ if ($this->collGroups === null) {
+ $this->initGroups();
+ }
+
+ if (!$this->collGroups->contains($group)) { // only add it if the **same** object is not already associated
+ $this->doAddGroup($group);
+ $this->collGroups[] = $group;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Group $group The group object to add.
+ */
+ protected function doAddGroup($group)
+ {
+ $groupResource = new ChildGroupResource();
+ $groupResource->setGroup($group);
+ $this->addGroupResource($groupResource);
+ // set the back reference to this object directly as using provided method either results
+ // in endless loop or in multiple relations
+ if (!$group->getResources()->contains($this)) {
+ $foreignCollection = $group->getResources();
+ $foreignCollection[] = $this;
+ }
+ }
+
+ /**
+ * Remove a ChildGroup object to this object
+ * through the group_resource cross reference table.
+ *
+ * @param ChildGroup $group The ChildGroupResource object to relate
+ * @return ChildResource The current object (for fluent API support)
+ */
+ public function removeGroup(ChildGroup $group)
+ {
+ if ($this->getGroups()->contains($group)) {
+ $this->collGroups->remove($this->collGroups->search($group));
+
+ if (null === $this->groupsScheduledForDeletion) {
+ $this->groupsScheduledForDeletion = clone $this->collGroups;
+ $this->groupsScheduledForDeletion->clear();
+ }
+
+ $this->groupsScheduledForDeletion[] = $group;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collGroupResources) {
+ foreach ($this->collGroupResources as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collResourceI18ns) {
+ foreach ($this->collResourceI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collGroups) {
+ foreach ($this->collGroups as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collGroupResources instanceof Collection) {
+ $this->collGroupResources->clearIterator();
+ }
+ $this->collGroupResources = null;
+ if ($this->collResourceI18ns instanceof Collection) {
+ $this->collResourceI18ns->clearIterator();
+ }
+ $this->collResourceI18ns = null;
+ if ($this->collGroups instanceof Collection) {
+ $this->collGroups->clearIterator();
+ }
+ $this->collGroups = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ResourceTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildResource The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = ResourceTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildResource The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildResourceI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collResourceI18ns) {
+ foreach ($this->collResourceI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildResourceI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildResourceI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addResourceI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildResource The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildResourceI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collResourceI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collResourceI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildResourceI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ResourceI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ResourceI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+ return $this->getCurrentTranslation()->getChapo();
+ }
+
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ResourceI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ { $this->getCurrentTranslation()->setChapo($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+ return $this->getCurrentTranslation()->getPostscriptum();
+ }
+
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ResourceI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ { $this->getCurrentTranslation()->setPostscriptum($v);
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ResourceI18n.php b/core/lib/Thelia/Model/Base/ResourceI18n.php
new file mode 100644
index 000000000..b740bd858
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ResourceI18n.php
@@ -0,0 +1,1439 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\ResourceI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another ResourceI18n instance. If
+ * obj is an instance of ResourceI18n, delegates to
+ * equals(ResourceI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return ResourceI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return ResourceI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [chapo] column value.
+ *
+ * @return string
+ */
+ public function getChapo()
+ {
+
+ return $this->chapo;
+ }
+
+ /**
+ * Get the [postscriptum] column value.
+ *
+ * @return string
+ */
+ public function getPostscriptum()
+ {
+
+ return $this->postscriptum;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\ResourceI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = ResourceI18nTableMap::ID;
+ }
+
+ if ($this->aResource !== null && $this->aResource->getId() !== $v) {
+ $this->aResource = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ResourceI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = ResourceI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ResourceI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = ResourceI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ResourceI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = ResourceI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Set the value of [chapo] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ResourceI18n The current object (for fluent API support)
+ */
+ public function setChapo($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->chapo !== $v) {
+ $this->chapo = $v;
+ $this->modifiedColumns[] = ResourceI18nTableMap::CHAPO;
+ }
+
+
+ return $this;
+ } // setChapo()
+
+ /**
+ * Set the value of [postscriptum] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\ResourceI18n The current object (for fluent API support)
+ */
+ public function setPostscriptum($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->postscriptum !== $v) {
+ $this->postscriptum = $v;
+ $this->modifiedColumns[] = ResourceI18nTableMap::POSTSCRIPTUM;
+ }
+
+
+ return $this;
+ } // setPostscriptum()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ResourceI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ResourceI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ResourceI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ResourceI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ResourceI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->chapo = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ResourceI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->postscriptum = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = ResourceI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\ResourceI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aResource !== null && $this->id !== $this->aResource->getId()) {
+ $this->aResource = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ResourceI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildResourceI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aResource = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see ResourceI18n::setDeleted()
+ * @see ResourceI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ResourceI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildResourceI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ResourceI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ ResourceI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aResource !== null) {
+ if ($this->aResource->isModified() || $this->aResource->isNew()) {
+ $affectedRows += $this->aResource->save($con);
+ }
+ $this->setResource($this->aResource);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(ResourceI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(ResourceI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(ResourceI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(ResourceI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(ResourceI18nTableMap::CHAPO)) {
+ $modifiedColumns[':p' . $index++] = 'CHAPO';
+ }
+ if ($this->isColumnModified(ResourceI18nTableMap::POSTSCRIPTUM)) {
+ $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO resource_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CHAPO':
+ $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR);
+ break;
+ case 'POSTSCRIPTUM':
+ $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ResourceI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getChapo();
+ break;
+ case 5:
+ return $this->getPostscriptum();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['ResourceI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['ResourceI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = ResourceI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getChapo(),
+ $keys[5] => $this->getPostscriptum(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aResource) {
+ $result['Resource'] = $this->aResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = ResourceI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setChapo($value);
+ break;
+ case 5:
+ $this->setPostscriptum($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = ResourceI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(ResourceI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(ResourceI18nTableMap::ID)) $criteria->add(ResourceI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(ResourceI18nTableMap::LOCALE)) $criteria->add(ResourceI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(ResourceI18nTableMap::TITLE)) $criteria->add(ResourceI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(ResourceI18nTableMap::DESCRIPTION)) $criteria->add(ResourceI18nTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(ResourceI18nTableMap::CHAPO)) $criteria->add(ResourceI18nTableMap::CHAPO, $this->chapo);
+ if ($this->isColumnModified(ResourceI18nTableMap::POSTSCRIPTUM)) $criteria->add(ResourceI18nTableMap::POSTSCRIPTUM, $this->postscriptum);
+
+ 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(ResourceI18nTableMap::DATABASE_NAME);
+ $criteria->add(ResourceI18nTableMap::ID, $this->id);
+ $criteria->add(ResourceI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\ResourceI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setChapo($this->getChapo());
+ $copyObj->setPostscriptum($this->getPostscriptum());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\ResourceI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildResource object.
+ *
+ * @param ChildResource $v
+ * @return \Thelia\Model\ResourceI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setResource(ChildResource $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aResource = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildResource object, it will not be re-added.
+ if ($v !== null) {
+ $v->addResourceI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildResource object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildResource The associated ChildResource object.
+ * @throws PropelException
+ */
+ public function getResource(ConnectionInterface $con = null)
+ {
+ if ($this->aResource === null && ($this->id !== null)) {
+ $this->aResource = ChildResourceQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aResource->addResourceI18ns($this);
+ */
+ }
+
+ return $this->aResource;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->chapo = null;
+ $this->postscriptum = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aResource = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(ResourceI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/ResourceI18nQuery.php b/core/lib/Thelia/Model/Base/ResourceI18nQuery.php
new file mode 100644
index 000000000..8c9872943
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ResourceI18nQuery.php
@@ -0,0 +1,607 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildResourceI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ResourceI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ResourceI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildResourceI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM resource_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildResourceI18n();
+ $obj->hydrate($row);
+ ResourceI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildResourceI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildResourceI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(ResourceI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(ResourceI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildResourceI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(ResourceI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(ResourceI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByResource()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildResourceI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ResourceI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ResourceI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildResourceI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildResourceI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildResourceI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the chapo column
+ *
+ * Example usage:
+ *
+ * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
+ * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
+ *
+ *
+ * @param string $chapo The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildResourceI18nQuery The current query, for fluid interface
+ */
+ public function filterByChapo($chapo = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($chapo)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $chapo)) {
+ $chapo = str_replace('*', '%', $chapo);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceI18nTableMap::CHAPO, $chapo, $comparison);
+ }
+
+ /**
+ * Filter the query on the postscriptum column
+ *
+ * Example usage:
+ *
+ * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
+ * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
+ *
+ *
+ * @param string $postscriptum The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildResourceI18nQuery The current query, for fluid interface
+ */
+ public function filterByPostscriptum($postscriptum = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($postscriptum)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $postscriptum)) {
+ $postscriptum = str_replace('*', '%', $postscriptum);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Resource object
+ *
+ * @param \Thelia\Model\Resource|ObjectCollection $resource The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildResourceI18nQuery The current query, for fluid interface
+ */
+ public function filterByResource($resource, $comparison = null)
+ {
+ if ($resource instanceof \Thelia\Model\Resource) {
+ return $this
+ ->addUsingAlias(ResourceI18nTableMap::ID, $resource->getId(), $comparison);
+ } elseif ($resource instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(ResourceI18nTableMap::ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByResource() only accepts arguments of type \Thelia\Model\Resource or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Resource relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildResourceI18nQuery The current query, for fluid interface
+ */
+ public function joinResource($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Resource');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Resource');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Resource relation Resource object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ResourceQuery A secondary query class using the current class as primary query
+ */
+ public function useResourceQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinResource($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Resource', '\Thelia\Model\ResourceQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildResourceI18n $resourceI18n Object to remove from the list of results
+ *
+ * @return ChildResourceI18nQuery The current query, for fluid interface
+ */
+ public function prune($resourceI18n = null)
+ {
+ if ($resourceI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(ResourceI18nTableMap::ID), $resourceI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(ResourceI18nTableMap::LOCALE), $resourceI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the resource_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ResourceI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ResourceI18nTableMap::clearInstancePool();
+ ResourceI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildResourceI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildResourceI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ResourceI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ResourceI18nTableMap::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->beginTransaction();
+
+
+ ResourceI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ResourceI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // ResourceI18nQuery
diff --git a/core/lib/Thelia/Model/Base/ResourceQuery.php b/core/lib/Thelia/Model/Base/ResourceQuery.php
new file mode 100644
index 000000000..e12ee8f53
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/ResourceQuery.php
@@ -0,0 +1,769 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildResource|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = ResourceTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(ResourceTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildResource A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CODE, CREATED_AT, UPDATED_AT FROM resource WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildResource();
+ $obj->hydrate($row);
+ ResourceTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildResource|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(ResourceTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(ResourceTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(ResourceTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(ResourceTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceTableMap::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(ResourceTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(ResourceTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(ResourceTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(ResourceTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(ResourceTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\GroupResource object
+ *
+ * @param \Thelia\Model\GroupResource|ObjectCollection $groupResource the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function filterByGroupResource($groupResource, $comparison = null)
+ {
+ if ($groupResource instanceof \Thelia\Model\GroupResource) {
+ return $this
+ ->addUsingAlias(ResourceTableMap::ID, $groupResource->getResourceId(), $comparison);
+ } elseif ($groupResource instanceof ObjectCollection) {
+ return $this
+ ->useGroupResourceQuery()
+ ->filterByPrimaryKeys($groupResource->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByGroupResource() only accepts arguments of type \Thelia\Model\GroupResource or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the GroupResource relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function joinGroupResource($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('GroupResource');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'GroupResource');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the GroupResource relation GroupResource object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\GroupResourceQuery A secondary query class using the current class as primary query
+ */
+ public function useGroupResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinGroupResource($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'GroupResource', '\Thelia\Model\GroupResourceQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\ResourceI18n object
+ *
+ * @param \Thelia\Model\ResourceI18n|ObjectCollection $resourceI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function filterByResourceI18n($resourceI18n, $comparison = null)
+ {
+ if ($resourceI18n instanceof \Thelia\Model\ResourceI18n) {
+ return $this
+ ->addUsingAlias(ResourceTableMap::ID, $resourceI18n->getId(), $comparison);
+ } elseif ($resourceI18n instanceof ObjectCollection) {
+ return $this
+ ->useResourceI18nQuery()
+ ->filterByPrimaryKeys($resourceI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByResourceI18n() only accepts arguments of type \Thelia\Model\ResourceI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the ResourceI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function joinResourceI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('ResourceI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'ResourceI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the ResourceI18n relation ResourceI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ResourceI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useResourceI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinResourceI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ResourceI18n', '\Thelia\Model\ResourceI18nQuery');
+ }
+
+ /**
+ * Filter the query by a related Group object
+ * using the group_resource table as cross reference
+ *
+ * @param Group $group the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function filterByGroup($group, $comparison = Criteria::EQUAL)
+ {
+ return $this
+ ->useGroupResourceQuery()
+ ->filterByGroup($group, $comparison)
+ ->endUse();
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildResource $resource Object to remove from the list of results
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function prune($resource = null)
+ {
+ if ($resource) {
+ $this->addUsingAlias(ResourceTableMap::ID, $resource->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the resource table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ResourceTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ ResourceTableMap::clearInstancePool();
+ ResourceTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildResource or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildResource object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ResourceTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(ResourceTableMap::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->beginTransaction();
+
+
+ ResourceTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ ResourceTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ResourceTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(ResourceTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ResourceTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ResourceTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(ResourceTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(ResourceTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'ResourceI18n';
+
+ return $this
+ ->joinResourceI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildResourceQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('ResourceI18n');
+ $this->with['ResourceI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildResourceI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'ResourceI18n', '\Thelia\Model\ResourceI18nQuery');
+ }
+
+} // ResourceQuery
diff --git a/core/lib/Thelia/Model/Base/Rewriting.php b/core/lib/Thelia/Model/Base/Rewriting.php
new file mode 100644
index 000000000..12229c438
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Rewriting.php
@@ -0,0 +1,1812 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Rewriting instance. If
+ * obj is an instance of Rewriting, delegates to
+ * equals(Rewriting). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Rewriting The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Rewriting The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [url] column value.
+ *
+ * @return string
+ */
+ public function getUrl()
+ {
+
+ return $this->url;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [category_id] column value.
+ *
+ * @return int
+ */
+ public function getCategoryId()
+ {
+
+ return $this->category_id;
+ }
+
+ /**
+ * Get the [folder_id] column value.
+ *
+ * @return int
+ */
+ public function getFolderId()
+ {
+
+ return $this->folder_id;
+ }
+
+ /**
+ * Get the [content_id] column value.
+ *
+ * @return int
+ */
+ public function getContentId()
+ {
+
+ return $this->content_id;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Rewriting The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = RewritingTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [url] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\Rewriting The current object (for fluent API support)
+ */
+ public function setUrl($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->url !== $v) {
+ $this->url = $v;
+ $this->modifiedColumns[] = RewritingTableMap::URL;
+ }
+
+
+ return $this;
+ } // setUrl()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Rewriting The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = RewritingTableMap::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [category_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Rewriting The current object (for fluent API support)
+ */
+ public function setCategoryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->category_id !== $v) {
+ $this->category_id = $v;
+ $this->modifiedColumns[] = RewritingTableMap::CATEGORY_ID;
+ }
+
+ if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
+ $this->aCategory = null;
+ }
+
+
+ return $this;
+ } // setCategoryId()
+
+ /**
+ * Set the value of [folder_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Rewriting The current object (for fluent API support)
+ */
+ public function setFolderId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->folder_id !== $v) {
+ $this->folder_id = $v;
+ $this->modifiedColumns[] = RewritingTableMap::FOLDER_ID;
+ }
+
+ if ($this->aFolder !== null && $this->aFolder->getId() !== $v) {
+ $this->aFolder = null;
+ }
+
+
+ return $this;
+ } // setFolderId()
+
+ /**
+ * Set the value of [content_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Rewriting The current object (for fluent API support)
+ */
+ public function setContentId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->content_id !== $v) {
+ $this->content_id = $v;
+ $this->modifiedColumns[] = RewritingTableMap::CONTENT_ID;
+ }
+
+ if ($this->aContent !== null && $this->aContent->getId() !== $v) {
+ $this->aContent = null;
+ }
+
+
+ return $this;
+ } // setContentId()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Rewriting The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = RewritingTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Rewriting The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = RewritingTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : RewritingTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : RewritingTableMap::translateFieldName('Url', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->url = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : RewritingTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->product_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : RewritingTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->category_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : RewritingTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->folder_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : RewritingTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->content_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : RewritingTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : RewritingTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 8; // 8 = RewritingTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Rewriting object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
+ $this->aCategory = null;
+ }
+ if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) {
+ $this->aFolder = null;
+ }
+ if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) {
+ $this->aContent = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(RewritingTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildRewritingQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aFolder = null;
+ $this->aContent = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Rewriting::setDeleted()
+ * @see Rewriting::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildRewritingQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(RewritingTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(RewritingTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(RewritingTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ RewritingTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
+ if ($this->aCategory !== null) {
+ if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
+ $affectedRows += $this->aCategory->save($con);
+ }
+ $this->setCategory($this->aCategory);
+ }
+
+ if ($this->aFolder !== null) {
+ if ($this->aFolder->isModified() || $this->aFolder->isNew()) {
+ $affectedRows += $this->aFolder->save($con);
+ }
+ $this->setFolder($this->aFolder);
+ }
+
+ if ($this->aContent !== null) {
+ if ($this->aContent->isModified() || $this->aContent->isNew()) {
+ $affectedRows += $this->aContent->save($con);
+ }
+ $this->setContent($this->aContent);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(RewritingTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(RewritingTableMap::URL)) {
+ $modifiedColumns[':p' . $index++] = 'URL';
+ }
+ if ($this->isColumnModified(RewritingTableMap::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'PRODUCT_ID';
+ }
+ if ($this->isColumnModified(RewritingTableMap::CATEGORY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CATEGORY_ID';
+ }
+ if ($this->isColumnModified(RewritingTableMap::FOLDER_ID)) {
+ $modifiedColumns[':p' . $index++] = 'FOLDER_ID';
+ }
+ if ($this->isColumnModified(RewritingTableMap::CONTENT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'CONTENT_ID';
+ }
+ if ($this->isColumnModified(RewritingTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(RewritingTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO rewriting (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'URL':
+ $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR);
+ break;
+ case 'PRODUCT_ID':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case 'CATEGORY_ID':
+ $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT);
+ break;
+ case 'FOLDER_ID':
+ $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT);
+ break;
+ case 'CONTENT_ID':
+ $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = RewritingTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getUrl();
+ break;
+ case 2:
+ return $this->getProductId();
+ break;
+ case 3:
+ return $this->getCategoryId();
+ break;
+ case 4:
+ return $this->getFolderId();
+ break;
+ case 5:
+ return $this->getContentId();
+ break;
+ case 6:
+ return $this->getCreatedAt();
+ break;
+ case 7:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Rewriting'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Rewriting'][$this->getPrimaryKey()] = true;
+ $keys = RewritingTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getUrl(),
+ $keys[2] => $this->getProductId(),
+ $keys[3] => $this->getCategoryId(),
+ $keys[4] => $this->getFolderId(),
+ $keys[5] => $this->getContentId(),
+ $keys[6] => $this->getCreatedAt(),
+ $keys[7] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCategory) {
+ $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aFolder) {
+ $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aContent) {
+ $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = RewritingTableMap::translateFieldName($name, $type, TableMap::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->setUrl($value);
+ break;
+ case 2:
+ $this->setProductId($value);
+ break;
+ case 3:
+ $this->setCategoryId($value);
+ break;
+ case 4:
+ $this->setFolderId($value);
+ break;
+ case 5:
+ $this->setContentId($value);
+ break;
+ case 6:
+ $this->setCreatedAt($value);
+ break;
+ case 7:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = RewritingTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setUrl($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setProductId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setCategoryId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setFolderId($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setContentId($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
+ if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
+ }
+
+ /**
+ * 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(RewritingTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(RewritingTableMap::ID)) $criteria->add(RewritingTableMap::ID, $this->id);
+ if ($this->isColumnModified(RewritingTableMap::URL)) $criteria->add(RewritingTableMap::URL, $this->url);
+ if ($this->isColumnModified(RewritingTableMap::PRODUCT_ID)) $criteria->add(RewritingTableMap::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(RewritingTableMap::CATEGORY_ID)) $criteria->add(RewritingTableMap::CATEGORY_ID, $this->category_id);
+ if ($this->isColumnModified(RewritingTableMap::FOLDER_ID)) $criteria->add(RewritingTableMap::FOLDER_ID, $this->folder_id);
+ if ($this->isColumnModified(RewritingTableMap::CONTENT_ID)) $criteria->add(RewritingTableMap::CONTENT_ID, $this->content_id);
+ if ($this->isColumnModified(RewritingTableMap::CREATED_AT)) $criteria->add(RewritingTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(RewritingTableMap::UPDATED_AT)) $criteria->add(RewritingTableMap::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(RewritingTableMap::DATABASE_NAME);
+ $criteria->add(RewritingTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Rewriting (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setUrl($this->getUrl());
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setCategoryId($this->getCategoryId());
+ $copyObj->setFolderId($this->getFolderId());
+ $copyObj->setContentId($this->getContentId());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\Rewriting 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildProduct object.
+ *
+ * @param ChildProduct $v
+ * @return \Thelia\Model\Rewriting The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(ChildProduct $v = null)
+ {
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
+ }
+
+ $this->aProduct = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildProduct object, it will not be re-added.
+ if ($v !== null) {
+ $v->addRewriting($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildProduct object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildProduct The associated ChildProduct object.
+ * @throws PropelException
+ */
+ public function getProduct(ConnectionInterface $con = null)
+ {
+ if ($this->aProduct === null && ($this->product_id !== null)) {
+ $this->aProduct = ChildProductQuery::create()->findPk($this->product_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aProduct->addRewritings($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCategory object.
+ *
+ * @param ChildCategory $v
+ * @return \Thelia\Model\Rewriting The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCategory(ChildCategory $v = null)
+ {
+ if ($v === null) {
+ $this->setCategoryId(NULL);
+ } else {
+ $this->setCategoryId($v->getId());
+ }
+
+ $this->aCategory = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCategory object, it will not be re-added.
+ if ($v !== null) {
+ $v->addRewriting($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCategory object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCategory The associated ChildCategory object.
+ * @throws PropelException
+ */
+ public function getCategory(ConnectionInterface $con = null)
+ {
+ if ($this->aCategory === null && ($this->category_id !== null)) {
+ $this->aCategory = ChildCategoryQuery::create()->findPk($this->category_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCategory->addRewritings($this);
+ */
+ }
+
+ return $this->aCategory;
+ }
+
+ /**
+ * Declares an association between this object and a ChildFolder object.
+ *
+ * @param ChildFolder $v
+ * @return \Thelia\Model\Rewriting The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setFolder(ChildFolder $v = null)
+ {
+ if ($v === null) {
+ $this->setFolderId(NULL);
+ } else {
+ $this->setFolderId($v->getId());
+ }
+
+ $this->aFolder = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildFolder object, it will not be re-added.
+ if ($v !== null) {
+ $v->addRewriting($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildFolder object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildFolder The associated ChildFolder object.
+ * @throws PropelException
+ */
+ public function getFolder(ConnectionInterface $con = null)
+ {
+ if ($this->aFolder === null && ($this->folder_id !== null)) {
+ $this->aFolder = ChildFolderQuery::create()->findPk($this->folder_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aFolder->addRewritings($this);
+ */
+ }
+
+ return $this->aFolder;
+ }
+
+ /**
+ * Declares an association between this object and a ChildContent object.
+ *
+ * @param ChildContent $v
+ * @return \Thelia\Model\Rewriting The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setContent(ChildContent $v = null)
+ {
+ if ($v === null) {
+ $this->setContentId(NULL);
+ } else {
+ $this->setContentId($v->getId());
+ }
+
+ $this->aContent = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildContent object, it will not be re-added.
+ if ($v !== null) {
+ $v->addRewriting($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildContent object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildContent The associated ChildContent object.
+ * @throws PropelException
+ */
+ public function getContent(ConnectionInterface $con = null)
+ {
+ if ($this->aContent === null && ($this->content_id !== null)) {
+ $this->aContent = ChildContentQuery::create()->findPk($this->content_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aContent->addRewritings($this);
+ */
+ }
+
+ return $this->aContent;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->url = null;
+ $this->product_id = null;
+ $this->category_id = null;
+ $this->folder_id = null;
+ $this->content_id = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aProduct = null;
+ $this->aCategory = null;
+ $this->aFolder = null;
+ $this->aContent = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(RewritingTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildRewriting The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = RewritingTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/RewritingQuery.php b/core/lib/Thelia/Model/Base/RewritingQuery.php
new file mode 100644
index 000000000..bf814cfd2
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/RewritingQuery.php
@@ -0,0 +1,1044 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildRewriting|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = RewritingTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(RewritingTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildRewriting A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, URL, PRODUCT_ID, CATEGORY_ID, FOLDER_ID, CONTENT_ID, CREATED_AT, UPDATED_AT FROM rewriting WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildRewriting();
+ $obj->hydrate($row);
+ RewritingTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildRewriting|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(RewritingTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(RewritingTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(RewritingTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(RewritingTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the url column
+ *
+ * Example usage:
+ *
+ * $query->filterByUrl('fooValue'); // WHERE url = 'fooValue'
+ * $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%'
+ *
+ *
+ * @param string $url The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function filterByUrl($url = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($url)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $url)) {
+ $url = str_replace('*', '%', $url);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingTableMap::URL, $url, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(RewritingTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(RewritingTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingTableMap::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the category_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCategoryId(1234); // WHERE category_id = 1234
+ * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34)
+ * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12
+ *
+ *
+ * @see filterByCategory()
+ *
+ * @param mixed $categoryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function filterByCategoryId($categoryId = null, $comparison = null)
+ {
+ if (is_array($categoryId)) {
+ $useMinMax = false;
+ if (isset($categoryId['min'])) {
+ $this->addUsingAlias(RewritingTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($categoryId['max'])) {
+ $this->addUsingAlias(RewritingTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingTableMap::CATEGORY_ID, $categoryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the folder_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByFolderId(1234); // WHERE folder_id = 1234
+ * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34)
+ * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12
+ *
+ *
+ * @see filterByFolder()
+ *
+ * @param mixed $folderId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function filterByFolderId($folderId = null, $comparison = null)
+ {
+ if (is_array($folderId)) {
+ $useMinMax = false;
+ if (isset($folderId['min'])) {
+ $this->addUsingAlias(RewritingTableMap::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($folderId['max'])) {
+ $this->addUsingAlias(RewritingTableMap::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingTableMap::FOLDER_ID, $folderId, $comparison);
+ }
+
+ /**
+ * Filter the query on the content_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByContentId(1234); // WHERE content_id = 1234
+ * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34)
+ * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12
+ *
+ *
+ * @see filterByContent()
+ *
+ * @param mixed $contentId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function filterByContentId($contentId = null, $comparison = null)
+ {
+ if (is_array($contentId)) {
+ $useMinMax = false;
+ if (isset($contentId['min'])) {
+ $this->addUsingAlias(RewritingTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($contentId['max'])) {
+ $this->addUsingAlias(RewritingTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingTableMap::CONTENT_ID, $contentId, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(RewritingTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(RewritingTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(RewritingTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(RewritingTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(RewritingTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Product object
+ *
+ * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function filterByProduct($product, $comparison = null)
+ {
+ if ($product instanceof \Thelia\Model\Product) {
+ return $this
+ ->addUsingAlias(RewritingTableMap::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(RewritingTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Product relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Product');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Product');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Product relation Product object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
+ */
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Category object
+ *
+ * @param \Thelia\Model\Category|ObjectCollection $category The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function filterByCategory($category, $comparison = null)
+ {
+ if ($category instanceof \Thelia\Model\Category) {
+ return $this
+ ->addUsingAlias(RewritingTableMap::CATEGORY_ID, $category->getId(), $comparison);
+ } elseif ($category instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(RewritingTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Category relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Category');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Category');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Category relation Category object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query
+ */
+ public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCategory($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Folder object
+ *
+ * @param \Thelia\Model\Folder|ObjectCollection $folder The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function filterByFolder($folder, $comparison = null)
+ {
+ if ($folder instanceof \Thelia\Model\Folder) {
+ return $this
+ ->addUsingAlias(RewritingTableMap::FOLDER_ID, $folder->getId(), $comparison);
+ } elseif ($folder instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(RewritingTableMap::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Folder relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Folder');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Folder');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Folder relation Folder object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query
+ */
+ public function useFolderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinFolder($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Content object
+ *
+ * @param \Thelia\Model\Content|ObjectCollection $content The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function filterByContent($content, $comparison = null)
+ {
+ if ($content instanceof \Thelia\Model\Content) {
+ return $this
+ ->addUsingAlias(RewritingTableMap::CONTENT_ID, $content->getId(), $comparison);
+ } elseif ($content instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(RewritingTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Content relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Content');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Content');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Content relation Content object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query
+ */
+ public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinContent($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildRewriting $rewriting Object to remove from the list of results
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function prune($rewriting = null)
+ {
+ if ($rewriting) {
+ $this->addUsingAlias(RewritingTableMap::ID, $rewriting->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the rewriting table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ RewritingTableMap::clearInstancePool();
+ RewritingTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildRewriting or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildRewriting object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(RewritingTableMap::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->beginTransaction();
+
+
+ RewritingTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ RewritingTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(RewritingTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(RewritingTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(RewritingTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(RewritingTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(RewritingTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildRewritingQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(RewritingTableMap::CREATED_AT);
+ }
+
+} // RewritingQuery
diff --git a/core/lib/Thelia/Model/Base/Stock.php b/core/lib/Thelia/Model/Base/Stock.php
new file mode 100644
index 000000000..6594c845c
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Stock.php
@@ -0,0 +1,1611 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Stock instance. If
+ * obj is an instance of Stock, delegates to
+ * equals(Stock). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Stock The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Stock The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [combination_id] column value.
+ *
+ * @return int
+ */
+ public function getCombinationId()
+ {
+
+ return $this->combination_id;
+ }
+
+ /**
+ * Get the [product_id] column value.
+ *
+ * @return int
+ */
+ public function getProductId()
+ {
+
+ return $this->product_id;
+ }
+
+ /**
+ * Get the [increase] column value.
+ *
+ * @return double
+ */
+ public function getIncrease()
+ {
+
+ return $this->increase;
+ }
+
+ /**
+ * Get the [value] column value.
+ *
+ * @return double
+ */
+ public function getValue()
+ {
+
+ return $this->value;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Stock The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = StockTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [combination_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Stock The current object (for fluent API support)
+ */
+ public function setCombinationId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->combination_id !== $v) {
+ $this->combination_id = $v;
+ $this->modifiedColumns[] = StockTableMap::COMBINATION_ID;
+ }
+
+ if ($this->aCombination !== null && $this->aCombination->getId() !== $v) {
+ $this->aCombination = null;
+ }
+
+
+ return $this;
+ } // setCombinationId()
+
+ /**
+ * Set the value of [product_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Stock The current object (for fluent API support)
+ */
+ public function setProductId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->product_id !== $v) {
+ $this->product_id = $v;
+ $this->modifiedColumns[] = StockTableMap::PRODUCT_ID;
+ }
+
+ if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
+ $this->aProduct = null;
+ }
+
+
+ return $this;
+ } // setProductId()
+
+ /**
+ * Set the value of [increase] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\Stock The current object (for fluent API support)
+ */
+ public function setIncrease($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->increase !== $v) {
+ $this->increase = $v;
+ $this->modifiedColumns[] = StockTableMap::INCREASE;
+ }
+
+
+ return $this;
+ } // setIncrease()
+
+ /**
+ * Set the value of [value] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\Stock The current object (for fluent API support)
+ */
+ public function setValue($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->value !== $v) {
+ $this->value = $v;
+ $this->modifiedColumns[] = StockTableMap::VALUE;
+ }
+
+
+ return $this;
+ } // setValue()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Stock The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = StockTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Stock The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = StockTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : StockTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : StockTableMap::translateFieldName('CombinationId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->combination_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : StockTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->product_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : StockTableMap::translateFieldName('Increase', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->increase = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : StockTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->value = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : StockTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : StockTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = StockTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Stock object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aCombination !== null && $this->combination_id !== $this->aCombination->getId()) {
+ $this->aCombination = null;
+ }
+ if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) {
+ $this->aProduct = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(StockTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildStockQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aCombination = null;
+ $this->aProduct = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Stock::setDeleted()
+ * @see Stock::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildStockQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(StockTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(StockTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(StockTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ StockTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aCombination !== null) {
+ if ($this->aCombination->isModified() || $this->aCombination->isNew()) {
+ $affectedRows += $this->aCombination->save($con);
+ }
+ $this->setCombination($this->aCombination);
+ }
+
+ if ($this->aProduct !== null) {
+ if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
+ $affectedRows += $this->aProduct->save($con);
+ }
+ $this->setProduct($this->aProduct);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = StockTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . StockTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(StockTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(StockTableMap::COMBINATION_ID)) {
+ $modifiedColumns[':p' . $index++] = 'COMBINATION_ID';
+ }
+ if ($this->isColumnModified(StockTableMap::PRODUCT_ID)) {
+ $modifiedColumns[':p' . $index++] = 'PRODUCT_ID';
+ }
+ if ($this->isColumnModified(StockTableMap::INCREASE)) {
+ $modifiedColumns[':p' . $index++] = 'INCREASE';
+ }
+ if ($this->isColumnModified(StockTableMap::VALUE)) {
+ $modifiedColumns[':p' . $index++] = 'VALUE';
+ }
+ if ($this->isColumnModified(StockTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(StockTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO stock (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'COMBINATION_ID':
+ $stmt->bindValue($identifier, $this->combination_id, PDO::PARAM_INT);
+ break;
+ case 'PRODUCT_ID':
+ $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
+ break;
+ case 'INCREASE':
+ $stmt->bindValue($identifier, $this->increase, PDO::PARAM_STR);
+ break;
+ case 'VALUE':
+ $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = StockTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getCombinationId();
+ break;
+ case 2:
+ return $this->getProductId();
+ break;
+ case 3:
+ return $this->getIncrease();
+ break;
+ case 4:
+ return $this->getValue();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Stock'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Stock'][$this->getPrimaryKey()] = true;
+ $keys = StockTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCombinationId(),
+ $keys[2] => $this->getProductId(),
+ $keys[3] => $this->getIncrease(),
+ $keys[4] => $this->getValue(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aCombination) {
+ $result['Combination'] = $this->aCombination->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aProduct) {
+ $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = StockTableMap::translateFieldName($name, $type, TableMap::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->setCombinationId($value);
+ break;
+ case 2:
+ $this->setProductId($value);
+ break;
+ case 3:
+ $this->setIncrease($value);
+ break;
+ case 4:
+ $this->setValue($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = StockTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCombinationId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setProductId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setIncrease($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setValue($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * 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(StockTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(StockTableMap::ID)) $criteria->add(StockTableMap::ID, $this->id);
+ if ($this->isColumnModified(StockTableMap::COMBINATION_ID)) $criteria->add(StockTableMap::COMBINATION_ID, $this->combination_id);
+ if ($this->isColumnModified(StockTableMap::PRODUCT_ID)) $criteria->add(StockTableMap::PRODUCT_ID, $this->product_id);
+ if ($this->isColumnModified(StockTableMap::INCREASE)) $criteria->add(StockTableMap::INCREASE, $this->increase);
+ if ($this->isColumnModified(StockTableMap::VALUE)) $criteria->add(StockTableMap::VALUE, $this->value);
+ if ($this->isColumnModified(StockTableMap::CREATED_AT)) $criteria->add(StockTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(StockTableMap::UPDATED_AT)) $criteria->add(StockTableMap::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(StockTableMap::DATABASE_NAME);
+ $criteria->add(StockTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Stock (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCombinationId($this->getCombinationId());
+ $copyObj->setProductId($this->getProductId());
+ $copyObj->setIncrease($this->getIncrease());
+ $copyObj->setValue($this->getValue());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Stock 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCombination object.
+ *
+ * @param ChildCombination $v
+ * @return \Thelia\Model\Stock The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCombination(ChildCombination $v = null)
+ {
+ if ($v === null) {
+ $this->setCombinationId(NULL);
+ } else {
+ $this->setCombinationId($v->getId());
+ }
+
+ $this->aCombination = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCombination object, it will not be re-added.
+ if ($v !== null) {
+ $v->addStock($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCombination object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCombination The associated ChildCombination object.
+ * @throws PropelException
+ */
+ public function getCombination(ConnectionInterface $con = null)
+ {
+ if ($this->aCombination === null && ($this->combination_id !== null)) {
+ $this->aCombination = ChildCombinationQuery::create()->findPk($this->combination_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCombination->addStocks($this);
+ */
+ }
+
+ return $this->aCombination;
+ }
+
+ /**
+ * Declares an association between this object and a ChildProduct object.
+ *
+ * @param ChildProduct $v
+ * @return \Thelia\Model\Stock The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setProduct(ChildProduct $v = null)
+ {
+ if ($v === null) {
+ $this->setProductId(NULL);
+ } else {
+ $this->setProductId($v->getId());
+ }
+
+ $this->aProduct = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildProduct object, it will not be re-added.
+ if ($v !== null) {
+ $v->addStock($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildProduct object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildProduct The associated ChildProduct object.
+ * @throws PropelException
+ */
+ public function getProduct(ConnectionInterface $con = null)
+ {
+ if ($this->aProduct === null && ($this->product_id !== null)) {
+ $this->aProduct = ChildProductQuery::create()->findPk($this->product_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aProduct->addStocks($this);
+ */
+ }
+
+ return $this->aProduct;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->combination_id = null;
+ $this->product_id = null;
+ $this->increase = null;
+ $this->value = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aCombination = null;
+ $this->aProduct = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(StockTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildStock The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = StockTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/StockQuery.php b/core/lib/Thelia/Model/Base/StockQuery.php
new file mode 100644
index 000000000..787543d4b
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/StockQuery.php
@@ -0,0 +1,849 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildStock|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = StockTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(StockTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildStock A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, COMBINATION_ID, PRODUCT_ID, INCREASE, VALUE, CREATED_AT, UPDATED_AT FROM stock WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildStock();
+ $obj->hydrate($row);
+ StockTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildStock|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(StockTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(StockTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(StockTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(StockTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(StockTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the combination_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCombinationId(1234); // WHERE combination_id = 1234
+ * $query->filterByCombinationId(array(12, 34)); // WHERE combination_id IN (12, 34)
+ * $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id > 12
+ *
+ *
+ * @see filterByCombination()
+ *
+ * @param mixed $combinationId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function filterByCombinationId($combinationId = null, $comparison = null)
+ {
+ if (is_array($combinationId)) {
+ $useMinMax = false;
+ if (isset($combinationId['min'])) {
+ $this->addUsingAlias(StockTableMap::COMBINATION_ID, $combinationId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($combinationId['max'])) {
+ $this->addUsingAlias(StockTableMap::COMBINATION_ID, $combinationId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(StockTableMap::COMBINATION_ID, $combinationId, $comparison);
+ }
+
+ /**
+ * Filter the query on the product_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByProductId(1234); // WHERE product_id = 1234
+ * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34)
+ * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12
+ *
+ *
+ * @see filterByProduct()
+ *
+ * @param mixed $productId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function filterByProductId($productId = null, $comparison = null)
+ {
+ if (is_array($productId)) {
+ $useMinMax = false;
+ if (isset($productId['min'])) {
+ $this->addUsingAlias(StockTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($productId['max'])) {
+ $this->addUsingAlias(StockTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(StockTableMap::PRODUCT_ID, $productId, $comparison);
+ }
+
+ /**
+ * Filter the query on the increase column
+ *
+ * Example usage:
+ *
+ * $query->filterByIncrease(1234); // WHERE increase = 1234
+ * $query->filterByIncrease(array(12, 34)); // WHERE increase IN (12, 34)
+ * $query->filterByIncrease(array('min' => 12)); // WHERE increase > 12
+ *
+ *
+ * @param mixed $increase The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function filterByIncrease($increase = null, $comparison = null)
+ {
+ if (is_array($increase)) {
+ $useMinMax = false;
+ if (isset($increase['min'])) {
+ $this->addUsingAlias(StockTableMap::INCREASE, $increase['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($increase['max'])) {
+ $this->addUsingAlias(StockTableMap::INCREASE, $increase['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(StockTableMap::INCREASE, $increase, $comparison);
+ }
+
+ /**
+ * Filter the query on the value column
+ *
+ * Example usage:
+ *
+ * $query->filterByValue(1234); // WHERE value = 1234
+ * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34)
+ * $query->filterByValue(array('min' => 12)); // WHERE value > 12
+ *
+ *
+ * @param mixed $value The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function filterByValue($value = null, $comparison = null)
+ {
+ if (is_array($value)) {
+ $useMinMax = false;
+ if (isset($value['min'])) {
+ $this->addUsingAlias(StockTableMap::VALUE, $value['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($value['max'])) {
+ $this->addUsingAlias(StockTableMap::VALUE, $value['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(StockTableMap::VALUE, $value, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(StockTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(StockTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(StockTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(StockTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(StockTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(StockTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Combination object
+ *
+ * @param \Thelia\Model\Combination|ObjectCollection $combination The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function filterByCombination($combination, $comparison = null)
+ {
+ if ($combination instanceof \Thelia\Model\Combination) {
+ return $this
+ ->addUsingAlias(StockTableMap::COMBINATION_ID, $combination->getId(), $comparison);
+ } elseif ($combination instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(StockTableMap::COMBINATION_ID, $combination->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCombination() only accepts arguments of type \Thelia\Model\Combination or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Combination relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function joinCombination($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Combination');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Combination');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Combination relation Combination object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CombinationQuery A secondary query class using the current class as primary query
+ */
+ public function useCombinationQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCombination($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Combination', '\Thelia\Model\CombinationQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Product object
+ *
+ * @param \Thelia\Model\Product|ObjectCollection $product The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function filterByProduct($product, $comparison = null)
+ {
+ if ($product instanceof \Thelia\Model\Product) {
+ return $this
+ ->addUsingAlias(StockTableMap::PRODUCT_ID, $product->getId(), $comparison);
+ } elseif ($product instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(StockTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Product relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Product');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Product');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Product relation Product object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
+ */
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
+ {
+ return $this
+ ->joinProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildStock $stock Object to remove from the list of results
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function prune($stock = null)
+ {
+ if ($stock) {
+ $this->addUsingAlias(StockTableMap::ID, $stock->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the stock table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ StockTableMap::clearInstancePool();
+ StockTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildStock or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildStock object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(StockTableMap::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->beginTransaction();
+
+
+ StockTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ StockTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(StockTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(StockTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(StockTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(StockTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(StockTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildStockQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(StockTableMap::CREATED_AT);
+ }
+
+} // StockQuery
diff --git a/core/lib/Thelia/Model/Base/Tax.php b/core/lib/Thelia/Model/Base/Tax.php
new file mode 100644
index 000000000..f3717366f
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/Tax.php
@@ -0,0 +1,2067 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another Tax instance. If
+ * obj is an instance of Tax, delegates to
+ * equals(Tax). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return Tax The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return Tax The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [rate] column value.
+ *
+ * @return double
+ */
+ public function getRate()
+ {
+
+ return $this->rate;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\Tax The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = TaxTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [rate] column.
+ *
+ * @param double $v new value
+ * @return \Thelia\Model\Tax The current object (for fluent API support)
+ */
+ public function setRate($v)
+ {
+ if ($v !== null) {
+ $v = (double) $v;
+ }
+
+ if ($this->rate !== $v) {
+ $this->rate = $v;
+ $this->modifiedColumns[] = TaxTableMap::RATE;
+ }
+
+
+ return $this;
+ } // setRate()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Tax The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = TaxTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\Tax The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = TaxTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxTableMap::translateFieldName('Rate', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->rate = (null !== $col) ? (double) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = TaxTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\Tax object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(TaxTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildTaxQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collTaxRuleCountries = null;
+
+ $this->collTaxI18ns = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see Tax::setDeleted()
+ * @see Tax::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildTaxQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(TaxTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(TaxTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(TaxTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ TaxTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->taxRuleCountriesScheduledForDeletion !== null) {
+ if (!$this->taxRuleCountriesScheduledForDeletion->isEmpty()) {
+ foreach ($this->taxRuleCountriesScheduledForDeletion as $taxRuleCountry) {
+ // need to save related object because we set the relation to null
+ $taxRuleCountry->save($con);
+ }
+ $this->taxRuleCountriesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collTaxRuleCountries !== null) {
+ foreach ($this->collTaxRuleCountries as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->taxI18nsScheduledForDeletion !== null) {
+ if (!$this->taxI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\TaxI18nQuery::create()
+ ->filterByPrimaryKeys($this->taxI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->taxI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collTaxI18ns !== null) {
+ foreach ($this->collTaxI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = TaxTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . TaxTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(TaxTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(TaxTableMap::RATE)) {
+ $modifiedColumns[':p' . $index++] = 'RATE';
+ }
+ if ($this->isColumnModified(TaxTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(TaxTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO tax (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'RATE':
+ $stmt->bindValue($identifier, $this->rate, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = TaxTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getRate();
+ break;
+ case 2:
+ return $this->getCreatedAt();
+ break;
+ case 3:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['Tax'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['Tax'][$this->getPrimaryKey()] = true;
+ $keys = TaxTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getRate(),
+ $keys[2] => $this->getCreatedAt(),
+ $keys[3] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collTaxRuleCountries) {
+ $result['TaxRuleCountries'] = $this->collTaxRuleCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collTaxI18ns) {
+ $result['TaxI18ns'] = $this->collTaxI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = TaxTableMap::translateFieldName($name, $type, TableMap::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->setRate($value);
+ break;
+ case 2:
+ $this->setCreatedAt($value);
+ break;
+ case 3:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = TaxTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setRate($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
+ }
+
+ /**
+ * 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(TaxTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(TaxTableMap::ID)) $criteria->add(TaxTableMap::ID, $this->id);
+ if ($this->isColumnModified(TaxTableMap::RATE)) $criteria->add(TaxTableMap::RATE, $this->rate);
+ if ($this->isColumnModified(TaxTableMap::CREATED_AT)) $criteria->add(TaxTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(TaxTableMap::UPDATED_AT)) $criteria->add(TaxTableMap::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(TaxTableMap::DATABASE_NAME);
+ $criteria->add(TaxTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\Tax (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setRate($this->getRate());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getTaxRuleCountries() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addTaxRuleCountry($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getTaxI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addTaxI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\Tax 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('TaxRuleCountry' == $relationName) {
+ return $this->initTaxRuleCountries();
+ }
+ if ('TaxI18n' == $relationName) {
+ return $this->initTaxI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collTaxRuleCountries collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addTaxRuleCountries()
+ */
+ public function clearTaxRuleCountries()
+ {
+ $this->collTaxRuleCountries = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collTaxRuleCountries collection loaded partially.
+ */
+ public function resetPartialTaxRuleCountries($v = true)
+ {
+ $this->collTaxRuleCountriesPartial = $v;
+ }
+
+ /**
+ * Initializes the collTaxRuleCountries collection.
+ *
+ * By default this just sets the collTaxRuleCountries collection to an empty array (like clearcollTaxRuleCountries());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initTaxRuleCountries($overrideExisting = true)
+ {
+ if (null !== $this->collTaxRuleCountries && !$overrideExisting) {
+ return;
+ }
+ $this->collTaxRuleCountries = new ObjectCollection();
+ $this->collTaxRuleCountries->setModel('\Thelia\Model\TaxRuleCountry');
+ }
+
+ /**
+ * Gets an array of ChildTaxRuleCountry objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildTax is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects
+ * @throws PropelException
+ */
+ public function getTaxRuleCountries($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collTaxRuleCountriesPartial && !$this->isNew();
+ if (null === $this->collTaxRuleCountries || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleCountries) {
+ // return empty collection
+ $this->initTaxRuleCountries();
+ } else {
+ $collTaxRuleCountries = ChildTaxRuleCountryQuery::create(null, $criteria)
+ ->filterByTax($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collTaxRuleCountriesPartial && count($collTaxRuleCountries)) {
+ $this->initTaxRuleCountries(false);
+
+ foreach ($collTaxRuleCountries as $obj) {
+ if (false == $this->collTaxRuleCountries->contains($obj)) {
+ $this->collTaxRuleCountries->append($obj);
+ }
+ }
+
+ $this->collTaxRuleCountriesPartial = true;
+ }
+
+ $collTaxRuleCountries->getInternalIterator()->rewind();
+
+ return $collTaxRuleCountries;
+ }
+
+ if ($partial && $this->collTaxRuleCountries) {
+ foreach ($this->collTaxRuleCountries as $obj) {
+ if ($obj->isNew()) {
+ $collTaxRuleCountries[] = $obj;
+ }
+ }
+ }
+
+ $this->collTaxRuleCountries = $collTaxRuleCountries;
+ $this->collTaxRuleCountriesPartial = false;
+ }
+ }
+
+ return $this->collTaxRuleCountries;
+ }
+
+ /**
+ * Sets a collection of TaxRuleCountry objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $taxRuleCountries A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildTax The current object (for fluent API support)
+ */
+ public function setTaxRuleCountries(Collection $taxRuleCountries, ConnectionInterface $con = null)
+ {
+ $taxRuleCountriesToDelete = $this->getTaxRuleCountries(new Criteria(), $con)->diff($taxRuleCountries);
+
+
+ $this->taxRuleCountriesScheduledForDeletion = $taxRuleCountriesToDelete;
+
+ foreach ($taxRuleCountriesToDelete as $taxRuleCountryRemoved) {
+ $taxRuleCountryRemoved->setTax(null);
+ }
+
+ $this->collTaxRuleCountries = null;
+ foreach ($taxRuleCountries as $taxRuleCountry) {
+ $this->addTaxRuleCountry($taxRuleCountry);
+ }
+
+ $this->collTaxRuleCountries = $taxRuleCountries;
+ $this->collTaxRuleCountriesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related TaxRuleCountry objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related TaxRuleCountry objects.
+ * @throws PropelException
+ */
+ public function countTaxRuleCountries(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collTaxRuleCountriesPartial && !$this->isNew();
+ if (null === $this->collTaxRuleCountries || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleCountries) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getTaxRuleCountries());
+ }
+
+ $query = ChildTaxRuleCountryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByTax($this)
+ ->count($con);
+ }
+
+ return count($this->collTaxRuleCountries);
+ }
+
+ /**
+ * Method called to associate a ChildTaxRuleCountry object to this object
+ * through the ChildTaxRuleCountry foreign key attribute.
+ *
+ * @param ChildTaxRuleCountry $l ChildTaxRuleCountry
+ * @return \Thelia\Model\Tax The current object (for fluent API support)
+ */
+ public function addTaxRuleCountry(ChildTaxRuleCountry $l)
+ {
+ if ($this->collTaxRuleCountries === null) {
+ $this->initTaxRuleCountries();
+ $this->collTaxRuleCountriesPartial = true;
+ }
+
+ if (!in_array($l, $this->collTaxRuleCountries->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddTaxRuleCountry($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add.
+ */
+ protected function doAddTaxRuleCountry($taxRuleCountry)
+ {
+ $this->collTaxRuleCountries[]= $taxRuleCountry;
+ $taxRuleCountry->setTax($this);
+ }
+
+ /**
+ * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove.
+ * @return ChildTax The current object (for fluent API support)
+ */
+ public function removeTaxRuleCountry($taxRuleCountry)
+ {
+ if ($this->getTaxRuleCountries()->contains($taxRuleCountry)) {
+ $this->collTaxRuleCountries->remove($this->collTaxRuleCountries->search($taxRuleCountry));
+ if (null === $this->taxRuleCountriesScheduledForDeletion) {
+ $this->taxRuleCountriesScheduledForDeletion = clone $this->collTaxRuleCountries;
+ $this->taxRuleCountriesScheduledForDeletion->clear();
+ }
+ $this->taxRuleCountriesScheduledForDeletion[]= $taxRuleCountry;
+ $taxRuleCountry->setTax(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Tax is new, it will return
+ * an empty collection; or if this Tax has previously
+ * been saved, it will retrieve related TaxRuleCountries 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 Tax.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects
+ */
+ public function getTaxRuleCountriesJoinTaxRule($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildTaxRuleCountryQuery::create(null, $criteria);
+ $query->joinWith('TaxRule', $joinBehavior);
+
+ return $this->getTaxRuleCountries($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this Tax is new, it will return
+ * an empty collection; or if this Tax has previously
+ * been saved, it will retrieve related TaxRuleCountries 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 Tax.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects
+ */
+ public function getTaxRuleCountriesJoinCountry($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildTaxRuleCountryQuery::create(null, $criteria);
+ $query->joinWith('Country', $joinBehavior);
+
+ return $this->getTaxRuleCountries($query, $con);
+ }
+
+ /**
+ * Clears out the collTaxI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addTaxI18ns()
+ */
+ public function clearTaxI18ns()
+ {
+ $this->collTaxI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collTaxI18ns collection loaded partially.
+ */
+ public function resetPartialTaxI18ns($v = true)
+ {
+ $this->collTaxI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collTaxI18ns collection.
+ *
+ * By default this just sets the collTaxI18ns collection to an empty array (like clearcollTaxI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initTaxI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collTaxI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collTaxI18ns = new ObjectCollection();
+ $this->collTaxI18ns->setModel('\Thelia\Model\TaxI18n');
+ }
+
+ /**
+ * Gets an array of ChildTaxI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildTax is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildTaxI18n[] List of ChildTaxI18n objects
+ * @throws PropelException
+ */
+ public function getTaxI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collTaxI18nsPartial && !$this->isNew();
+ if (null === $this->collTaxI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxI18ns) {
+ // return empty collection
+ $this->initTaxI18ns();
+ } else {
+ $collTaxI18ns = ChildTaxI18nQuery::create(null, $criteria)
+ ->filterByTax($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collTaxI18nsPartial && count($collTaxI18ns)) {
+ $this->initTaxI18ns(false);
+
+ foreach ($collTaxI18ns as $obj) {
+ if (false == $this->collTaxI18ns->contains($obj)) {
+ $this->collTaxI18ns->append($obj);
+ }
+ }
+
+ $this->collTaxI18nsPartial = true;
+ }
+
+ $collTaxI18ns->getInternalIterator()->rewind();
+
+ return $collTaxI18ns;
+ }
+
+ if ($partial && $this->collTaxI18ns) {
+ foreach ($this->collTaxI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collTaxI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collTaxI18ns = $collTaxI18ns;
+ $this->collTaxI18nsPartial = false;
+ }
+ }
+
+ return $this->collTaxI18ns;
+ }
+
+ /**
+ * Sets a collection of TaxI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $taxI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildTax The current object (for fluent API support)
+ */
+ public function setTaxI18ns(Collection $taxI18ns, ConnectionInterface $con = null)
+ {
+ $taxI18nsToDelete = $this->getTaxI18ns(new Criteria(), $con)->diff($taxI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->taxI18nsScheduledForDeletion = clone $taxI18nsToDelete;
+
+ foreach ($taxI18nsToDelete as $taxI18nRemoved) {
+ $taxI18nRemoved->setTax(null);
+ }
+
+ $this->collTaxI18ns = null;
+ foreach ($taxI18ns as $taxI18n) {
+ $this->addTaxI18n($taxI18n);
+ }
+
+ $this->collTaxI18ns = $taxI18ns;
+ $this->collTaxI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related TaxI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related TaxI18n objects.
+ * @throws PropelException
+ */
+ public function countTaxI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collTaxI18nsPartial && !$this->isNew();
+ if (null === $this->collTaxI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getTaxI18ns());
+ }
+
+ $query = ChildTaxI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByTax($this)
+ ->count($con);
+ }
+
+ return count($this->collTaxI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildTaxI18n object to this object
+ * through the ChildTaxI18n foreign key attribute.
+ *
+ * @param ChildTaxI18n $l ChildTaxI18n
+ * @return \Thelia\Model\Tax The current object (for fluent API support)
+ */
+ public function addTaxI18n(ChildTaxI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collTaxI18ns === null) {
+ $this->initTaxI18ns();
+ $this->collTaxI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collTaxI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddTaxI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param TaxI18n $taxI18n The taxI18n object to add.
+ */
+ protected function doAddTaxI18n($taxI18n)
+ {
+ $this->collTaxI18ns[]= $taxI18n;
+ $taxI18n->setTax($this);
+ }
+
+ /**
+ * @param TaxI18n $taxI18n The taxI18n object to remove.
+ * @return ChildTax The current object (for fluent API support)
+ */
+ public function removeTaxI18n($taxI18n)
+ {
+ if ($this->getTaxI18ns()->contains($taxI18n)) {
+ $this->collTaxI18ns->remove($this->collTaxI18ns->search($taxI18n));
+ if (null === $this->taxI18nsScheduledForDeletion) {
+ $this->taxI18nsScheduledForDeletion = clone $this->collTaxI18ns;
+ $this->taxI18nsScheduledForDeletion->clear();
+ }
+ $this->taxI18nsScheduledForDeletion[]= clone $taxI18n;
+ $taxI18n->setTax(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->rate = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collTaxRuleCountries) {
+ foreach ($this->collTaxRuleCountries as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collTaxI18ns) {
+ foreach ($this->collTaxI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collTaxRuleCountries instanceof Collection) {
+ $this->collTaxRuleCountries->clearIterator();
+ }
+ $this->collTaxRuleCountries = null;
+ if ($this->collTaxI18ns instanceof Collection) {
+ $this->collTaxI18ns->clearIterator();
+ }
+ $this->collTaxI18ns = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(TaxTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildTax The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = TaxTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildTax The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildTaxI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collTaxI18ns) {
+ foreach ($this->collTaxI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildTaxI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildTaxI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addTaxI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildTax The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildTaxI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collTaxI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collTaxI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildTaxI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->getCurrentTranslation()->getTitle();
+ }
+
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\TaxI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ { $this->getCurrentTranslation()->setTitle($v);
+
+ return $this;
+ }
+
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->getCurrentTranslation()->getDescription();
+ }
+
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\TaxI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ { $this->getCurrentTranslation()->setDescription($v);
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/TaxI18n.php b/core/lib/Thelia/Model/Base/TaxI18n.php
new file mode 100644
index 000000000..8fdec086d
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/TaxI18n.php
@@ -0,0 +1,1323 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\TaxI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another TaxI18n instance. If
+ * obj is an instance of TaxI18n, delegates to
+ * equals(TaxI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return TaxI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return TaxI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\TaxI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = TaxI18nTableMap::ID;
+ }
+
+ if ($this->aTax !== null && $this->aTax->getId() !== $v) {
+ $this->aTax = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\TaxI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = TaxI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\TaxI18n The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = TaxI18nTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\TaxI18n The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = TaxI18nTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 4; // 4 = TaxI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\TaxI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aTax !== null && $this->id !== $this->aTax->getId()) {
+ $this->aTax = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(TaxI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildTaxI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aTax = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see TaxI18n::setDeleted()
+ * @see TaxI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildTaxI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ TaxI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aTax !== null) {
+ if ($this->aTax->isModified() || $this->aTax->isNew()) {
+ $affectedRows += $this->aTax->save($con);
+ }
+ $this->setTax($this->aTax);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(TaxI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(TaxI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+ if ($this->isColumnModified(TaxI18nTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(TaxI18nTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO tax_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = TaxI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['TaxI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['TaxI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = TaxI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aTax) {
+ $result['Tax'] = $this->aTax->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = TaxI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = TaxI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ }
+
+ /**
+ * 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(TaxI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(TaxI18nTableMap::ID)) $criteria->add(TaxI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(TaxI18nTableMap::LOCALE)) $criteria->add(TaxI18nTableMap::LOCALE, $this->locale);
+ if ($this->isColumnModified(TaxI18nTableMap::TITLE)) $criteria->add(TaxI18nTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(TaxI18nTableMap::DESCRIPTION)) $criteria->add(TaxI18nTableMap::DESCRIPTION, $this->description);
+
+ 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(TaxI18nTableMap::DATABASE_NAME);
+ $criteria->add(TaxI18nTableMap::ID, $this->id);
+ $criteria->add(TaxI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\TaxI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\TaxI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildTax object.
+ *
+ * @param ChildTax $v
+ * @return \Thelia\Model\TaxI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setTax(ChildTax $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aTax = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildTax object, it will not be re-added.
+ if ($v !== null) {
+ $v->addTaxI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildTax object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildTax The associated ChildTax object.
+ * @throws PropelException
+ */
+ public function getTax(ConnectionInterface $con = null)
+ {
+ if ($this->aTax === null && ($this->id !== null)) {
+ $this->aTax = ChildTaxQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aTax->addTaxI18ns($this);
+ */
+ }
+
+ return $this->aTax;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->title = null;
+ $this->description = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aTax = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(TaxI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/TaxI18nQuery.php b/core/lib/Thelia/Model/Base/TaxI18nQuery.php
new file mode 100644
index 000000000..e23b36155
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/TaxI18nQuery.php
@@ -0,0 +1,541 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildTaxI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = TaxI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(TaxI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildTaxI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION FROM tax_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildTaxI18n();
+ $obj->hydrate($row);
+ TaxI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildTaxI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildTaxI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(TaxI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(TaxI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildTaxI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(TaxI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(TaxI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByTax()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(TaxI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(TaxI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxI18nQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxI18nTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxI18nQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxI18nTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Tax object
+ *
+ * @param \Thelia\Model\Tax|ObjectCollection $tax The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxI18nQuery The current query, for fluid interface
+ */
+ public function filterByTax($tax, $comparison = null)
+ {
+ if ($tax instanceof \Thelia\Model\Tax) {
+ return $this
+ ->addUsingAlias(TaxI18nTableMap::ID, $tax->getId(), $comparison);
+ } elseif ($tax instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(TaxI18nTableMap::ID, $tax->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByTax() only accepts arguments of type \Thelia\Model\Tax or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Tax relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildTaxI18nQuery The current query, for fluid interface
+ */
+ public function joinTax($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Tax');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Tax');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Tax relation Tax object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\TaxQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinTax($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Tax', '\Thelia\Model\TaxQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildTaxI18n $taxI18n Object to remove from the list of results
+ *
+ * @return ChildTaxI18nQuery The current query, for fluid interface
+ */
+ public function prune($taxI18n = null)
+ {
+ if ($taxI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(TaxI18nTableMap::ID), $taxI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(TaxI18nTableMap::LOCALE), $taxI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the tax_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ TaxI18nTableMap::clearInstancePool();
+ TaxI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildTaxI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildTaxI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxI18nTableMap::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->beginTransaction();
+
+
+ TaxI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ TaxI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // TaxI18nQuery
diff --git a/core/lib/Thelia/Model/Base/TaxQuery.php b/core/lib/Thelia/Model/Base/TaxQuery.php
new file mode 100644
index 000000000..0a61cbb3c
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/TaxQuery.php
@@ -0,0 +1,764 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildTax|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = TaxTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(TaxTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildTax A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, RATE, CREATED_AT, UPDATED_AT FROM tax WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildTax();
+ $obj->hydrate($row);
+ TaxTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildTax|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(TaxTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(TaxTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(TaxTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(TaxTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the rate column
+ *
+ * Example usage:
+ *
+ * $query->filterByRate(1234); // WHERE rate = 1234
+ * $query->filterByRate(array(12, 34)); // WHERE rate IN (12, 34)
+ * $query->filterByRate(array('min' => 12)); // WHERE rate > 12
+ *
+ *
+ * @param mixed $rate The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function filterByRate($rate = null, $comparison = null)
+ {
+ if (is_array($rate)) {
+ $useMinMax = false;
+ if (isset($rate['min'])) {
+ $this->addUsingAlias(TaxTableMap::RATE, $rate['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($rate['max'])) {
+ $this->addUsingAlias(TaxTableMap::RATE, $rate['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxTableMap::RATE, $rate, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(TaxTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(TaxTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(TaxTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(TaxTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\TaxRuleCountry object
+ *
+ * @param \Thelia\Model\TaxRuleCountry|ObjectCollection $taxRuleCountry the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null)
+ {
+ if ($taxRuleCountry instanceof \Thelia\Model\TaxRuleCountry) {
+ return $this
+ ->addUsingAlias(TaxTableMap::ID, $taxRuleCountry->getTaxId(), $comparison);
+ } elseif ($taxRuleCountry instanceof ObjectCollection) {
+ return $this
+ ->useTaxRuleCountryQuery()
+ ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type \Thelia\Model\TaxRuleCountry or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxRuleCountry relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxRuleCountry');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'TaxRuleCountry');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxRuleCountry relation TaxRuleCountry object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinTaxRuleCountry($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxRuleCountry', '\Thelia\Model\TaxRuleCountryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\TaxI18n object
+ *
+ * @param \Thelia\Model\TaxI18n|ObjectCollection $taxI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function filterByTaxI18n($taxI18n, $comparison = null)
+ {
+ if ($taxI18n instanceof \Thelia\Model\TaxI18n) {
+ return $this
+ ->addUsingAlias(TaxTableMap::ID, $taxI18n->getId(), $comparison);
+ } elseif ($taxI18n instanceof ObjectCollection) {
+ return $this
+ ->useTaxI18nQuery()
+ ->filterByPrimaryKeys($taxI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByTaxI18n() only accepts arguments of type \Thelia\Model\TaxI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function joinTaxI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'TaxI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxI18n relation TaxI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\TaxI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinTaxI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxI18n', '\Thelia\Model\TaxI18nQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildTax $tax Object to remove from the list of results
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function prune($tax = null)
+ {
+ if ($tax) {
+ $this->addUsingAlias(TaxTableMap::ID, $tax->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the tax table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ TaxTableMap::clearInstancePool();
+ TaxTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildTax or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildTax object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxTableMap::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->beginTransaction();
+
+
+ TaxTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ TaxTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(TaxTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(TaxTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(TaxTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(TaxTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(TaxTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(TaxTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'TaxI18n';
+
+ return $this
+ ->joinTaxI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildTaxQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('TaxI18n');
+ $this->with['TaxI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildTaxI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxI18n', '\Thelia\Model\TaxI18nQuery');
+ }
+
+} // TaxQuery
diff --git a/core/lib/Thelia/Model/Base/TaxRule.php b/core/lib/Thelia/Model/Base/TaxRule.php
new file mode 100644
index 000000000..101471313
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/TaxRule.php
@@ -0,0 +1,2407 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another TaxRule instance. If
+ * obj is an instance of TaxRule, delegates to
+ * equals(TaxRule). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return TaxRule The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return TaxRule The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [code] column value.
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+
+ return $this->code;
+ }
+
+ /**
+ * Get the [title] column value.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+
+ return $this->title;
+ }
+
+ /**
+ * Get the [description] column value.
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+
+ return $this->description;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\TaxRule The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = TaxRuleTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [code] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\TaxRule The current object (for fluent API support)
+ */
+ public function setCode($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->code !== $v) {
+ $this->code = $v;
+ $this->modifiedColumns[] = TaxRuleTableMap::CODE;
+ }
+
+
+ return $this;
+ } // setCode()
+
+ /**
+ * Set the value of [title] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\TaxRule The current object (for fluent API support)
+ */
+ public function setTitle($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->title !== $v) {
+ $this->title = $v;
+ $this->modifiedColumns[] = TaxRuleTableMap::TITLE;
+ }
+
+
+ return $this;
+ } // setTitle()
+
+ /**
+ * Set the value of [description] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\TaxRule The current object (for fluent API support)
+ */
+ public function setDescription($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->description !== $v) {
+ $this->description = $v;
+ $this->modifiedColumns[] = TaxRuleTableMap::DESCRIPTION;
+ }
+
+
+ return $this;
+ } // setDescription()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\TaxRule The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = TaxRuleTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\TaxRule The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = TaxRuleTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxRuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->code = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxRuleTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->title = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxRuleTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->description = (null !== $col) ? (string) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : TaxRuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : TaxRuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 6; // 6 = TaxRuleTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\TaxRule object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(TaxRuleTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildTaxRuleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->collProducts = null;
+
+ $this->collTaxRuleCountries = null;
+
+ $this->collTaxRuleI18ns = null;
+
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see TaxRule::setDeleted()
+ * @see TaxRule::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildTaxRuleQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(TaxRuleTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(TaxRuleTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(TaxRuleTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ TaxRuleTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con)
+ {
+ $affectedRows = 0; // initialize var to track total num of affected rows
+ if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ if ($this->productsScheduledForDeletion !== null) {
+ if (!$this->productsScheduledForDeletion->isEmpty()) {
+ foreach ($this->productsScheduledForDeletion as $product) {
+ // need to save related object because we set the relation to null
+ $product->save($con);
+ }
+ $this->productsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collProducts !== null) {
+ foreach ($this->collProducts as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->taxRuleCountriesScheduledForDeletion !== null) {
+ if (!$this->taxRuleCountriesScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\TaxRuleCountryQuery::create()
+ ->filterByPrimaryKeys($this->taxRuleCountriesScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->taxRuleCountriesScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collTaxRuleCountries !== null) {
+ foreach ($this->collTaxRuleCountries as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ if ($this->taxRuleI18nsScheduledForDeletion !== null) {
+ if (!$this->taxRuleI18nsScheduledForDeletion->isEmpty()) {
+ \Thelia\Model\TaxRuleI18nQuery::create()
+ ->filterByPrimaryKeys($this->taxRuleI18nsScheduledForDeletion->getPrimaryKeys(false))
+ ->delete($con);
+ $this->taxRuleI18nsScheduledForDeletion = null;
+ }
+ }
+
+ if ($this->collTaxRuleI18ns !== null) {
+ foreach ($this->collTaxRuleI18ns as $referrerFK) {
+ if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+ $this->modifiedColumns[] = TaxRuleTableMap::ID;
+ if (null !== $this->id) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key (' . TaxRuleTableMap::ID . ')');
+ }
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(TaxRuleTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(TaxRuleTableMap::CODE)) {
+ $modifiedColumns[':p' . $index++] = 'CODE';
+ }
+ if ($this->isColumnModified(TaxRuleTableMap::TITLE)) {
+ $modifiedColumns[':p' . $index++] = 'TITLE';
+ }
+ if ($this->isColumnModified(TaxRuleTableMap::DESCRIPTION)) {
+ $modifiedColumns[':p' . $index++] = 'DESCRIPTION';
+ }
+ if ($this->isColumnModified(TaxRuleTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(TaxRuleTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO tax_rule (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'CODE':
+ $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
+ break;
+ case 'TITLE':
+ $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR);
+ break;
+ case 'DESCRIPTION':
+ $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ try {
+ $pk = $con->lastInsertId();
+ } catch (Exception $e) {
+ throw new PropelException('Unable to get autoincrement id.', 0, $e);
+ }
+ $this->setId($pk);
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = TaxRuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getCode();
+ break;
+ case 2:
+ return $this->getTitle();
+ break;
+ case 3:
+ return $this->getDescription();
+ break;
+ case 4:
+ return $this->getCreatedAt();
+ break;
+ case 5:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['TaxRule'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['TaxRule'][$this->getPrimaryKey()] = true;
+ $keys = TaxRuleTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getCode(),
+ $keys[2] => $this->getTitle(),
+ $keys[3] => $this->getDescription(),
+ $keys[4] => $this->getCreatedAt(),
+ $keys[5] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->collProducts) {
+ $result['Products'] = $this->collProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collTaxRuleCountries) {
+ $result['TaxRuleCountries'] = $this->collTaxRuleCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ if (null !== $this->collTaxRuleI18ns) {
+ $result['TaxRuleI18ns'] = $this->collTaxRuleI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = TaxRuleTableMap::translateFieldName($name, $type, TableMap::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->setCode($value);
+ break;
+ case 2:
+ $this->setTitle($value);
+ break;
+ case 3:
+ $this->setDescription($value);
+ break;
+ case 4:
+ $this->setCreatedAt($value);
+ break;
+ case 5:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = TaxRuleTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
+ }
+
+ /**
+ * 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(TaxRuleTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(TaxRuleTableMap::ID)) $criteria->add(TaxRuleTableMap::ID, $this->id);
+ if ($this->isColumnModified(TaxRuleTableMap::CODE)) $criteria->add(TaxRuleTableMap::CODE, $this->code);
+ if ($this->isColumnModified(TaxRuleTableMap::TITLE)) $criteria->add(TaxRuleTableMap::TITLE, $this->title);
+ if ($this->isColumnModified(TaxRuleTableMap::DESCRIPTION)) $criteria->add(TaxRuleTableMap::DESCRIPTION, $this->description);
+ if ($this->isColumnModified(TaxRuleTableMap::CREATED_AT)) $criteria->add(TaxRuleTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(TaxRuleTableMap::UPDATED_AT)) $criteria->add(TaxRuleTableMap::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(TaxRuleTableMap::DATABASE_NAME);
+ $criteria->add(TaxRuleTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\TaxRule (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setCode($this->getCode());
+ $copyObj->setTitle($this->getTitle());
+ $copyObj->setDescription($this->getDescription());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+
+ 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->getProducts() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addProduct($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getTaxRuleCountries() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addTaxRuleCountry($relObj->copy($deepCopy));
+ }
+ }
+
+ foreach ($this->getTaxRuleI18ns() as $relObj) {
+ if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
+ $copyObj->addTaxRuleI18n($relObj->copy($deepCopy));
+ }
+ }
+
+ } // if ($deepCopy)
+
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ $copyObj->setId(NULL); // this is a auto-increment 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 \Thelia\Model\TaxRule 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;
+ }
+
+
+ /**
+ * Initializes a collection based on the name of a relation.
+ * Avoids crafting an 'init[$relationName]s' method name
+ * that wouldn't work when StandardEnglishPluralizer is used.
+ *
+ * @param string $relationName The name of the relation to initialize
+ * @return void
+ */
+ public function initRelation($relationName)
+ {
+ if ('Product' == $relationName) {
+ return $this->initProducts();
+ }
+ if ('TaxRuleCountry' == $relationName) {
+ return $this->initTaxRuleCountries();
+ }
+ if ('TaxRuleI18n' == $relationName) {
+ return $this->initTaxRuleI18ns();
+ }
+ }
+
+ /**
+ * Clears out the collProducts collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addProducts()
+ */
+ public function clearProducts()
+ {
+ $this->collProducts = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collProducts collection loaded partially.
+ */
+ public function resetPartialProducts($v = true)
+ {
+ $this->collProductsPartial = $v;
+ }
+
+ /**
+ * Initializes the collProducts collection.
+ *
+ * By default this just sets the collProducts collection to an empty array (like clearcollProducts());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initProducts($overrideExisting = true)
+ {
+ if (null !== $this->collProducts && !$overrideExisting) {
+ return;
+ }
+ $this->collProducts = new ObjectCollection();
+ $this->collProducts->setModel('\Thelia\Model\Product');
+ }
+
+ /**
+ * Gets an array of ChildProduct objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildTaxRule is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildProduct[] List of ChildProduct objects
+ * @throws PropelException
+ */
+ public function getProducts($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collProductsPartial && !$this->isNew();
+ if (null === $this->collProducts || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProducts) {
+ // return empty collection
+ $this->initProducts();
+ } else {
+ $collProducts = ChildProductQuery::create(null, $criteria)
+ ->filterByTaxRule($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collProductsPartial && count($collProducts)) {
+ $this->initProducts(false);
+
+ foreach ($collProducts as $obj) {
+ if (false == $this->collProducts->contains($obj)) {
+ $this->collProducts->append($obj);
+ }
+ }
+
+ $this->collProductsPartial = true;
+ }
+
+ $collProducts->getInternalIterator()->rewind();
+
+ return $collProducts;
+ }
+
+ if ($partial && $this->collProducts) {
+ foreach ($this->collProducts as $obj) {
+ if ($obj->isNew()) {
+ $collProducts[] = $obj;
+ }
+ }
+ }
+
+ $this->collProducts = $collProducts;
+ $this->collProductsPartial = false;
+ }
+ }
+
+ return $this->collProducts;
+ }
+
+ /**
+ * Sets a collection of Product objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $products A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildTaxRule The current object (for fluent API support)
+ */
+ public function setProducts(Collection $products, ConnectionInterface $con = null)
+ {
+ $productsToDelete = $this->getProducts(new Criteria(), $con)->diff($products);
+
+
+ $this->productsScheduledForDeletion = $productsToDelete;
+
+ foreach ($productsToDelete as $productRemoved) {
+ $productRemoved->setTaxRule(null);
+ }
+
+ $this->collProducts = null;
+ foreach ($products as $product) {
+ $this->addProduct($product);
+ }
+
+ $this->collProducts = $products;
+ $this->collProductsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related Product objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related Product objects.
+ * @throws PropelException
+ */
+ public function countProducts(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collProductsPartial && !$this->isNew();
+ if (null === $this->collProducts || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collProducts) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getProducts());
+ }
+
+ $query = ChildProductQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByTaxRule($this)
+ ->count($con);
+ }
+
+ return count($this->collProducts);
+ }
+
+ /**
+ * Method called to associate a ChildProduct object to this object
+ * through the ChildProduct foreign key attribute.
+ *
+ * @param ChildProduct $l ChildProduct
+ * @return \Thelia\Model\TaxRule The current object (for fluent API support)
+ */
+ public function addProduct(ChildProduct $l)
+ {
+ if ($this->collProducts === null) {
+ $this->initProducts();
+ $this->collProductsPartial = true;
+ }
+
+ if (!in_array($l, $this->collProducts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddProduct($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param Product $product The product object to add.
+ */
+ protected function doAddProduct($product)
+ {
+ $this->collProducts[]= $product;
+ $product->setTaxRule($this);
+ }
+
+ /**
+ * @param Product $product The product object to remove.
+ * @return ChildTaxRule The current object (for fluent API support)
+ */
+ public function removeProduct($product)
+ {
+ if ($this->getProducts()->contains($product)) {
+ $this->collProducts->remove($this->collProducts->search($product));
+ if (null === $this->productsScheduledForDeletion) {
+ $this->productsScheduledForDeletion = clone $this->collProducts;
+ $this->productsScheduledForDeletion->clear();
+ }
+ $this->productsScheduledForDeletion[]= $product;
+ $product->setTaxRule(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears out the collTaxRuleCountries collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addTaxRuleCountries()
+ */
+ public function clearTaxRuleCountries()
+ {
+ $this->collTaxRuleCountries = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collTaxRuleCountries collection loaded partially.
+ */
+ public function resetPartialTaxRuleCountries($v = true)
+ {
+ $this->collTaxRuleCountriesPartial = $v;
+ }
+
+ /**
+ * Initializes the collTaxRuleCountries collection.
+ *
+ * By default this just sets the collTaxRuleCountries collection to an empty array (like clearcollTaxRuleCountries());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initTaxRuleCountries($overrideExisting = true)
+ {
+ if (null !== $this->collTaxRuleCountries && !$overrideExisting) {
+ return;
+ }
+ $this->collTaxRuleCountries = new ObjectCollection();
+ $this->collTaxRuleCountries->setModel('\Thelia\Model\TaxRuleCountry');
+ }
+
+ /**
+ * Gets an array of ChildTaxRuleCountry objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildTaxRule is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects
+ * @throws PropelException
+ */
+ public function getTaxRuleCountries($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collTaxRuleCountriesPartial && !$this->isNew();
+ if (null === $this->collTaxRuleCountries || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleCountries) {
+ // return empty collection
+ $this->initTaxRuleCountries();
+ } else {
+ $collTaxRuleCountries = ChildTaxRuleCountryQuery::create(null, $criteria)
+ ->filterByTaxRule($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collTaxRuleCountriesPartial && count($collTaxRuleCountries)) {
+ $this->initTaxRuleCountries(false);
+
+ foreach ($collTaxRuleCountries as $obj) {
+ if (false == $this->collTaxRuleCountries->contains($obj)) {
+ $this->collTaxRuleCountries->append($obj);
+ }
+ }
+
+ $this->collTaxRuleCountriesPartial = true;
+ }
+
+ $collTaxRuleCountries->getInternalIterator()->rewind();
+
+ return $collTaxRuleCountries;
+ }
+
+ if ($partial && $this->collTaxRuleCountries) {
+ foreach ($this->collTaxRuleCountries as $obj) {
+ if ($obj->isNew()) {
+ $collTaxRuleCountries[] = $obj;
+ }
+ }
+ }
+
+ $this->collTaxRuleCountries = $collTaxRuleCountries;
+ $this->collTaxRuleCountriesPartial = false;
+ }
+ }
+
+ return $this->collTaxRuleCountries;
+ }
+
+ /**
+ * Sets a collection of TaxRuleCountry objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $taxRuleCountries A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildTaxRule The current object (for fluent API support)
+ */
+ public function setTaxRuleCountries(Collection $taxRuleCountries, ConnectionInterface $con = null)
+ {
+ $taxRuleCountriesToDelete = $this->getTaxRuleCountries(new Criteria(), $con)->diff($taxRuleCountries);
+
+
+ $this->taxRuleCountriesScheduledForDeletion = $taxRuleCountriesToDelete;
+
+ foreach ($taxRuleCountriesToDelete as $taxRuleCountryRemoved) {
+ $taxRuleCountryRemoved->setTaxRule(null);
+ }
+
+ $this->collTaxRuleCountries = null;
+ foreach ($taxRuleCountries as $taxRuleCountry) {
+ $this->addTaxRuleCountry($taxRuleCountry);
+ }
+
+ $this->collTaxRuleCountries = $taxRuleCountries;
+ $this->collTaxRuleCountriesPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related TaxRuleCountry objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related TaxRuleCountry objects.
+ * @throws PropelException
+ */
+ public function countTaxRuleCountries(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collTaxRuleCountriesPartial && !$this->isNew();
+ if (null === $this->collTaxRuleCountries || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleCountries) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getTaxRuleCountries());
+ }
+
+ $query = ChildTaxRuleCountryQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByTaxRule($this)
+ ->count($con);
+ }
+
+ return count($this->collTaxRuleCountries);
+ }
+
+ /**
+ * Method called to associate a ChildTaxRuleCountry object to this object
+ * through the ChildTaxRuleCountry foreign key attribute.
+ *
+ * @param ChildTaxRuleCountry $l ChildTaxRuleCountry
+ * @return \Thelia\Model\TaxRule The current object (for fluent API support)
+ */
+ public function addTaxRuleCountry(ChildTaxRuleCountry $l)
+ {
+ if ($this->collTaxRuleCountries === null) {
+ $this->initTaxRuleCountries();
+ $this->collTaxRuleCountriesPartial = true;
+ }
+
+ if (!in_array($l, $this->collTaxRuleCountries->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddTaxRuleCountry($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add.
+ */
+ protected function doAddTaxRuleCountry($taxRuleCountry)
+ {
+ $this->collTaxRuleCountries[]= $taxRuleCountry;
+ $taxRuleCountry->setTaxRule($this);
+ }
+
+ /**
+ * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove.
+ * @return ChildTaxRule The current object (for fluent API support)
+ */
+ public function removeTaxRuleCountry($taxRuleCountry)
+ {
+ if ($this->getTaxRuleCountries()->contains($taxRuleCountry)) {
+ $this->collTaxRuleCountries->remove($this->collTaxRuleCountries->search($taxRuleCountry));
+ if (null === $this->taxRuleCountriesScheduledForDeletion) {
+ $this->taxRuleCountriesScheduledForDeletion = clone $this->collTaxRuleCountries;
+ $this->taxRuleCountriesScheduledForDeletion->clear();
+ }
+ $this->taxRuleCountriesScheduledForDeletion[]= $taxRuleCountry;
+ $taxRuleCountry->setTaxRule(null);
+ }
+
+ return $this;
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this TaxRule is new, it will return
+ * an empty collection; or if this TaxRule has previously
+ * been saved, it will retrieve related TaxRuleCountries 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 TaxRule.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects
+ */
+ public function getTaxRuleCountriesJoinTax($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildTaxRuleCountryQuery::create(null, $criteria);
+ $query->joinWith('Tax', $joinBehavior);
+
+ return $this->getTaxRuleCountries($query, $con);
+ }
+
+
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this TaxRule is new, it will return
+ * an empty collection; or if this TaxRule has previously
+ * been saved, it will retrieve related TaxRuleCountries 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 TaxRule.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
+ * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects
+ */
+ public function getTaxRuleCountriesJoinCountry($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
+ {
+ $query = ChildTaxRuleCountryQuery::create(null, $criteria);
+ $query->joinWith('Country', $joinBehavior);
+
+ return $this->getTaxRuleCountries($query, $con);
+ }
+
+ /**
+ * Clears out the collTaxRuleI18ns collection
+ *
+ * This does not modify the database; however, it will remove any associated objects, causing
+ * them to be refetched by subsequent calls to accessor method.
+ *
+ * @return void
+ * @see addTaxRuleI18ns()
+ */
+ public function clearTaxRuleI18ns()
+ {
+ $this->collTaxRuleI18ns = null; // important to set this to NULL since that means it is uninitialized
+ }
+
+ /**
+ * Reset is the collTaxRuleI18ns collection loaded partially.
+ */
+ public function resetPartialTaxRuleI18ns($v = true)
+ {
+ $this->collTaxRuleI18nsPartial = $v;
+ }
+
+ /**
+ * Initializes the collTaxRuleI18ns collection.
+ *
+ * By default this just sets the collTaxRuleI18ns collection to an empty array (like clearcollTaxRuleI18ns());
+ * however, you may wish to override this method in your stub class to provide setting appropriate
+ * to your application -- for example, setting the initial array to the values stored in database.
+ *
+ * @param boolean $overrideExisting If set to true, the method call initializes
+ * the collection even if it is not empty
+ *
+ * @return void
+ */
+ public function initTaxRuleI18ns($overrideExisting = true)
+ {
+ if (null !== $this->collTaxRuleI18ns && !$overrideExisting) {
+ return;
+ }
+ $this->collTaxRuleI18ns = new ObjectCollection();
+ $this->collTaxRuleI18ns->setModel('\Thelia\Model\TaxRuleI18n');
+ }
+
+ /**
+ * Gets an array of ChildTaxRuleI18n objects which contain a foreign key that references this object.
+ *
+ * If the $criteria is not null, it is used to always fetch the results from the database.
+ * Otherwise the results are fetched from the database the first time, then cached.
+ * Next time the same method is called without $criteria, the cached collection is returned.
+ * If this ChildTaxRule is new, it will return
+ * an empty collection or the current collection; the criteria is ignored on a new object.
+ *
+ * @param Criteria $criteria optional Criteria object to narrow the query
+ * @param ConnectionInterface $con optional connection object
+ * @return Collection|ChildTaxRuleI18n[] List of ChildTaxRuleI18n objects
+ * @throws PropelException
+ */
+ public function getTaxRuleI18ns($criteria = null, ConnectionInterface $con = null)
+ {
+ $partial = $this->collTaxRuleI18nsPartial && !$this->isNew();
+ if (null === $this->collTaxRuleI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleI18ns) {
+ // return empty collection
+ $this->initTaxRuleI18ns();
+ } else {
+ $collTaxRuleI18ns = ChildTaxRuleI18nQuery::create(null, $criteria)
+ ->filterByTaxRule($this)
+ ->find($con);
+
+ if (null !== $criteria) {
+ if (false !== $this->collTaxRuleI18nsPartial && count($collTaxRuleI18ns)) {
+ $this->initTaxRuleI18ns(false);
+
+ foreach ($collTaxRuleI18ns as $obj) {
+ if (false == $this->collTaxRuleI18ns->contains($obj)) {
+ $this->collTaxRuleI18ns->append($obj);
+ }
+ }
+
+ $this->collTaxRuleI18nsPartial = true;
+ }
+
+ $collTaxRuleI18ns->getInternalIterator()->rewind();
+
+ return $collTaxRuleI18ns;
+ }
+
+ if ($partial && $this->collTaxRuleI18ns) {
+ foreach ($this->collTaxRuleI18ns as $obj) {
+ if ($obj->isNew()) {
+ $collTaxRuleI18ns[] = $obj;
+ }
+ }
+ }
+
+ $this->collTaxRuleI18ns = $collTaxRuleI18ns;
+ $this->collTaxRuleI18nsPartial = false;
+ }
+ }
+
+ return $this->collTaxRuleI18ns;
+ }
+
+ /**
+ * Sets a collection of TaxRuleI18n objects related by a one-to-many relationship
+ * to the current object.
+ * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
+ * and new objects from the given Propel collection.
+ *
+ * @param Collection $taxRuleI18ns A Propel collection.
+ * @param ConnectionInterface $con Optional connection object
+ * @return ChildTaxRule The current object (for fluent API support)
+ */
+ public function setTaxRuleI18ns(Collection $taxRuleI18ns, ConnectionInterface $con = null)
+ {
+ $taxRuleI18nsToDelete = $this->getTaxRuleI18ns(new Criteria(), $con)->diff($taxRuleI18ns);
+
+
+ //since at least one column in the foreign key is at the same time a PK
+ //we can not just set a PK to NULL in the lines below. We have to store
+ //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
+ $this->taxRuleI18nsScheduledForDeletion = clone $taxRuleI18nsToDelete;
+
+ foreach ($taxRuleI18nsToDelete as $taxRuleI18nRemoved) {
+ $taxRuleI18nRemoved->setTaxRule(null);
+ }
+
+ $this->collTaxRuleI18ns = null;
+ foreach ($taxRuleI18ns as $taxRuleI18n) {
+ $this->addTaxRuleI18n($taxRuleI18n);
+ }
+
+ $this->collTaxRuleI18ns = $taxRuleI18ns;
+ $this->collTaxRuleI18nsPartial = false;
+
+ return $this;
+ }
+
+ /**
+ * Returns the number of related TaxRuleI18n objects.
+ *
+ * @param Criteria $criteria
+ * @param boolean $distinct
+ * @param ConnectionInterface $con
+ * @return int Count of related TaxRuleI18n objects.
+ * @throws PropelException
+ */
+ public function countTaxRuleI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
+ {
+ $partial = $this->collTaxRuleI18nsPartial && !$this->isNew();
+ if (null === $this->collTaxRuleI18ns || null !== $criteria || $partial) {
+ if ($this->isNew() && null === $this->collTaxRuleI18ns) {
+ return 0;
+ }
+
+ if ($partial && !$criteria) {
+ return count($this->getTaxRuleI18ns());
+ }
+
+ $query = ChildTaxRuleI18nQuery::create(null, $criteria);
+ if ($distinct) {
+ $query->distinct();
+ }
+
+ return $query
+ ->filterByTaxRule($this)
+ ->count($con);
+ }
+
+ return count($this->collTaxRuleI18ns);
+ }
+
+ /**
+ * Method called to associate a ChildTaxRuleI18n object to this object
+ * through the ChildTaxRuleI18n foreign key attribute.
+ *
+ * @param ChildTaxRuleI18n $l ChildTaxRuleI18n
+ * @return \Thelia\Model\TaxRule The current object (for fluent API support)
+ */
+ public function addTaxRuleI18n(ChildTaxRuleI18n $l)
+ {
+ if ($l && $locale = $l->getLocale()) {
+ $this->setLocale($locale);
+ $this->currentTranslations[$locale] = $l;
+ }
+ if ($this->collTaxRuleI18ns === null) {
+ $this->initTaxRuleI18ns();
+ $this->collTaxRuleI18nsPartial = true;
+ }
+
+ if (!in_array($l, $this->collTaxRuleI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
+ $this->doAddTaxRuleI18n($l);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param TaxRuleI18n $taxRuleI18n The taxRuleI18n object to add.
+ */
+ protected function doAddTaxRuleI18n($taxRuleI18n)
+ {
+ $this->collTaxRuleI18ns[]= $taxRuleI18n;
+ $taxRuleI18n->setTaxRule($this);
+ }
+
+ /**
+ * @param TaxRuleI18n $taxRuleI18n The taxRuleI18n object to remove.
+ * @return ChildTaxRule The current object (for fluent API support)
+ */
+ public function removeTaxRuleI18n($taxRuleI18n)
+ {
+ if ($this->getTaxRuleI18ns()->contains($taxRuleI18n)) {
+ $this->collTaxRuleI18ns->remove($this->collTaxRuleI18ns->search($taxRuleI18n));
+ if (null === $this->taxRuleI18nsScheduledForDeletion) {
+ $this->taxRuleI18nsScheduledForDeletion = clone $this->collTaxRuleI18ns;
+ $this->taxRuleI18nsScheduledForDeletion->clear();
+ }
+ $this->taxRuleI18nsScheduledForDeletion[]= clone $taxRuleI18n;
+ $taxRuleI18n->setTaxRule(null);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->code = null;
+ $this->title = null;
+ $this->description = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ if ($this->collProducts) {
+ foreach ($this->collProducts as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collTaxRuleCountries) {
+ foreach ($this->collTaxRuleCountries as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ if ($this->collTaxRuleI18ns) {
+ foreach ($this->collTaxRuleI18ns as $o) {
+ $o->clearAllReferences($deep);
+ }
+ }
+ } // if ($deep)
+
+ // i18n behavior
+ $this->currentLocale = 'en_EN';
+ $this->currentTranslations = null;
+
+ if ($this->collProducts instanceof Collection) {
+ $this->collProducts->clearIterator();
+ }
+ $this->collProducts = null;
+ if ($this->collTaxRuleCountries instanceof Collection) {
+ $this->collTaxRuleCountries->clearIterator();
+ }
+ $this->collTaxRuleCountries = null;
+ if ($this->collTaxRuleI18ns instanceof Collection) {
+ $this->collTaxRuleI18ns->clearIterator();
+ }
+ $this->collTaxRuleI18ns = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(TaxRuleTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildTaxRule The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = TaxRuleTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ // i18n behavior
+
+ /**
+ * Sets the locale for translations
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ *
+ * @return ChildTaxRule The current object (for fluent API support)
+ */
+ public function setLocale($locale = 'en_EN')
+ {
+ $this->currentLocale = $locale;
+
+ return $this;
+ }
+
+ /**
+ * Gets the locale for translations
+ *
+ * @return string $locale Locale to use for the translation, e.g. 'fr_FR'
+ */
+ public function getLocale()
+ {
+ return $this->currentLocale;
+ }
+
+ /**
+ * Returns the current translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildTaxRuleI18n */
+ public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!isset($this->currentTranslations[$locale])) {
+ if (null !== $this->collTaxRuleI18ns) {
+ foreach ($this->collTaxRuleI18ns as $translation) {
+ if ($translation->getLocale() == $locale) {
+ $this->currentTranslations[$locale] = $translation;
+
+ return $translation;
+ }
+ }
+ }
+ if ($this->isNew()) {
+ $translation = new ChildTaxRuleI18n();
+ $translation->setLocale($locale);
+ } else {
+ $translation = ChildTaxRuleI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->findOneOrCreate($con);
+ $this->currentTranslations[$locale] = $translation;
+ }
+ $this->addTaxRuleI18n($translation);
+ }
+
+ return $this->currentTranslations[$locale];
+ }
+
+ /**
+ * Remove the translation for a given locale
+ *
+ * @param string $locale Locale to use for the translation, e.g. 'fr_FR'
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildTaxRule The current object (for fluent API support)
+ */
+ public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null)
+ {
+ if (!$this->isNew()) {
+ ChildTaxRuleI18nQuery::create()
+ ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
+ ->delete($con);
+ }
+ if (isset($this->currentTranslations[$locale])) {
+ unset($this->currentTranslations[$locale]);
+ }
+ foreach ($this->collTaxRuleI18ns as $key => $translation) {
+ if ($translation->getLocale() == $locale) {
+ unset($this->collTaxRuleI18ns[$key]);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Returns the current translation
+ *
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildTaxRuleI18n */
+ public function getCurrentTranslation(ConnectionInterface $con = null)
+ {
+ return $this->getTranslation($this->getLocale(), $con);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/TaxRuleCountry.php b/core/lib/Thelia/Model/Base/TaxRuleCountry.php
new file mode 100644
index 000000000..b5ae7941b
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/TaxRuleCountry.php
@@ -0,0 +1,1677 @@
+modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another TaxRuleCountry instance. If
+ * obj is an instance of TaxRuleCountry, delegates to
+ * equals(TaxRuleCountry). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return TaxRuleCountry The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return TaxRuleCountry The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [tax_rule_id] column value.
+ *
+ * @return int
+ */
+ public function getTaxRuleId()
+ {
+
+ return $this->tax_rule_id;
+ }
+
+ /**
+ * Get the [country_id] column value.
+ *
+ * @return int
+ */
+ public function getCountryId()
+ {
+
+ return $this->country_id;
+ }
+
+ /**
+ * Get the [tax_id] column value.
+ *
+ * @return int
+ */
+ public function getTaxId()
+ {
+
+ return $this->tax_id;
+ }
+
+ /**
+ * Get the [none] column value.
+ *
+ * @return int
+ */
+ public function getNone()
+ {
+
+ return $this->none;
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [created_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getCreatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->created_at;
+ } else {
+ return $this->created_at !== null ? $this->created_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Get the [optionally formatted] temporal [updated_at] column value.
+ *
+ *
+ * @param string $format The date/time format string (either date()-style or strftime()-style).
+ * If format is NULL, then the raw \DateTime object will be returned.
+ *
+ * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
+ *
+ * @throws PropelException - if unable to parse/validate the date/time value.
+ */
+ public function getUpdatedAt($format = NULL)
+ {
+ if ($format === null) {
+ return $this->updated_at;
+ } else {
+ return $this->updated_at !== null ? $this->updated_at->format($format) : null;
+ }
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = TaxRuleCountryTableMap::ID;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [tax_rule_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support)
+ */
+ public function setTaxRuleId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->tax_rule_id !== $v) {
+ $this->tax_rule_id = $v;
+ $this->modifiedColumns[] = TaxRuleCountryTableMap::TAX_RULE_ID;
+ }
+
+ if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) {
+ $this->aTaxRule = null;
+ }
+
+
+ return $this;
+ } // setTaxRuleId()
+
+ /**
+ * Set the value of [country_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support)
+ */
+ public function setCountryId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->country_id !== $v) {
+ $this->country_id = $v;
+ $this->modifiedColumns[] = TaxRuleCountryTableMap::COUNTRY_ID;
+ }
+
+ if ($this->aCountry !== null && $this->aCountry->getId() !== $v) {
+ $this->aCountry = null;
+ }
+
+
+ return $this;
+ } // setCountryId()
+
+ /**
+ * Set the value of [tax_id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support)
+ */
+ public function setTaxId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->tax_id !== $v) {
+ $this->tax_id = $v;
+ $this->modifiedColumns[] = TaxRuleCountryTableMap::TAX_ID;
+ }
+
+ if ($this->aTax !== null && $this->aTax->getId() !== $v) {
+ $this->aTax = null;
+ }
+
+
+ return $this;
+ } // setTaxId()
+
+ /**
+ * Set the value of [none] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support)
+ */
+ public function setNone($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->none !== $v) {
+ $this->none = $v;
+ $this->modifiedColumns[] = TaxRuleCountryTableMap::NONE;
+ }
+
+
+ return $this;
+ } // setNone()
+
+ /**
+ * Sets the value of [created_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support)
+ */
+ public function setCreatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->created_at !== null || $dt !== null) {
+ if ($dt !== $this->created_at) {
+ $this->created_at = $dt;
+ $this->modifiedColumns[] = TaxRuleCountryTableMap::CREATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setCreatedAt()
+
+ /**
+ * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
+ *
+ * @param mixed $v string, integer (timestamp), or \DateTime value.
+ * Empty strings are treated as NULL.
+ * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support)
+ */
+ public function setUpdatedAt($v)
+ {
+ $dt = PropelDateTime::newInstance($v, null, '\DateTime');
+ if ($this->updated_at !== null || $dt !== null) {
+ if ($dt !== $this->updated_at) {
+ $this->updated_at = $dt;
+ $this->modifiedColumns[] = TaxRuleCountryTableMap::UPDATED_AT;
+ }
+ } // if either are not null
+
+
+ return $this;
+ } // setUpdatedAt()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxRuleCountryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleCountryTableMap::translateFieldName('TaxRuleId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->tax_rule_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxRuleCountryTableMap::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->country_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxRuleCountryTableMap::translateFieldName('TaxId', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->tax_id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : TaxRuleCountryTableMap::translateFieldName('None', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->none = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : TaxRuleCountryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : TaxRuleCountryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
+ if ($col === '0000-00-00 00:00:00') {
+ $col = null;
+ }
+ $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 7; // 7 = TaxRuleCountryTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\TaxRuleCountry object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aTaxRule !== null && $this->tax_rule_id !== $this->aTaxRule->getId()) {
+ $this->aTaxRule = null;
+ }
+ if ($this->aCountry !== null && $this->country_id !== $this->aCountry->getId()) {
+ $this->aCountry = null;
+ }
+ if ($this->aTax !== null && $this->tax_id !== $this->aTax->getId()) {
+ $this->aTax = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(TaxRuleCountryTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildTaxRuleCountryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aTax = null;
+ $this->aTaxRule = null;
+ $this->aCountry = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see TaxRuleCountry::setDeleted()
+ * @see TaxRuleCountry::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleCountryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildTaxRuleCountryQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleCountryTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ // timestampable behavior
+ if (!$this->isColumnModified(TaxRuleCountryTableMap::CREATED_AT)) {
+ $this->setCreatedAt(time());
+ }
+ if (!$this->isColumnModified(TaxRuleCountryTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ // timestampable behavior
+ if ($this->isModified() && !$this->isColumnModified(TaxRuleCountryTableMap::UPDATED_AT)) {
+ $this->setUpdatedAt(time());
+ }
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ TaxRuleCountryTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aTax !== null) {
+ if ($this->aTax->isModified() || $this->aTax->isNew()) {
+ $affectedRows += $this->aTax->save($con);
+ }
+ $this->setTax($this->aTax);
+ }
+
+ if ($this->aTaxRule !== null) {
+ if ($this->aTaxRule->isModified() || $this->aTaxRule->isNew()) {
+ $affectedRows += $this->aTaxRule->save($con);
+ }
+ $this->setTaxRule($this->aTaxRule);
+ }
+
+ if ($this->aCountry !== null) {
+ if ($this->aCountry->isModified() || $this->aCountry->isNew()) {
+ $affectedRows += $this->aCountry->save($con);
+ }
+ $this->setCountry($this->aCountry);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(TaxRuleCountryTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(TaxRuleCountryTableMap::TAX_RULE_ID)) {
+ $modifiedColumns[':p' . $index++] = 'TAX_RULE_ID';
+ }
+ if ($this->isColumnModified(TaxRuleCountryTableMap::COUNTRY_ID)) {
+ $modifiedColumns[':p' . $index++] = 'COUNTRY_ID';
+ }
+ if ($this->isColumnModified(TaxRuleCountryTableMap::TAX_ID)) {
+ $modifiedColumns[':p' . $index++] = 'TAX_ID';
+ }
+ if ($this->isColumnModified(TaxRuleCountryTableMap::NONE)) {
+ $modifiedColumns[':p' . $index++] = 'NONE';
+ }
+ if ($this->isColumnModified(TaxRuleCountryTableMap::CREATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'CREATED_AT';
+ }
+ if ($this->isColumnModified(TaxRuleCountryTableMap::UPDATED_AT)) {
+ $modifiedColumns[':p' . $index++] = 'UPDATED_AT';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO tax_rule_country (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'TAX_RULE_ID':
+ $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT);
+ break;
+ case 'COUNTRY_ID':
+ $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT);
+ break;
+ case 'TAX_ID':
+ $stmt->bindValue($identifier, $this->tax_id, PDO::PARAM_INT);
+ break;
+ case 'NONE':
+ $stmt->bindValue($identifier, $this->none, PDO::PARAM_INT);
+ break;
+ case 'CREATED_AT':
+ $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ case 'UPDATED_AT':
+ $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = TaxRuleCountryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getTaxRuleId();
+ break;
+ case 2:
+ return $this->getCountryId();
+ break;
+ case 3:
+ return $this->getTaxId();
+ break;
+ case 4:
+ return $this->getNone();
+ break;
+ case 5:
+ return $this->getCreatedAt();
+ break;
+ case 6:
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['TaxRuleCountry'][$this->getPrimaryKey()])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['TaxRuleCountry'][$this->getPrimaryKey()] = true;
+ $keys = TaxRuleCountryTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getTaxRuleId(),
+ $keys[2] => $this->getCountryId(),
+ $keys[3] => $this->getTaxId(),
+ $keys[4] => $this->getNone(),
+ $keys[5] => $this->getCreatedAt(),
+ $keys[6] => $this->getUpdatedAt(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aTax) {
+ $result['Tax'] = $this->aTax->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aTaxRule) {
+ $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ if (null !== $this->aCountry) {
+ $result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = TaxRuleCountryTableMap::translateFieldName($name, $type, TableMap::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->setTaxRuleId($value);
+ break;
+ case 2:
+ $this->setCountryId($value);
+ break;
+ case 3:
+ $this->setTaxId($value);
+ break;
+ case 4:
+ $this->setNone($value);
+ break;
+ case 5:
+ $this->setCreatedAt($value);
+ break;
+ case 6:
+ $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = TaxRuleCountryTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setTaxRuleId($arr[$keys[1]]);
+ if (array_key_exists($keys[2], $arr)) $this->setCountryId($arr[$keys[2]]);
+ if (array_key_exists($keys[3], $arr)) $this->setTaxId($arr[$keys[3]]);
+ if (array_key_exists($keys[4], $arr)) $this->setNone($arr[$keys[4]]);
+ if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
+ if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
+ }
+
+ /**
+ * 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(TaxRuleCountryTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(TaxRuleCountryTableMap::ID)) $criteria->add(TaxRuleCountryTableMap::ID, $this->id);
+ if ($this->isColumnModified(TaxRuleCountryTableMap::TAX_RULE_ID)) $criteria->add(TaxRuleCountryTableMap::TAX_RULE_ID, $this->tax_rule_id);
+ if ($this->isColumnModified(TaxRuleCountryTableMap::COUNTRY_ID)) $criteria->add(TaxRuleCountryTableMap::COUNTRY_ID, $this->country_id);
+ if ($this->isColumnModified(TaxRuleCountryTableMap::TAX_ID)) $criteria->add(TaxRuleCountryTableMap::TAX_ID, $this->tax_id);
+ if ($this->isColumnModified(TaxRuleCountryTableMap::NONE)) $criteria->add(TaxRuleCountryTableMap::NONE, $this->none);
+ if ($this->isColumnModified(TaxRuleCountryTableMap::CREATED_AT)) $criteria->add(TaxRuleCountryTableMap::CREATED_AT, $this->created_at);
+ if ($this->isColumnModified(TaxRuleCountryTableMap::UPDATED_AT)) $criteria->add(TaxRuleCountryTableMap::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(TaxRuleCountryTableMap::DATABASE_NAME);
+ $criteria->add(TaxRuleCountryTableMap::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);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return null === $this->getId();
+ }
+
+ /**
+ * 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 \Thelia\Model\TaxRuleCountry (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setTaxRuleId($this->getTaxRuleId());
+ $copyObj->setCountryId($this->getCountryId());
+ $copyObj->setTaxId($this->getTaxId());
+ $copyObj->setNone($this->getNone());
+ $copyObj->setCreatedAt($this->getCreatedAt());
+ $copyObj->setUpdatedAt($this->getUpdatedAt());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\TaxRuleCountry 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildTax object.
+ *
+ * @param ChildTax $v
+ * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setTax(ChildTax $v = null)
+ {
+ if ($v === null) {
+ $this->setTaxId(NULL);
+ } else {
+ $this->setTaxId($v->getId());
+ }
+
+ $this->aTax = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildTax object, it will not be re-added.
+ if ($v !== null) {
+ $v->addTaxRuleCountry($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildTax object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildTax The associated ChildTax object.
+ * @throws PropelException
+ */
+ public function getTax(ConnectionInterface $con = null)
+ {
+ if ($this->aTax === null && ($this->tax_id !== null)) {
+ $this->aTax = ChildTaxQuery::create()->findPk($this->tax_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aTax->addTaxRuleCountries($this);
+ */
+ }
+
+ return $this->aTax;
+ }
+
+ /**
+ * Declares an association between this object and a ChildTaxRule object.
+ *
+ * @param ChildTaxRule $v
+ * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setTaxRule(ChildTaxRule $v = null)
+ {
+ if ($v === null) {
+ $this->setTaxRuleId(NULL);
+ } else {
+ $this->setTaxRuleId($v->getId());
+ }
+
+ $this->aTaxRule = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildTaxRule object, it will not be re-added.
+ if ($v !== null) {
+ $v->addTaxRuleCountry($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildTaxRule object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildTaxRule The associated ChildTaxRule object.
+ * @throws PropelException
+ */
+ public function getTaxRule(ConnectionInterface $con = null)
+ {
+ if ($this->aTaxRule === null && ($this->tax_rule_id !== null)) {
+ $this->aTaxRule = ChildTaxRuleQuery::create()->findPk($this->tax_rule_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aTaxRule->addTaxRuleCountries($this);
+ */
+ }
+
+ return $this->aTaxRule;
+ }
+
+ /**
+ * Declares an association between this object and a ChildCountry object.
+ *
+ * @param ChildCountry $v
+ * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setCountry(ChildCountry $v = null)
+ {
+ if ($v === null) {
+ $this->setCountryId(NULL);
+ } else {
+ $this->setCountryId($v->getId());
+ }
+
+ $this->aCountry = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildCountry object, it will not be re-added.
+ if ($v !== null) {
+ $v->addTaxRuleCountry($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildCountry object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildCountry The associated ChildCountry object.
+ * @throws PropelException
+ */
+ public function getCountry(ConnectionInterface $con = null)
+ {
+ if ($this->aCountry === null && ($this->country_id !== null)) {
+ $this->aCountry = ChildCountryQuery::create()->findPk($this->country_id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aCountry->addTaxRuleCountries($this);
+ */
+ }
+
+ return $this->aCountry;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->tax_rule_id = null;
+ $this->country_id = null;
+ $this->tax_id = null;
+ $this->none = null;
+ $this->created_at = null;
+ $this->updated_at = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aTax = null;
+ $this->aTaxRule = null;
+ $this->aCountry = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(TaxRuleCountryTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ // timestampable behavior
+
+ /**
+ * Mark the current object so that the update date doesn't get updated during next save
+ *
+ * @return ChildTaxRuleCountry The current object (for fluent API support)
+ */
+ public function keepUpdateDateUnchanged()
+ {
+ $this->modifiedColumns[] = TaxRuleCountryTableMap::UPDATED_AT;
+
+ return $this;
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/TaxRuleCountryQuery.php b/core/lib/Thelia/Model/Base/TaxRuleCountryQuery.php
new file mode 100644
index 000000000..b4d4cd1c2
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/TaxRuleCountryQuery.php
@@ -0,0 +1,930 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildTaxRuleCountry|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = TaxRuleCountryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(TaxRuleCountryTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildTaxRuleCountry A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, TAX_RULE_ID, COUNTRY_ID, TAX_ID, NONE, CREATED_AT, UPDATED_AT FROM tax_rule_country WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildTaxRuleCountry();
+ $obj->hydrate($row);
+ TaxRuleCountryTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildTaxRuleCountry|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(TaxRuleCountryTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(TaxRuleCountryTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleCountryTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the tax_rule_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByTaxRuleId(1234); // WHERE tax_rule_id = 1234
+ * $query->filterByTaxRuleId(array(12, 34)); // WHERE tax_rule_id IN (12, 34)
+ * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12
+ *
+ *
+ * @see filterByTaxRule()
+ *
+ * @param mixed $taxRuleId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByTaxRuleId($taxRuleId = null, $comparison = null)
+ {
+ if (is_array($taxRuleId)) {
+ $useMinMax = false;
+ if (isset($taxRuleId['min'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::TAX_RULE_ID, $taxRuleId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($taxRuleId['max'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::TAX_RULE_ID, $taxRuleId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleCountryTableMap::TAX_RULE_ID, $taxRuleId, $comparison);
+ }
+
+ /**
+ * Filter the query on the country_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByCountryId(1234); // WHERE country_id = 1234
+ * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
+ * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
+ *
+ *
+ * @see filterByCountry()
+ *
+ * @param mixed $countryId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByCountryId($countryId = null, $comparison = null)
+ {
+ if (is_array($countryId)) {
+ $useMinMax = false;
+ if (isset($countryId['min'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($countryId['max'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleCountryTableMap::COUNTRY_ID, $countryId, $comparison);
+ }
+
+ /**
+ * Filter the query on the tax_id column
+ *
+ * Example usage:
+ *
+ * $query->filterByTaxId(1234); // WHERE tax_id = 1234
+ * $query->filterByTaxId(array(12, 34)); // WHERE tax_id IN (12, 34)
+ * $query->filterByTaxId(array('min' => 12)); // WHERE tax_id > 12
+ *
+ *
+ * @see filterByTax()
+ *
+ * @param mixed $taxId The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByTaxId($taxId = null, $comparison = null)
+ {
+ if (is_array($taxId)) {
+ $useMinMax = false;
+ if (isset($taxId['min'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::TAX_ID, $taxId['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($taxId['max'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::TAX_ID, $taxId['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleCountryTableMap::TAX_ID, $taxId, $comparison);
+ }
+
+ /**
+ * Filter the query on the none column
+ *
+ * Example usage:
+ *
+ * $query->filterByNone(1234); // WHERE none = 1234
+ * $query->filterByNone(array(12, 34)); // WHERE none IN (12, 34)
+ * $query->filterByNone(array('min' => 12)); // WHERE none > 12
+ *
+ *
+ * @param mixed $none The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByNone($none = null, $comparison = null)
+ {
+ if (is_array($none)) {
+ $useMinMax = false;
+ if (isset($none['min'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::NONE, $none['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($none['max'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::NONE, $none['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleCountryTableMap::NONE, $none, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleCountryTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleCountryTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Tax object
+ *
+ * @param \Thelia\Model\Tax|ObjectCollection $tax The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByTax($tax, $comparison = null)
+ {
+ if ($tax instanceof \Thelia\Model\Tax) {
+ return $this
+ ->addUsingAlias(TaxRuleCountryTableMap::TAX_ID, $tax->getId(), $comparison);
+ } elseif ($tax instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(TaxRuleCountryTableMap::TAX_ID, $tax->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByTax() only accepts arguments of type \Thelia\Model\Tax or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Tax relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function joinTax($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Tax');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Tax');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Tax relation Tax object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\TaxQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinTax($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Tax', '\Thelia\Model\TaxQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\TaxRule object
+ *
+ * @param \Thelia\Model\TaxRule|ObjectCollection $taxRule The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByTaxRule($taxRule, $comparison = null)
+ {
+ if ($taxRule instanceof \Thelia\Model\TaxRule) {
+ return $this
+ ->addUsingAlias(TaxRuleCountryTableMap::TAX_RULE_ID, $taxRule->getId(), $comparison);
+ } elseif ($taxRule instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(TaxRuleCountryTableMap::TAX_RULE_ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByTaxRule() only accepts arguments of type \Thelia\Model\TaxRule or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxRule relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function joinTaxRule($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxRule');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'TaxRule');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxRule relation TaxRule object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\TaxRuleQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxRuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinTaxRule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxRule', '\Thelia\Model\TaxRuleQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Country object
+ *
+ * @param \Thelia\Model\Country|ObjectCollection $country The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function filterByCountry($country, $comparison = null)
+ {
+ if ($country instanceof \Thelia\Model\Country) {
+ return $this
+ ->addUsingAlias(TaxRuleCountryTableMap::COUNTRY_ID, $country->getId(), $comparison);
+ } elseif ($country instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(TaxRuleCountryTableMap::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByCountry() only accepts arguments of type \Thelia\Model\Country or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Country relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function joinCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Country');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Country');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Country relation Country object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\CountryQuery A secondary query class using the current class as primary query
+ */
+ public function useCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinCountry($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildTaxRuleCountry $taxRuleCountry Object to remove from the list of results
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function prune($taxRuleCountry = null)
+ {
+ if ($taxRuleCountry) {
+ $this->addUsingAlias(TaxRuleCountryTableMap::ID, $taxRuleCountry->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the tax_rule_country table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleCountryTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ TaxRuleCountryTableMap::clearInstancePool();
+ TaxRuleCountryTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildTaxRuleCountry or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildTaxRuleCountry object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleCountryTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleCountryTableMap::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->beginTransaction();
+
+
+ TaxRuleCountryTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ TaxRuleCountryTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(TaxRuleCountryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(TaxRuleCountryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(TaxRuleCountryTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(TaxRuleCountryTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(TaxRuleCountryTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildTaxRuleCountryQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(TaxRuleCountryTableMap::CREATED_AT);
+ }
+
+} // TaxRuleCountryQuery
diff --git a/core/lib/Thelia/Model/Base/TaxRuleI18n.php b/core/lib/Thelia/Model/Base/TaxRuleI18n.php
new file mode 100644
index 000000000..86215b335
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/TaxRuleI18n.php
@@ -0,0 +1,1207 @@
+locale = 'en_EN';
+ }
+
+ /**
+ * Initializes internal state of Thelia\Model\Base\TaxRuleI18n object.
+ * @see applyDefaults()
+ */
+ public function __construct()
+ {
+ $this->applyDefaultValues();
+ }
+
+ /**
+ * Returns whether the object has been modified.
+ *
+ * @return boolean True if the object has been modified.
+ */
+ public function isModified()
+ {
+ return !empty($this->modifiedColumns);
+ }
+
+ /**
+ * Has specified column been modified?
+ *
+ * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean True if $col has been modified.
+ */
+ public function isColumnModified($col)
+ {
+ return in_array($col, $this->modifiedColumns);
+ }
+
+ /**
+ * Get the columns that have been modified in this object.
+ * @return array A unique list of the modified column names for this object.
+ */
+ public function getModifiedColumns()
+ {
+ return array_unique($this->modifiedColumns);
+ }
+
+ /**
+ * Returns whether the object has ever been saved. This will
+ * be false, if the object was retrieved from storage or was created
+ * and then saved.
+ *
+ * @return true, if the object has never been persisted.
+ */
+ public function isNew()
+ {
+ return $this->new;
+ }
+
+ /**
+ * Setter for the isNew attribute. This method will be called
+ * by Propel-generated children and objects.
+ *
+ * @param boolean $b the state of the object.
+ */
+ public function setNew($b)
+ {
+ $this->new = (Boolean) $b;
+ }
+
+ /**
+ * Whether this object has been deleted.
+ * @return boolean The deleted state of this object.
+ */
+ public function isDeleted()
+ {
+ return $this->deleted;
+ }
+
+ /**
+ * Specify whether this object has been deleted.
+ * @param boolean $b The deleted state of this object.
+ * @return void
+ */
+ public function setDeleted($b)
+ {
+ $this->deleted = (Boolean) $b;
+ }
+
+ /**
+ * Sets the modified state for the object to be false.
+ * @param string $col If supplied, only the specified column is reset.
+ * @return void
+ */
+ public function resetModified($col = null)
+ {
+ if (null !== $col) {
+ while (false !== ($offset = array_search($col, $this->modifiedColumns))) {
+ array_splice($this->modifiedColumns, $offset, 1);
+ }
+ } else {
+ $this->modifiedColumns = array();
+ }
+ }
+
+ /**
+ * Compares this with another TaxRuleI18n instance. If
+ * obj is an instance of TaxRuleI18n, delegates to
+ * equals(TaxRuleI18n). Otherwise, returns false.
+ *
+ * @param obj The object to compare to.
+ * @return Whether equal to the object specified.
+ */
+ public function equals($obj)
+ {
+ $thisclazz = get_class($this);
+ if (!is_object($obj) || !($obj instanceof $thisclazz)) {
+ return false;
+ }
+
+ if ($this === $obj) {
+ return true;
+ }
+
+ if (null === $this->getPrimaryKey()
+ || null === $obj->getPrimaryKey()) {
+ return false;
+ }
+
+ return $this->getPrimaryKey() === $obj->getPrimaryKey();
+ }
+
+ /**
+ * If the primary key is not null, return the hashcode of the
+ * primary key. Otherwise, return the hash code of the object.
+ *
+ * @return int Hashcode
+ */
+ public function hashCode()
+ {
+ if (null !== $this->getPrimaryKey()) {
+ return crc32(serialize($this->getPrimaryKey()));
+ }
+
+ return crc32(serialize(clone $this));
+ }
+
+ /**
+ * Get the associative array of the virtual columns in this object
+ *
+ * @param string $name The virtual column name
+ *
+ * @return array
+ */
+ public function getVirtualColumns()
+ {
+ return $this->virtualColumns;
+ }
+
+ /**
+ * Checks the existence of a virtual column in this object
+ *
+ * @return boolean
+ */
+ public function hasVirtualColumn($name)
+ {
+ return isset($this->virtualColumns[$name]);
+ }
+
+ /**
+ * Get the value of a virtual column in this object
+ *
+ * @return mixed
+ */
+ public function getVirtualColumn($name)
+ {
+ if (!$this->hasVirtualColumn($name)) {
+ throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
+ }
+
+ return $this->virtualColumns[$name];
+ }
+
+ /**
+ * Set the value of a virtual column in this object
+ *
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
+ *
+ * @return TaxRuleI18n The current object, for fluid interface
+ */
+ public function setVirtualColumn($name, $value)
+ {
+ $this->virtualColumns[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Logs a message using Propel::log().
+ *
+ * @param string $msg
+ * @param int $priority One of the Propel::LOG_* logging levels
+ * @return boolean
+ */
+ protected function log($msg, $priority = Propel::LOG_INFO)
+ {
+ return Propel::log(get_class($this) . ': ' . $msg, $priority);
+ }
+
+ /**
+ * Populate the current object from a string, using a given parser format
+ *
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance,
+ * or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
+ *
+ * @return TaxRuleI18n The current object, for fluid interface
+ */
+ public function importFrom($parser, $data)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME);
+ }
+
+ /**
+ * Export the current object properties to a string, using a given parser format
+ *
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ *
+ *
+ * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
+ * @return string The exported data
+ */
+ public function exportTo($parser, $includeLazyLoadColumns = true)
+ {
+ if (!$parser instanceof AbstractParser) {
+ $parser = AbstractParser::getParser($parser);
+ }
+
+ return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
+ }
+
+ /**
+ * Clean up internal collections prior to serializing
+ * Avoids recursive loops that turn into segmentation faults when serializing
+ */
+ public function __sleep()
+ {
+ $this->clearAllReferences();
+
+ return array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Get the [id] column value.
+ *
+ * @return int
+ */
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+ /**
+ * Get the [locale] column value.
+ *
+ * @return string
+ */
+ public function getLocale()
+ {
+
+ return $this->locale;
+ }
+
+ /**
+ * Set the value of [id] column.
+ *
+ * @param int $v new value
+ * @return \Thelia\Model\TaxRuleI18n The current object (for fluent API support)
+ */
+ public function setId($v)
+ {
+ if ($v !== null) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = TaxRuleI18nTableMap::ID;
+ }
+
+ if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) {
+ $this->aTaxRule = null;
+ }
+
+
+ return $this;
+ } // setId()
+
+ /**
+ * Set the value of [locale] column.
+ *
+ * @param string $v new value
+ * @return \Thelia\Model\TaxRuleI18n The current object (for fluent API support)
+ */
+ public function setLocale($v)
+ {
+ if ($v !== null) {
+ $v = (string) $v;
+ }
+
+ if ($this->locale !== $v) {
+ $this->locale = $v;
+ $this->modifiedColumns[] = TaxRuleI18nTableMap::LOCALE;
+ }
+
+
+ return $this;
+ } // setLocale()
+
+ /**
+ * Indicates whether the columns in this object are only set to default values.
+ *
+ * This method can be used in conjunction with isModified() to indicate whether an object is both
+ * modified _and_ has some values set which are non-default.
+ *
+ * @return boolean Whether the columns in this object are only been set with default values.
+ */
+ public function hasOnlyDefaultValues()
+ {
+ if ($this->locale !== 'en_EN') {
+ return false;
+ }
+
+ // otherwise, everything was equal, so return TRUE
+ return true;
+ } // hasOnlyDefaultValues()
+
+ /**
+ * Hydrates (populates) the object variables with values from the database resultset.
+ *
+ * An offset (0-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 array $row The row returned by DataFetcher->fetch().
+ * @param int $startcol 0-based offset column which indicates which restultset column to start with.
+ * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @return int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
+ {
+ try {
+
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxRuleI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->id = (null !== $col) ? (int) $col : null;
+
+ $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
+ $this->locale = (null !== $col) ? (string) $col : null;
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ if ($rehydrate) {
+ $this->ensureConsistency();
+ }
+
+ return $startcol + 2; // 2 = TaxRuleI18nTableMap::NUM_HYDRATE_COLUMNS.
+
+ } catch (Exception $e) {
+ throw new PropelException("Error populating \Thelia\Model\TaxRuleI18n object", 0, $e);
+ }
+ }
+
+ /**
+ * Checks and repairs the internal consistency of the object.
+ *
+ * This method is executed after an already-instantiated object is re-hydrated
+ * from the database. It exists to check any foreign keys to make sure that
+ * the objects related to the current object are correct based on foreign key.
+ *
+ * You can override this method in the stub class, but you should always invoke
+ * the base method from the overridden method (i.e. parent::ensureConsistency()),
+ * in case your model changes.
+ *
+ * @throws PropelException
+ */
+ public function ensureConsistency()
+ {
+ if ($this->aTaxRule !== null && $this->id !== $this->aTaxRule->getId()) {
+ $this->aTaxRule = null;
+ }
+ } // ensureConsistency
+
+ /**
+ * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
+ *
+ * This will only work if the object has been saved and has a valid primary key set.
+ *
+ * @param boolean $deep (optional) Whether to also de-associated any related objects.
+ * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use.
+ * @return void
+ * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
+ */
+ public function reload($deep = false, ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("Cannot reload a deleted object.");
+ }
+
+ if ($this->isNew()) {
+ throw new PropelException("Cannot reload an unsaved object.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(TaxRuleI18nTableMap::DATABASE_NAME);
+ }
+
+ // We don't need to alter the object instance pool; we're just modifying this instance
+ // already in the pool.
+
+ $dataFetcher = ChildTaxRuleI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
+ $row = $dataFetcher->fetch();
+ $dataFetcher->close();
+ if (!$row) {
+ throw new PropelException('Cannot find matching row in the database to reload object values.');
+ }
+ $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
+
+ if ($deep) { // also de-associate any related objects?
+
+ $this->aTaxRule = null;
+ } // if (deep)
+ }
+
+ /**
+ * Removes this object from datastore and sets delete attribute.
+ *
+ * @param ConnectionInterface $con
+ * @return void
+ * @throws PropelException
+ * @see TaxRuleI18n::setDeleted()
+ * @see TaxRuleI18n::isDeleted()
+ */
+ public function delete(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ try {
+ $deleteQuery = ChildTaxRuleI18nQuery::create()
+ ->filterByPrimaryKey($this->getPrimaryKey());
+ $ret = $this->preDelete($con);
+ if ($ret) {
+ $deleteQuery->delete($con);
+ $this->postDelete($con);
+ $con->commit();
+ $this->setDeleted(true);
+ } else {
+ $con->commit();
+ }
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Persists this object to the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All modified related objects will also be persisted in the doSave()
+ * method. This method wraps all precipitate database operations in a
+ * single transaction.
+ *
+ * @param ConnectionInterface $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(ConnectionInterface $con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleI18nTableMap::DATABASE_NAME);
+ }
+
+ $con->beginTransaction();
+ $isInsert = $this->isNew();
+ try {
+ $ret = $this->preSave($con);
+ if ($isInsert) {
+ $ret = $ret && $this->preInsert($con);
+ } else {
+ $ret = $ret && $this->preUpdate($con);
+ }
+ if ($ret) {
+ $affectedRows = $this->doSave($con);
+ if ($isInsert) {
+ $this->postInsert($con);
+ } else {
+ $this->postUpdate($con);
+ }
+ $this->postSave($con);
+ TaxRuleI18nTableMap::addInstanceToPool($this);
+ } else {
+ $affectedRows = 0;
+ }
+ $con->commit();
+
+ return $affectedRows;
+ } catch (Exception $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set
+ // method. This object relates to these object(s) by a
+ // foreign key reference.
+
+ if ($this->aTaxRule !== null) {
+ if ($this->aTaxRule->isModified() || $this->aTaxRule->isNew()) {
+ $affectedRows += $this->aTaxRule->save($con);
+ }
+ $this->setTaxRule($this->aTaxRule);
+ }
+
+ if ($this->isNew() || $this->isModified()) {
+ // persist changes
+ if ($this->isNew()) {
+ $this->doInsert($con);
+ } else {
+ $this->doUpdate($con);
+ }
+ $affectedRows += 1;
+ $this->resetModified();
+ }
+
+ $this->alreadyInSave = false;
+
+ }
+
+ return $affectedRows;
+ } // doSave()
+
+ /**
+ * Insert the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @throws PropelException
+ * @see doSave()
+ */
+ protected function doInsert(ConnectionInterface $con)
+ {
+ $modifiedColumns = array();
+ $index = 0;
+
+
+ // check the columns in natural order for more readable SQL queries
+ if ($this->isColumnModified(TaxRuleI18nTableMap::ID)) {
+ $modifiedColumns[':p' . $index++] = 'ID';
+ }
+ if ($this->isColumnModified(TaxRuleI18nTableMap::LOCALE)) {
+ $modifiedColumns[':p' . $index++] = 'LOCALE';
+ }
+
+ $sql = sprintf(
+ 'INSERT INTO tax_rule_i18n (%s) VALUES (%s)',
+ implode(', ', $modifiedColumns),
+ implode(', ', array_keys($modifiedColumns))
+ );
+
+ try {
+ $stmt = $con->prepare($sql);
+ foreach ($modifiedColumns as $identifier => $columnName) {
+ switch ($columnName) {
+ case 'ID':
+ $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
+ break;
+ case 'LOCALE':
+ $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
+ break;
+ }
+ }
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
+ }
+
+ $this->setNew(false);
+ }
+
+ /**
+ * Update the row in the database.
+ *
+ * @param ConnectionInterface $con
+ *
+ * @return Integer Number of updated rows
+ * @see doSave()
+ */
+ protected function doUpdate(ConnectionInterface $con)
+ {
+ $selectCriteria = $this->buildPkeyCriteria();
+ $valuesCriteria = $this->buildCriteria();
+
+ return $selectCriteria->doUpdate($valuesCriteria, $con);
+ }
+
+ /**
+ * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return mixed Value of field.
+ */
+ public function getByName($name, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = TaxRuleI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
+ $field = $this->getByPosition($pos);
+
+ return $field;
+ }
+
+ /**
+ * 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->getLocale();
+ 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
+ * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
+ * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
+ *
+ * @return array an associative array containing the field names (as keys) and field values
+ */
+ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
+ {
+ if (isset($alreadyDumpedObjects['TaxRuleI18n'][serialize($this->getPrimaryKey())])) {
+ return '*RECURSION*';
+ }
+ $alreadyDumpedObjects['TaxRuleI18n'][serialize($this->getPrimaryKey())] = true;
+ $keys = TaxRuleI18nTableMap::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getLocale(),
+ );
+ $virtualColumns = $this->virtualColumns;
+ foreach($virtualColumns as $key => $virtualColumn)
+ {
+ $result[$key] = $virtualColumn;
+ }
+
+ if ($includeForeignObjects) {
+ if (null !== $this->aTaxRule) {
+ $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string $name
+ * @param mixed $value field value
+ * @param string $type The type of fieldname the $name is of:
+ * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * Defaults to TableMap::TYPE_PHPNAME.
+ * @return void
+ */
+ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
+ {
+ $pos = TaxRuleI18nTableMap::translateFieldName($name, $type, TableMap::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->setLocale($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ * The default key type is the column's TableMap::TYPE_PHPNAME.
+ *
+ * @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 = TableMap::TYPE_PHPNAME)
+ {
+ $keys = TaxRuleI18nTableMap::getFieldNames($keyType);
+
+ if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+ if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
+ }
+
+ /**
+ * 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(TaxRuleI18nTableMap::DATABASE_NAME);
+
+ if ($this->isColumnModified(TaxRuleI18nTableMap::ID)) $criteria->add(TaxRuleI18nTableMap::ID, $this->id);
+ if ($this->isColumnModified(TaxRuleI18nTableMap::LOCALE)) $criteria->add(TaxRuleI18nTableMap::LOCALE, $this->locale);
+
+ 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(TaxRuleI18nTableMap::DATABASE_NAME);
+ $criteria->add(TaxRuleI18nTableMap::ID, $this->id);
+ $criteria->add(TaxRuleI18nTableMap::LOCALE, $this->locale);
+
+ return $criteria;
+ }
+
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ $pks = array();
+ $pks[0] = $this->getId();
+ $pks[1] = $this->getLocale();
+
+ return $pks;
+ }
+
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array $keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey($keys)
+ {
+ $this->setId($keys[0]);
+ $this->setLocale($keys[1]);
+ }
+
+ /**
+ * Returns true if the primary key for this object is null.
+ * @return boolean
+ */
+ public function isPrimaryKeyNull()
+ {
+
+ return (null === $this->getId()) && (null === $this->getLocale());
+ }
+
+ /**
+ * 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 \Thelia\Model\TaxRuleI18n (or compatible) type.
+ * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
+ * @throws PropelException
+ */
+ public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
+ {
+ $copyObj->setId($this->getId());
+ $copyObj->setLocale($this->getLocale());
+ if ($makeNew) {
+ $copyObj->setNew(true);
+ }
+ }
+
+ /**
+ * 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 \Thelia\Model\TaxRuleI18n 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;
+ }
+
+ /**
+ * Declares an association between this object and a ChildTaxRule object.
+ *
+ * @param ChildTaxRule $v
+ * @return \Thelia\Model\TaxRuleI18n The current object (for fluent API support)
+ * @throws PropelException
+ */
+ public function setTaxRule(ChildTaxRule $v = null)
+ {
+ if ($v === null) {
+ $this->setId(NULL);
+ } else {
+ $this->setId($v->getId());
+ }
+
+ $this->aTaxRule = $v;
+
+ // Add binding for other direction of this n:n relationship.
+ // If this object has already been added to the ChildTaxRule object, it will not be re-added.
+ if ($v !== null) {
+ $v->addTaxRuleI18n($this);
+ }
+
+
+ return $this;
+ }
+
+
+ /**
+ * Get the associated ChildTaxRule object
+ *
+ * @param ConnectionInterface $con Optional Connection object.
+ * @return ChildTaxRule The associated ChildTaxRule object.
+ * @throws PropelException
+ */
+ public function getTaxRule(ConnectionInterface $con = null)
+ {
+ if ($this->aTaxRule === null && ($this->id !== null)) {
+ $this->aTaxRule = ChildTaxRuleQuery::create()->findPk($this->id, $con);
+ /* The following can be used additionally to
+ guarantee the related object contains a reference
+ to this object. This level of coupling may, however, be
+ undesirable since it could result in an only partially populated collection
+ in the referenced object.
+ $this->aTaxRule->addTaxRuleI18ns($this);
+ */
+ }
+
+ return $this->aTaxRule;
+ }
+
+ /**
+ * Clears the current object and sets all attributes to their default values
+ */
+ public function clear()
+ {
+ $this->id = null;
+ $this->locale = null;
+ $this->alreadyInSave = false;
+ $this->clearAllReferences();
+ $this->applyDefaultValues();
+ $this->resetModified();
+ $this->setNew(true);
+ $this->setDeleted(false);
+ }
+
+ /**
+ * Resets all references to other model objects or collections of model objects.
+ *
+ * This method is a user-space workaround for PHP's inability to garbage collect
+ * objects with circular references (even in PHP 5.3). This is currently necessary
+ * when using Propel in certain daemon or large-volume/high-memory operations.
+ *
+ * @param boolean $deep Whether to also clear the references on all referrer objects.
+ */
+ public function clearAllReferences($deep = false)
+ {
+ if ($deep) {
+ } // if ($deep)
+
+ $this->aTaxRule = null;
+ }
+
+ /**
+ * Return the string representation of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return (string) $this->exportTo(TaxRuleI18nTableMap::DEFAULT_STRING_FORMAT);
+ }
+
+ /**
+ * Code to be run before persisting the object
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preSave(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after persisting the object
+ * @param ConnectionInterface $con
+ */
+ public function postSave(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before inserting to database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preInsert(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after inserting to database
+ * @param ConnectionInterface $con
+ */
+ public function postInsert(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before updating the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preUpdate(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after updating the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postUpdate(ConnectionInterface $con = null)
+ {
+
+ }
+
+ /**
+ * Code to be run before deleting the object in database
+ * @param ConnectionInterface $con
+ * @return boolean
+ */
+ public function preDelete(ConnectionInterface $con = null)
+ {
+ return true;
+ }
+
+ /**
+ * Code to be run after deleting the object in database
+ * @param ConnectionInterface $con
+ */
+ public function postDelete(ConnectionInterface $con = null)
+ {
+
+ }
+
+
+ /**
+ * Derived method to catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you overwrite __call()
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
+ public function __call($name, $params)
+ {
+ if (0 === strpos($name, 'get')) {
+ $virtualColumn = substr($name, 3);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+
+ $virtualColumn = lcfirst($virtualColumn);
+ if ($this->hasVirtualColumn($virtualColumn)) {
+ return $this->getVirtualColumn($virtualColumn);
+ }
+ }
+
+ if (0 === strpos($name, 'from')) {
+ $format = substr($name, 4);
+
+ return $this->importFrom($format, reset($params));
+ }
+
+ if (0 === strpos($name, 'to')) {
+ $format = substr($name, 2);
+ $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
+
+ return $this->exportTo($format, $includeLazyLoadColumns);
+ }
+
+ throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
+ }
+
+}
diff --git a/core/lib/Thelia/Model/Base/TaxRuleI18nQuery.php b/core/lib/Thelia/Model/Base/TaxRuleI18nQuery.php
new file mode 100644
index 000000000..02667f4ac
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/TaxRuleI18nQuery.php
@@ -0,0 +1,475 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(array(12, 34), $con);
+ *
+ *
+ * @param array[$id, $locale] $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildTaxRuleI18n|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = TaxRuleI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(TaxRuleI18nTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildTaxRuleI18n A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, LOCALE FROM tax_rule_i18n WHERE ID = :p0 AND LOCALE = :p1';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
+ $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildTaxRuleI18n();
+ $obj->hydrate($row);
+ TaxRuleI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildTaxRuleI18n|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildTaxRuleI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+ $this->addUsingAlias(TaxRuleI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $this->addUsingAlias(TaxRuleI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+
+ return $this;
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildTaxRuleI18nQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+ if (empty($keys)) {
+ return $this->add(null, '1<>1', Criteria::CUSTOM);
+ }
+ foreach ($keys as $key) {
+ $cton0 = $this->getNewCriterion(TaxRuleI18nTableMap::ID, $key[0], Criteria::EQUAL);
+ $cton1 = $this->getNewCriterion(TaxRuleI18nTableMap::LOCALE, $key[1], Criteria::EQUAL);
+ $cton0->addAnd($cton1);
+ $this->addOr($cton0);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @see filterByTaxRule()
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleI18nQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(TaxRuleI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(TaxRuleI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleI18nTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the locale column
+ *
+ * Example usage:
+ *
+ * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
+ * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
+ *
+ *
+ * @param string $locale The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleI18nQuery The current query, for fluid interface
+ */
+ public function filterByLocale($locale = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($locale)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $locale)) {
+ $locale = str_replace('*', '%', $locale);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleI18nTableMap::LOCALE, $locale, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\TaxRule object
+ *
+ * @param \Thelia\Model\TaxRule|ObjectCollection $taxRule The related object(s) to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleI18nQuery The current query, for fluid interface
+ */
+ public function filterByTaxRule($taxRule, $comparison = null)
+ {
+ if ($taxRule instanceof \Thelia\Model\TaxRule) {
+ return $this
+ ->addUsingAlias(TaxRuleI18nTableMap::ID, $taxRule->getId(), $comparison);
+ } elseif ($taxRule instanceof ObjectCollection) {
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+
+ return $this
+ ->addUsingAlias(TaxRuleI18nTableMap::ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison);
+ } else {
+ throw new PropelException('filterByTaxRule() only accepts arguments of type \Thelia\Model\TaxRule or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxRule relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildTaxRuleI18nQuery The current query, for fluid interface
+ */
+ public function joinTaxRule($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxRule');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'TaxRule');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxRule relation TaxRule object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\TaxRuleQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxRuleQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinTaxRule($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxRule', '\Thelia\Model\TaxRuleQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildTaxRuleI18n $taxRuleI18n Object to remove from the list of results
+ *
+ * @return ChildTaxRuleI18nQuery The current query, for fluid interface
+ */
+ public function prune($taxRuleI18n = null)
+ {
+ if ($taxRuleI18n) {
+ $this->addCond('pruneCond0', $this->getAliasedColName(TaxRuleI18nTableMap::ID), $taxRuleI18n->getId(), Criteria::NOT_EQUAL);
+ $this->addCond('pruneCond1', $this->getAliasedColName(TaxRuleI18nTableMap::LOCALE), $taxRuleI18n->getLocale(), Criteria::NOT_EQUAL);
+ $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the tax_rule_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleI18nTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ TaxRuleI18nTableMap::clearInstancePool();
+ TaxRuleI18nTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildTaxRuleI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildTaxRuleI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleI18nTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleI18nTableMap::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->beginTransaction();
+
+
+ TaxRuleI18nTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ TaxRuleI18nTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+} // TaxRuleI18nQuery
diff --git a/core/lib/Thelia/Model/Base/TaxRuleQuery.php b/core/lib/Thelia/Model/Base/TaxRuleQuery.php
new file mode 100644
index 000000000..36f2edd99
--- /dev/null
+++ b/core/lib/Thelia/Model/Base/TaxRuleQuery.php
@@ -0,0 +1,895 @@
+setModelAlias($modelAlias);
+ }
+ if ($criteria instanceof Criteria) {
+ $query->mergeWith($criteria);
+ }
+
+ return $query;
+ }
+
+ /**
+ * Find object by primary key.
+ * Propel uses the instance pool to skip the database if the object exists.
+ * Go fast if the query is untouched.
+ *
+ *
+ * $obj = $c->findPk(12, $con);
+ *
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ChildTaxRule|array|mixed the result, formatted by the current formatter
+ */
+ public function findPk($key, $con = null)
+ {
+ if ($key === null) {
+ return null;
+ }
+ if ((null !== ($obj = TaxRuleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
+ // the object is already in the instance pool
+ return $obj;
+ }
+ if ($con === null) {
+ $con = Propel::getServiceContainer()->getReadConnection(TaxRuleTableMap::DATABASE_NAME);
+ }
+ $this->basePreSelect($con);
+ if ($this->formatter || $this->modelAlias || $this->with || $this->select
+ || $this->selectColumns || $this->asColumns || $this->selectModifiers
+ || $this->map || $this->having || $this->joins) {
+ return $this->findPkComplex($key, $con);
+ } else {
+ return $this->findPkSimple($key, $con);
+ }
+ }
+
+ /**
+ * Find object by primary key using raw SQL to go fast.
+ * Bypass doSelect() and the object formatter by using generated code.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildTaxRule A model object, or null if the key is not found
+ */
+ protected function findPkSimple($key, $con)
+ {
+ $sql = 'SELECT ID, CODE, TITLE, DESCRIPTION, CREATED_AT, UPDATED_AT FROM tax_rule WHERE ID = :p0';
+ try {
+ $stmt = $con->prepare($sql);
+ $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
+ $stmt->execute();
+ } catch (Exception $e) {
+ Propel::log($e->getMessage(), Propel::LOG_ERR);
+ throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
+ }
+ $obj = null;
+ if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
+ $obj = new ChildTaxRule();
+ $obj->hydrate($row);
+ TaxRuleTableMap::addInstanceToPool($obj, (string) $key);
+ }
+ $stmt->closeCursor();
+
+ return $obj;
+ }
+
+ /**
+ * Find object by primary key.
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param ConnectionInterface $con A connection object
+ *
+ * @return ChildTaxRule|array|mixed the result, formatted by the current formatter
+ */
+ protected function findPkComplex($key, $con)
+ {
+ // As the query uses a PK condition, no limit(1) is necessary.
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKey($key)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
+ }
+
+ /**
+ * Find objects by primary key
+ *
+ * $objs = $c->findPks(array(12, 56, 832), $con);
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param ConnectionInterface $con an optional connection object
+ *
+ * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
+ */
+ public function findPks($keys, $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
+ }
+ $this->basePreSelect($con);
+ $criteria = $this->isKeepQuery() ? clone $this : $this;
+ $dataFetcher = $criteria
+ ->filterByPrimaryKeys($keys)
+ ->doSelect($con);
+
+ return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
+ }
+
+ /**
+ * Filter the query by primary key
+ *
+ * @param mixed $key Primary key to use for the query
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKey($key)
+ {
+
+ return $this->addUsingAlias(TaxRuleTableMap::ID, $key, Criteria::EQUAL);
+ }
+
+ /**
+ * Filter the query by a list of primary keys
+ *
+ * @param array $keys The list of primary key to use for the query
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByPrimaryKeys($keys)
+ {
+
+ return $this->addUsingAlias(TaxRuleTableMap::ID, $keys, Criteria::IN);
+ }
+
+ /**
+ * Filter the query on the id column
+ *
+ * Example usage:
+ *
+ * $query->filterById(1234); // WHERE id = 1234
+ * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
+ * $query->filterById(array('min' => 12)); // WHERE id > 12
+ *
+ *
+ * @param mixed $id The value to use as filter.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function filterById($id = null, $comparison = null)
+ {
+ if (is_array($id)) {
+ $useMinMax = false;
+ if (isset($id['min'])) {
+ $this->addUsingAlias(TaxRuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($id['max'])) {
+ $this->addUsingAlias(TaxRuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleTableMap::ID, $id, $comparison);
+ }
+
+ /**
+ * Filter the query on the code column
+ *
+ * Example usage:
+ *
+ * $query->filterByCode('fooValue'); // WHERE code = 'fooValue'
+ * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%'
+ *
+ *
+ * @param string $code The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByCode($code = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($code)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $code)) {
+ $code = str_replace('*', '%', $code);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleTableMap::CODE, $code, $comparison);
+ }
+
+ /**
+ * Filter the query on the title column
+ *
+ * Example usage:
+ *
+ * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue'
+ * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
+ *
+ *
+ * @param string $title The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByTitle($title = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($title)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $title)) {
+ $title = str_replace('*', '%', $title);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleTableMap::TITLE, $title, $comparison);
+ }
+
+ /**
+ * Filter the query on the description column
+ *
+ * Example usage:
+ *
+ * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue'
+ * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
+ *
+ *
+ * @param string $description The value to use as filter.
+ * Accepts wildcards (* and % trigger a LIKE)
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByDescription($description = null, $comparison = null)
+ {
+ if (null === $comparison) {
+ if (is_array($description)) {
+ $comparison = Criteria::IN;
+ } elseif (preg_match('/[\%\*]/', $description)) {
+ $description = str_replace('*', '%', $description);
+ $comparison = Criteria::LIKE;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleTableMap::DESCRIPTION, $description, $comparison);
+ }
+
+ /**
+ * Filter the query on the created_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
+ * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
+ *
+ *
+ * @param mixed $createdAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByCreatedAt($createdAt = null, $comparison = null)
+ {
+ if (is_array($createdAt)) {
+ $useMinMax = false;
+ if (isset($createdAt['min'])) {
+ $this->addUsingAlias(TaxRuleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($createdAt['max'])) {
+ $this->addUsingAlias(TaxRuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleTableMap::CREATED_AT, $createdAt, $comparison);
+ }
+
+ /**
+ * Filter the query on the updated_at column
+ *
+ * Example usage:
+ *
+ * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
+ * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
+ *
+ *
+ * @param mixed $updatedAt The value to use as filter.
+ * Values can be integers (unix timestamps), DateTime objects, or strings.
+ * Empty strings are treated as NULL.
+ * Use scalar values for equality.
+ * Use array values for in_array() equivalent.
+ * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByUpdatedAt($updatedAt = null, $comparison = null)
+ {
+ if (is_array($updatedAt)) {
+ $useMinMax = false;
+ if (isset($updatedAt['min'])) {
+ $this->addUsingAlias(TaxRuleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
+ $useMinMax = true;
+ }
+ if (isset($updatedAt['max'])) {
+ $this->addUsingAlias(TaxRuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
+ $useMinMax = true;
+ }
+ if ($useMinMax) {
+ return $this;
+ }
+ if (null === $comparison) {
+ $comparison = Criteria::IN;
+ }
+ }
+
+ return $this->addUsingAlias(TaxRuleTableMap::UPDATED_AT, $updatedAt, $comparison);
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\Product object
+ *
+ * @param \Thelia\Model\Product|ObjectCollection $product the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByProduct($product, $comparison = null)
+ {
+ if ($product instanceof \Thelia\Model\Product) {
+ return $this
+ ->addUsingAlias(TaxRuleTableMap::ID, $product->getTaxRuleId(), $comparison);
+ } elseif ($product instanceof ObjectCollection) {
+ return $this
+ ->useProductQuery()
+ ->filterByPrimaryKeys($product->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the Product relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('Product');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'Product');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the Product relation Product object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query
+ */
+ public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinProduct($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\TaxRuleCountry object
+ *
+ * @param \Thelia\Model\TaxRuleCountry|ObjectCollection $taxRuleCountry the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null)
+ {
+ if ($taxRuleCountry instanceof \Thelia\Model\TaxRuleCountry) {
+ return $this
+ ->addUsingAlias(TaxRuleTableMap::ID, $taxRuleCountry->getTaxRuleId(), $comparison);
+ } elseif ($taxRuleCountry instanceof ObjectCollection) {
+ return $this
+ ->useTaxRuleCountryQuery()
+ ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type \Thelia\Model\TaxRuleCountry or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxRuleCountry relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxRuleCountry');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'TaxRuleCountry');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxRuleCountry relation TaxRuleCountry object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinTaxRuleCountry($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxRuleCountry', '\Thelia\Model\TaxRuleCountryQuery');
+ }
+
+ /**
+ * Filter the query by a related \Thelia\Model\TaxRuleI18n object
+ *
+ * @param \Thelia\Model\TaxRuleI18n|ObjectCollection $taxRuleI18n the related object to use as filter
+ * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function filterByTaxRuleI18n($taxRuleI18n, $comparison = null)
+ {
+ if ($taxRuleI18n instanceof \Thelia\Model\TaxRuleI18n) {
+ return $this
+ ->addUsingAlias(TaxRuleTableMap::ID, $taxRuleI18n->getId(), $comparison);
+ } elseif ($taxRuleI18n instanceof ObjectCollection) {
+ return $this
+ ->useTaxRuleI18nQuery()
+ ->filterByPrimaryKeys($taxRuleI18n->getPrimaryKeys())
+ ->endUse();
+ } else {
+ throw new PropelException('filterByTaxRuleI18n() only accepts arguments of type \Thelia\Model\TaxRuleI18n or Collection');
+ }
+ }
+
+ /**
+ * Adds a JOIN clause to the query using the TaxRuleI18n relation
+ *
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function joinTaxRuleI18n($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ $tableMap = $this->getTableMap();
+ $relationMap = $tableMap->getRelation('TaxRuleI18n');
+
+ // create a ModelJoin object for this join
+ $join = new ModelJoin();
+ $join->setJoinType($joinType);
+ $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
+ if ($previousJoin = $this->getPreviousJoin()) {
+ $join->setPreviousJoin($previousJoin);
+ }
+
+ // add the ModelJoin to the current object
+ if ($relationAlias) {
+ $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
+ $this->addJoinObject($join, $relationAlias);
+ } else {
+ $this->addJoinObject($join, 'TaxRuleI18n');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Use the TaxRuleI18n relation TaxRuleI18n object
+ *
+ * @see useQuery()
+ *
+ * @param string $relationAlias optional alias for the relation,
+ * to be used as main alias in the secondary query
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ *
+ * @return \Thelia\Model\TaxRuleI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useTaxRuleI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN')
+ {
+ return $this
+ ->joinTaxRuleI18n($relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxRuleI18n', '\Thelia\Model\TaxRuleI18nQuery');
+ }
+
+ /**
+ * Exclude object from result
+ *
+ * @param ChildTaxRule $taxRule Object to remove from the list of results
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function prune($taxRule = null)
+ {
+ if ($taxRule) {
+ $this->addUsingAlias(TaxRuleTableMap::ID, $taxRule->getId(), Criteria::NOT_EQUAL);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Deletes all rows from the tax_rule table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public function doDeleteAll(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleTableMap::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->beginTransaction();
+ $affectedRows += parent::doDeleteAll($con);
+ // Because this db requires some delete cascade/set null emulation, we have to
+ // clear the cached instance *after* the emulation has happened (since
+ // instances get re-added by the select statement contained therein).
+ TaxRuleTableMap::clearInstancePool();
+ TaxRuleTableMap::clearRelatedInstancePool();
+
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ChildTaxRule or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ChildTaxRule object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleTableMap::DATABASE_NAME);
+ }
+
+ $criteria = $this;
+
+ // Set the correct dbName
+ $criteria->setDbName(TaxRuleTableMap::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->beginTransaction();
+
+
+ TaxRuleTableMap::removeInstanceFromPool($criteria);
+
+ $affectedRows += ModelCriteria::delete($con);
+ TaxRuleTableMap::clearRelatedInstancePool();
+ $con->commit();
+
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+ }
+
+ // timestampable behavior
+
+ /**
+ * Filter by the latest updated
+ *
+ * @param int $nbDays Maximum age of the latest update in days
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function recentlyUpdated($nbDays = 7)
+ {
+ return $this->addUsingAlias(TaxRuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Filter by the latest created
+ *
+ * @param int $nbDays Maximum age of in days
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function recentlyCreated($nbDays = 7)
+ {
+ return $this->addUsingAlias(TaxRuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
+ }
+
+ /**
+ * Order by update date desc
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function lastUpdatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(TaxRuleTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by update date asc
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function firstUpdatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(TaxRuleTableMap::UPDATED_AT);
+ }
+
+ /**
+ * Order by create date desc
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function lastCreatedFirst()
+ {
+ return $this->addDescendingOrderByColumn(TaxRuleTableMap::CREATED_AT);
+ }
+
+ /**
+ * Order by create date asc
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function firstCreatedFirst()
+ {
+ return $this->addAscendingOrderByColumn(TaxRuleTableMap::CREATED_AT);
+ }
+
+ // i18n behavior
+
+ /**
+ * Adds a JOIN clause to the query using the i18n relation
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ $relationName = $relationAlias ? $relationAlias : 'TaxRuleI18n';
+
+ return $this
+ ->joinTaxRuleI18n($relationAlias, $joinType)
+ ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale);
+ }
+
+ /**
+ * Adds a JOIN clause to the query and hydrates the related I18n object.
+ * Shortcut for $c->joinI18n($locale)->with()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildTaxRuleQuery The current query, for fluid interface
+ */
+ public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN)
+ {
+ $this
+ ->joinI18n($locale, null, $joinType)
+ ->with('TaxRuleI18n');
+ $this->with['TaxRuleI18n']->setIsWithOneToMany(false);
+
+ return $this;
+ }
+
+ /**
+ * Use the I18n relation query object
+ *
+ * @see useQuery()
+ *
+ * @param string $locale Locale to use for the join condition, e.g. 'fr_FR'
+ * @param string $relationAlias optional alias for the relation
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join.
+ *
+ * @return ChildTaxRuleI18nQuery A secondary query class using the current class as primary query
+ */
+ public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+ {
+ return $this
+ ->joinI18n($locale, $relationAlias, $joinType)
+ ->useQuery($relationAlias ? $relationAlias : 'TaxRuleI18n', '\Thelia\Model\TaxRuleI18nQuery');
+ }
+
+} // TaxRuleQuery
diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php
index e9c06a477..e6cf6f18c 100644
--- a/core/lib/Thelia/Model/Customer.php
+++ b/core/lib/Thelia/Model/Customer.php
@@ -3,6 +3,7 @@
namespace Thelia\Model;
use Thelia\Model\Base\Customer as BaseCustomer;
+
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Thelia\Core\Event\CustomRefEvent;
diff --git a/core/lib/Thelia/Model/Map/AccessoryTableMap.php b/core/lib/Thelia/Model/Map/AccessoryTableMap.php
new file mode 100644
index 000000000..80c0548ef
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/AccessoryTableMap.php
@@ -0,0 +1,453 @@
+ array('Id', 'ProductId', 'Accessory', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'accessory', 'position', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(AccessoryTableMap::ID, AccessoryTableMap::PRODUCT_ID, AccessoryTableMap::ACCESSORY, AccessoryTableMap::POSITION, AccessoryTableMap::CREATED_AT, AccessoryTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'ACCESSORY', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'product_id', 'accessory', 'position', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Accessory' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'accessory' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ self::TYPE_COLNAME => array(AccessoryTableMap::ID => 0, AccessoryTableMap::PRODUCT_ID => 1, AccessoryTableMap::ACCESSORY => 2, AccessoryTableMap::POSITION => 3, AccessoryTableMap::CREATED_AT => 4, AccessoryTableMap::UPDATED_AT => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'ACCESSORY' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'accessory' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('accessory');
+ $this->setPhpName('Accessory');
+ $this->setClassName('\\Thelia\\Model\\Accessory');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ $this->setIsCrossRef(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
+ $this->addForeignKey('ACCESSORY', 'Accessory', 'INTEGER', 'product', 'ID', true, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('ProductRelatedByProductId', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('ProductRelatedByAccessory', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('accessory' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? AccessoryTableMap::CLASS_DEFAULT : AccessoryTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Accessory object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = AccessoryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = AccessoryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + AccessoryTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AccessoryTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ AccessoryTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = AccessoryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = AccessoryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AccessoryTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AccessoryTableMap::ID);
+ $criteria->addSelectColumn(AccessoryTableMap::PRODUCT_ID);
+ $criteria->addSelectColumn(AccessoryTableMap::ACCESSORY);
+ $criteria->addSelectColumn(AccessoryTableMap::POSITION);
+ $criteria->addSelectColumn(AccessoryTableMap::CREATED_AT);
+ $criteria->addSelectColumn(AccessoryTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.ACCESSORY');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(AccessoryTableMap::DATABASE_NAME)->getTable(AccessoryTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(AccessoryTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(AccessoryTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new AccessoryTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Accessory or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Accessory object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AccessoryTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Accessory) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(AccessoryTableMap::DATABASE_NAME);
+ $criteria->add(AccessoryTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = AccessoryQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { AccessoryTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { AccessoryTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the accessory table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return AccessoryQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Accessory or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Accessory object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AccessoryTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Accessory object
+ }
+
+
+ // Set the correct dbName
+ $query = AccessoryQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // AccessoryTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+AccessoryTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/AddressTableMap.php b/core/lib/Thelia/Model/Map/AddressTableMap.php
new file mode 100644
index 000000000..8a6126964
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/AddressTableMap.php
@@ -0,0 +1,536 @@
+ array('Id', 'Title', 'CustomerId', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'title', 'customerId', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(AddressTableMap::ID, AddressTableMap::TITLE, AddressTableMap::CUSTOMER_ID, AddressTableMap::CUSTOMER_TITLE_ID, AddressTableMap::COMPANY, AddressTableMap::FIRSTNAME, AddressTableMap::LASTNAME, AddressTableMap::ADDRESS1, AddressTableMap::ADDRESS2, AddressTableMap::ADDRESS3, AddressTableMap::ZIPCODE, AddressTableMap::CITY, AddressTableMap::COUNTRY_ID, AddressTableMap::PHONE, AddressTableMap::CREATED_AT, AddressTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'TITLE', 'CUSTOMER_ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'title', 'customer_id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Title' => 1, 'CustomerId' => 2, 'CustomerTitleId' => 3, 'Company' => 4, 'Firstname' => 5, 'Lastname' => 6, 'Address1' => 7, 'Address2' => 8, 'Address3' => 9, 'Zipcode' => 10, 'City' => 11, 'CountryId' => 12, 'Phone' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'title' => 1, 'customerId' => 2, 'customerTitleId' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'countryId' => 12, 'phone' => 13, 'createdAt' => 14, 'updatedAt' => 15, ),
+ self::TYPE_COLNAME => array(AddressTableMap::ID => 0, AddressTableMap::TITLE => 1, AddressTableMap::CUSTOMER_ID => 2, AddressTableMap::CUSTOMER_TITLE_ID => 3, AddressTableMap::COMPANY => 4, AddressTableMap::FIRSTNAME => 5, AddressTableMap::LASTNAME => 6, AddressTableMap::ADDRESS1 => 7, AddressTableMap::ADDRESS2 => 8, AddressTableMap::ADDRESS3 => 9, AddressTableMap::ZIPCODE => 10, AddressTableMap::CITY => 11, AddressTableMap::COUNTRY_ID => 12, AddressTableMap::PHONE => 13, AddressTableMap::CREATED_AT => 14, AddressTableMap::UPDATED_AT => 15, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'TITLE' => 1, 'CUSTOMER_ID' => 2, 'CUSTOMER_TITLE_ID' => 3, 'COMPANY' => 4, 'FIRSTNAME' => 5, 'LASTNAME' => 6, 'ADDRESS1' => 7, 'ADDRESS2' => 8, 'ADDRESS3' => 9, 'ZIPCODE' => 10, 'CITY' => 11, 'COUNTRY_ID' => 12, 'PHONE' => 13, 'CREATED_AT' => 14, 'UPDATED_AT' => 15, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'title' => 1, 'customer_id' => 2, 'customer_title_id' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'country_id' => 12, 'phone' => 13, 'created_at' => 14, 'updated_at' => 15, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('address');
+ $this->setPhpName('Address');
+ $this->setClassName('\\Thelia\\Model\\Address');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null);
+ $this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', false, null, null);
+ $this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null);
+ $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null);
+ $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS1', 'Address1', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS2', 'Address2', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS3', 'Address3', 'VARCHAR', true, 255, null);
+ $this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', true, 10, null);
+ $this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null);
+ $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null);
+ $this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'RESTRICT', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? AddressTableMap::CLASS_DEFAULT : AddressTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Address object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = AddressTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = AddressTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + AddressTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AddressTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ AddressTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = AddressTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = AddressTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AddressTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AddressTableMap::ID);
+ $criteria->addSelectColumn(AddressTableMap::TITLE);
+ $criteria->addSelectColumn(AddressTableMap::CUSTOMER_ID);
+ $criteria->addSelectColumn(AddressTableMap::CUSTOMER_TITLE_ID);
+ $criteria->addSelectColumn(AddressTableMap::COMPANY);
+ $criteria->addSelectColumn(AddressTableMap::FIRSTNAME);
+ $criteria->addSelectColumn(AddressTableMap::LASTNAME);
+ $criteria->addSelectColumn(AddressTableMap::ADDRESS1);
+ $criteria->addSelectColumn(AddressTableMap::ADDRESS2);
+ $criteria->addSelectColumn(AddressTableMap::ADDRESS3);
+ $criteria->addSelectColumn(AddressTableMap::ZIPCODE);
+ $criteria->addSelectColumn(AddressTableMap::CITY);
+ $criteria->addSelectColumn(AddressTableMap::COUNTRY_ID);
+ $criteria->addSelectColumn(AddressTableMap::PHONE);
+ $criteria->addSelectColumn(AddressTableMap::CREATED_AT);
+ $criteria->addSelectColumn(AddressTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_ID');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID');
+ $criteria->addSelectColumn($alias . '.COMPANY');
+ $criteria->addSelectColumn($alias . '.FIRSTNAME');
+ $criteria->addSelectColumn($alias . '.LASTNAME');
+ $criteria->addSelectColumn($alias . '.ADDRESS1');
+ $criteria->addSelectColumn($alias . '.ADDRESS2');
+ $criteria->addSelectColumn($alias . '.ADDRESS3');
+ $criteria->addSelectColumn($alias . '.ZIPCODE');
+ $criteria->addSelectColumn($alias . '.CITY');
+ $criteria->addSelectColumn($alias . '.COUNTRY_ID');
+ $criteria->addSelectColumn($alias . '.PHONE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(AddressTableMap::DATABASE_NAME)->getTable(AddressTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(AddressTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(AddressTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new AddressTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Address or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Address object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AddressTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Address) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(AddressTableMap::DATABASE_NAME);
+ $criteria->add(AddressTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = AddressQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { AddressTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { AddressTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the address table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return AddressQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Address or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Address object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AddressTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Address object
+ }
+
+ if ($criteria->containsKey(AddressTableMap::ID) && $criteria->keyContainsValue(AddressTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AddressTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = AddressQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // AddressTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+AddressTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/AdminGroupTableMap.php b/core/lib/Thelia/Model/Map/AdminGroupTableMap.php
new file mode 100644
index 000000000..78f06d1c2
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/AdminGroupTableMap.php
@@ -0,0 +1,509 @@
+ array('Id', 'GroupId', 'AdminId', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'groupId', 'adminId', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(AdminGroupTableMap::ID, AdminGroupTableMap::GROUP_ID, AdminGroupTableMap::ADMIN_ID, AdminGroupTableMap::CREATED_AT, AdminGroupTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'GROUP_ID', 'ADMIN_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'group_id', 'admin_id', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'GroupId' => 1, 'AdminId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'groupId' => 1, 'adminId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ self::TYPE_COLNAME => array(AdminGroupTableMap::ID => 0, AdminGroupTableMap::GROUP_ID => 1, AdminGroupTableMap::ADMIN_ID => 2, AdminGroupTableMap::CREATED_AT => 3, AdminGroupTableMap::UPDATED_AT => 4, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'GROUP_ID' => 1, 'ADMIN_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'group_id' => 1, 'admin_id' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('admin_group');
+ $this->setPhpName('AdminGroup');
+ $this->setClassName('\\Thelia\\Model\\AdminGroup');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ $this->setIsCrossRef(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignPrimaryKey('GROUP_ID', 'GroupId', 'INTEGER' , 'group', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('ADMIN_ID', 'AdminId', 'INTEGER' , 'admin', 'ID', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Group', '\\Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Admin', '\\Thelia\\Model\\Admin', RelationMap::MANY_TO_ONE, array('admin_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\AdminGroup $obj A \Thelia\Model\AdminGroup object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getGroupId(), (string) $obj->getAdminId()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\AdminGroup object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\AdminGroup) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getGroupId(), (string) $value->getAdminId()));
+
+ } elseif (is_array($value) && count($value) === 3) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1], (string) $value[2]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\AdminGroup object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('AdminId', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('AdminId', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? AdminGroupTableMap::CLASS_DEFAULT : AdminGroupTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (AdminGroup object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = AdminGroupTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = AdminGroupTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + AdminGroupTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AdminGroupTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ AdminGroupTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = AdminGroupTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = AdminGroupTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AdminGroupTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AdminGroupTableMap::ID);
+ $criteria->addSelectColumn(AdminGroupTableMap::GROUP_ID);
+ $criteria->addSelectColumn(AdminGroupTableMap::ADMIN_ID);
+ $criteria->addSelectColumn(AdminGroupTableMap::CREATED_AT);
+ $criteria->addSelectColumn(AdminGroupTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.GROUP_ID');
+ $criteria->addSelectColumn($alias . '.ADMIN_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(AdminGroupTableMap::DATABASE_NAME)->getTable(AdminGroupTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(AdminGroupTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(AdminGroupTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new AdminGroupTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a AdminGroup or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or AdminGroup object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\AdminGroup) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(AdminGroupTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(AdminGroupTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(AdminGroupTableMap::GROUP_ID, $value[1]));
+ $criterion->addAnd($criteria->getNewCriterion(AdminGroupTableMap::ADMIN_ID, $value[2]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = AdminGroupQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { AdminGroupTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { AdminGroupTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the admin_group table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return AdminGroupQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a AdminGroup or Criteria object.
+ *
+ * @param mixed $criteria Criteria or AdminGroup object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from AdminGroup object
+ }
+
+ if ($criteria->containsKey(AdminGroupTableMap::ID) && $criteria->keyContainsValue(AdminGroupTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AdminGroupTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = AdminGroupQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // AdminGroupTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+AdminGroupTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/AdminLogTableMap.php b/core/lib/Thelia/Model/Map/AdminLogTableMap.php
new file mode 100644
index 000000000..633d6b4e9
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/AdminLogTableMap.php
@@ -0,0 +1,470 @@
+ array('Id', 'AdminLogin', 'AdminFirstname', 'AdminLastname', 'Action', 'Request', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'adminLogin', 'adminFirstname', 'adminLastname', 'action', 'request', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(AdminLogTableMap::ID, AdminLogTableMap::ADMIN_LOGIN, AdminLogTableMap::ADMIN_FIRSTNAME, AdminLogTableMap::ADMIN_LASTNAME, AdminLogTableMap::ACTION, AdminLogTableMap::REQUEST, AdminLogTableMap::CREATED_AT, AdminLogTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'ADMIN_LOGIN', 'ADMIN_FIRSTNAME', 'ADMIN_LASTNAME', 'ACTION', 'REQUEST', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'admin_login', 'admin_firstname', 'admin_lastname', 'action', 'request', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'AdminLogin' => 1, 'AdminFirstname' => 2, 'AdminLastname' => 3, 'Action' => 4, 'Request' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'adminLogin' => 1, 'adminFirstname' => 2, 'adminLastname' => 3, 'action' => 4, 'request' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ self::TYPE_COLNAME => array(AdminLogTableMap::ID => 0, AdminLogTableMap::ADMIN_LOGIN => 1, AdminLogTableMap::ADMIN_FIRSTNAME => 2, AdminLogTableMap::ADMIN_LASTNAME => 3, AdminLogTableMap::ACTION => 4, AdminLogTableMap::REQUEST => 5, AdminLogTableMap::CREATED_AT => 6, AdminLogTableMap::UPDATED_AT => 7, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'ADMIN_LOGIN' => 1, 'ADMIN_FIRSTNAME' => 2, 'ADMIN_LASTNAME' => 3, 'ACTION' => 4, 'REQUEST' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'admin_login' => 1, 'admin_firstname' => 2, 'admin_lastname' => 3, 'action' => 4, 'request' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('admin_log');
+ $this->setPhpName('AdminLog');
+ $this->setClassName('\\Thelia\\Model\\AdminLog');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('ADMIN_LOGIN', 'AdminLogin', 'VARCHAR', false, 255, null);
+ $this->addColumn('ADMIN_FIRSTNAME', 'AdminFirstname', 'VARCHAR', false, 255, null);
+ $this->addColumn('ADMIN_LASTNAME', 'AdminLastname', 'VARCHAR', false, 255, null);
+ $this->addColumn('ACTION', 'Action', 'VARCHAR', false, 255, null);
+ $this->addColumn('REQUEST', 'Request', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? AdminLogTableMap::CLASS_DEFAULT : AdminLogTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (AdminLog object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = AdminLogTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = AdminLogTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + AdminLogTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AdminLogTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ AdminLogTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = AdminLogTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = AdminLogTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AdminLogTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AdminLogTableMap::ID);
+ $criteria->addSelectColumn(AdminLogTableMap::ADMIN_LOGIN);
+ $criteria->addSelectColumn(AdminLogTableMap::ADMIN_FIRSTNAME);
+ $criteria->addSelectColumn(AdminLogTableMap::ADMIN_LASTNAME);
+ $criteria->addSelectColumn(AdminLogTableMap::ACTION);
+ $criteria->addSelectColumn(AdminLogTableMap::REQUEST);
+ $criteria->addSelectColumn(AdminLogTableMap::CREATED_AT);
+ $criteria->addSelectColumn(AdminLogTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.ADMIN_LOGIN');
+ $criteria->addSelectColumn($alias . '.ADMIN_FIRSTNAME');
+ $criteria->addSelectColumn($alias . '.ADMIN_LASTNAME');
+ $criteria->addSelectColumn($alias . '.ACTION');
+ $criteria->addSelectColumn($alias . '.REQUEST');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(AdminLogTableMap::DATABASE_NAME)->getTable(AdminLogTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(AdminLogTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(AdminLogTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new AdminLogTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a AdminLog or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or AdminLog object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminLogTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\AdminLog) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(AdminLogTableMap::DATABASE_NAME);
+ $criteria->add(AdminLogTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = AdminLogQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { AdminLogTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { AdminLogTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the admin_log table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return AdminLogQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a AdminLog or Criteria object.
+ *
+ * @param mixed $criteria Criteria or AdminLog object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminLogTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from AdminLog object
+ }
+
+ if ($criteria->containsKey(AdminLogTableMap::ID) && $criteria->keyContainsValue(AdminLogTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AdminLogTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = AdminLogQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // AdminLogTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+AdminLogTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/AdminTableMap.php b/core/lib/Thelia/Model/Map/AdminTableMap.php
new file mode 100644
index 000000000..39decf52c
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/AdminTableMap.php
@@ -0,0 +1,489 @@
+ array('Id', 'Firstname', 'Lastname', 'Login', 'Password', 'Algo', 'Salt', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'firstname', 'lastname', 'login', 'password', 'algo', 'salt', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(AdminTableMap::ID, AdminTableMap::FIRSTNAME, AdminTableMap::LASTNAME, AdminTableMap::LOGIN, AdminTableMap::PASSWORD, AdminTableMap::ALGO, AdminTableMap::SALT, AdminTableMap::CREATED_AT, AdminTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'FIRSTNAME', 'LASTNAME', 'LOGIN', 'PASSWORD', 'ALGO', 'SALT', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'firstname', 'lastname', 'login', 'password', 'algo', 'salt', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Firstname' => 1, 'Lastname' => 2, 'Login' => 3, 'Password' => 4, 'Algo' => 5, 'Salt' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'firstname' => 1, 'lastname' => 2, 'login' => 3, 'password' => 4, 'algo' => 5, 'salt' => 6, 'createdAt' => 7, 'updatedAt' => 8, ),
+ self::TYPE_COLNAME => array(AdminTableMap::ID => 0, AdminTableMap::FIRSTNAME => 1, AdminTableMap::LASTNAME => 2, AdminTableMap::LOGIN => 3, AdminTableMap::PASSWORD => 4, AdminTableMap::ALGO => 5, AdminTableMap::SALT => 6, AdminTableMap::CREATED_AT => 7, AdminTableMap::UPDATED_AT => 8, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'FIRSTNAME' => 1, 'LASTNAME' => 2, 'LOGIN' => 3, 'PASSWORD' => 4, 'ALGO' => 5, 'SALT' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'firstname' => 1, 'lastname' => 2, 'login' => 3, 'password' => 4, 'algo' => 5, 'salt' => 6, 'created_at' => 7, 'updated_at' => 8, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('admin');
+ $this->setPhpName('Admin');
+ $this->setClassName('\\Thelia\\Model\\Admin');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 100, null);
+ $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 100, null);
+ $this->addColumn('LOGIN', 'Login', 'VARCHAR', true, 100, null);
+ $this->addColumn('PASSWORD', 'Password', 'VARCHAR', true, 128, null);
+ $this->addColumn('ALGO', 'Algo', 'VARCHAR', false, 128, null);
+ $this->addColumn('SALT', 'Salt', 'VARCHAR', false, 128, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('AdminGroup', '\\Thelia\\Model\\AdminGroup', RelationMap::ONE_TO_MANY, array('id' => 'admin_id', ), 'CASCADE', 'RESTRICT', 'AdminGroups');
+ $this->addRelation('Group', '\\Thelia\\Model\\Group', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Groups');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to admin * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ AdminGroupTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? AdminTableMap::CLASS_DEFAULT : AdminTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Admin object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = AdminTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = AdminTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + AdminTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AdminTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ AdminTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = AdminTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = AdminTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AdminTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AdminTableMap::ID);
+ $criteria->addSelectColumn(AdminTableMap::FIRSTNAME);
+ $criteria->addSelectColumn(AdminTableMap::LASTNAME);
+ $criteria->addSelectColumn(AdminTableMap::LOGIN);
+ $criteria->addSelectColumn(AdminTableMap::PASSWORD);
+ $criteria->addSelectColumn(AdminTableMap::ALGO);
+ $criteria->addSelectColumn(AdminTableMap::SALT);
+ $criteria->addSelectColumn(AdminTableMap::CREATED_AT);
+ $criteria->addSelectColumn(AdminTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.FIRSTNAME');
+ $criteria->addSelectColumn($alias . '.LASTNAME');
+ $criteria->addSelectColumn($alias . '.LOGIN');
+ $criteria->addSelectColumn($alias . '.PASSWORD');
+ $criteria->addSelectColumn($alias . '.ALGO');
+ $criteria->addSelectColumn($alias . '.SALT');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(AdminTableMap::DATABASE_NAME)->getTable(AdminTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(AdminTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(AdminTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new AdminTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Admin or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Admin object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Admin) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(AdminTableMap::DATABASE_NAME);
+ $criteria->add(AdminTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = AdminQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { AdminTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { AdminTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the admin table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return AdminQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Admin or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Admin object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AdminTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Admin object
+ }
+
+ if ($criteria->containsKey(AdminTableMap::ID) && $criteria->keyContainsValue(AdminTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AdminTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = AdminQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // AdminTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+AdminTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/AreaTableMap.php b/core/lib/Thelia/Model/Map/AreaTableMap.php
new file mode 100644
index 000000000..9dc308de5
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/AreaTableMap.php
@@ -0,0 +1,458 @@
+ array('Id', 'Name', 'Unit', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'name', 'unit', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(AreaTableMap::ID, AreaTableMap::NAME, AreaTableMap::UNIT, AreaTableMap::CREATED_AT, AreaTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'UNIT', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'name', 'unit', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'Unit' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'unit' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ self::TYPE_COLNAME => array(AreaTableMap::ID => 0, AreaTableMap::NAME => 1, AreaTableMap::UNIT => 2, AreaTableMap::CREATED_AT => 3, AreaTableMap::UPDATED_AT => 4, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'UNIT' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'unit' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('area');
+ $this->setPhpName('Area');
+ $this->setClassName('\\Thelia\\Model\\Area');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('NAME', 'Name', 'VARCHAR', true, 100, null);
+ $this->addColumn('UNIT', 'Unit', 'FLOAT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Country', '\\Thelia\\Model\\Country', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', 'RESTRICT', 'Countries');
+ $this->addRelation('Delivzone', '\\Thelia\\Model\\Delivzone', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', 'RESTRICT', 'Delivzones');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to area * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CountryTableMap::clearInstancePool();
+ DelivzoneTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? AreaTableMap::CLASS_DEFAULT : AreaTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Area object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = AreaTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = AreaTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + AreaTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AreaTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ AreaTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = AreaTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = AreaTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AreaTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AreaTableMap::ID);
+ $criteria->addSelectColumn(AreaTableMap::NAME);
+ $criteria->addSelectColumn(AreaTableMap::UNIT);
+ $criteria->addSelectColumn(AreaTableMap::CREATED_AT);
+ $criteria->addSelectColumn(AreaTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.NAME');
+ $criteria->addSelectColumn($alias . '.UNIT');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(AreaTableMap::DATABASE_NAME)->getTable(AreaTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(AreaTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(AreaTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new AreaTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Area or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Area object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AreaTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Area) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(AreaTableMap::DATABASE_NAME);
+ $criteria->add(AreaTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = AreaQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { AreaTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { AreaTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the area table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return AreaQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Area or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Area object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AreaTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Area object
+ }
+
+ if ($criteria->containsKey(AreaTableMap::ID) && $criteria->keyContainsValue(AreaTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AreaTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = AreaQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // AreaTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+AreaTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php b/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php
new file mode 100644
index 000000000..14fc79eeb
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(AttributeAvI18nTableMap::ID, AttributeAvI18nTableMap::LOCALE, AttributeAvI18nTableMap::TITLE, AttributeAvI18nTableMap::DESCRIPTION, AttributeAvI18nTableMap::CHAPO, AttributeAvI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(AttributeAvI18nTableMap::ID => 0, AttributeAvI18nTableMap::LOCALE => 1, AttributeAvI18nTableMap::TITLE => 2, AttributeAvI18nTableMap::DESCRIPTION => 3, AttributeAvI18nTableMap::CHAPO => 4, AttributeAvI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('attribute_av_i18n');
+ $this->setPhpName('AttributeAvI18n');
+ $this->setClassName('\\Thelia\\Model\\AttributeAvI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_av', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('AttributeAv', '\\Thelia\\Model\\AttributeAv', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\AttributeAvI18n $obj A \Thelia\Model\AttributeAvI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\AttributeAvI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\AttributeAvI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\AttributeAvI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? AttributeAvI18nTableMap::CLASS_DEFAULT : AttributeAvI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (AttributeAvI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = AttributeAvI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = AttributeAvI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + AttributeAvI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AttributeAvI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ AttributeAvI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = AttributeAvI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = AttributeAvI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AttributeAvI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AttributeAvI18nTableMap::ID);
+ $criteria->addSelectColumn(AttributeAvI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(AttributeAvI18nTableMap::TITLE);
+ $criteria->addSelectColumn(AttributeAvI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(AttributeAvI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(AttributeAvI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(AttributeAvI18nTableMap::DATABASE_NAME)->getTable(AttributeAvI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeAvI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(AttributeAvI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new AttributeAvI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a AttributeAvI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or AttributeAvI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\AttributeAvI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(AttributeAvI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(AttributeAvI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(AttributeAvI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = AttributeAvI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { AttributeAvI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { AttributeAvI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the attribute_av_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return AttributeAvI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a AttributeAvI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or AttributeAvI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from AttributeAvI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = AttributeAvI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // AttributeAvI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+AttributeAvI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/AttributeAvTableMap.php b/core/lib/Thelia/Model/Map/AttributeAvTableMap.php
new file mode 100644
index 000000000..138f0fa9c
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/AttributeAvTableMap.php
@@ -0,0 +1,469 @@
+ array('Id', 'AttributeId', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'attributeId', 'position', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(AttributeAvTableMap::ID, AttributeAvTableMap::ATTRIBUTE_ID, AttributeAvTableMap::POSITION, AttributeAvTableMap::CREATED_AT, AttributeAvTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'ATTRIBUTE_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'attribute_id', 'position', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'AttributeId' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'attributeId' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ self::TYPE_COLNAME => array(AttributeAvTableMap::ID => 0, AttributeAvTableMap::ATTRIBUTE_ID => 1, AttributeAvTableMap::POSITION => 2, AttributeAvTableMap::CREATED_AT => 3, AttributeAvTableMap::UPDATED_AT => 4, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'ATTRIBUTE_ID' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'attribute_id' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('attribute_av');
+ $this->setPhpName('AttributeAv');
+ $this->setClassName('\\Thelia\\Model\\AttributeAv');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', 'attribute', 'ID', true, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Attribute', '\\Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('AttributeCombination', '\\Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'attribute_av_id', ), 'CASCADE', 'RESTRICT', 'AttributeCombinations');
+ $this->addRelation('AttributeAvI18n', '\\Thelia\\Model\\AttributeAvI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'AttributeAvI18ns');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to attribute_av * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ AttributeCombinationTableMap::clearInstancePool();
+ AttributeAvI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? AttributeAvTableMap::CLASS_DEFAULT : AttributeAvTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (AttributeAv object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = AttributeAvTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = AttributeAvTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + AttributeAvTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AttributeAvTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ AttributeAvTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = AttributeAvTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = AttributeAvTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AttributeAvTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AttributeAvTableMap::ID);
+ $criteria->addSelectColumn(AttributeAvTableMap::ATTRIBUTE_ID);
+ $criteria->addSelectColumn(AttributeAvTableMap::POSITION);
+ $criteria->addSelectColumn(AttributeAvTableMap::CREATED_AT);
+ $criteria->addSelectColumn(AttributeAvTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(AttributeAvTableMap::DATABASE_NAME)->getTable(AttributeAvTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeAvTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(AttributeAvTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new AttributeAvTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a AttributeAv or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or AttributeAv object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\AttributeAv) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(AttributeAvTableMap::DATABASE_NAME);
+ $criteria->add(AttributeAvTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = AttributeAvQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { AttributeAvTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { AttributeAvTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the attribute_av table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return AttributeAvQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a AttributeAv or Criteria object.
+ *
+ * @param mixed $criteria Criteria or AttributeAv object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from AttributeAv object
+ }
+
+ if ($criteria->containsKey(AttributeAvTableMap::ID) && $criteria->keyContainsValue(AttributeAvTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeAvTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = AttributeAvQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // AttributeAvTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+AttributeAvTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/AttributeCategoryTableMap.php b/core/lib/Thelia/Model/Map/AttributeCategoryTableMap.php
new file mode 100644
index 000000000..b2525e8c3
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/AttributeCategoryTableMap.php
@@ -0,0 +1,449 @@
+ array('Id', 'CategoryId', 'AttributeId', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'categoryId', 'attributeId', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(AttributeCategoryTableMap::ID, AttributeCategoryTableMap::CATEGORY_ID, AttributeCategoryTableMap::ATTRIBUTE_ID, AttributeCategoryTableMap::CREATED_AT, AttributeCategoryTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CATEGORY_ID', 'ATTRIBUTE_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'category_id', 'attribute_id', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'CategoryId' => 1, 'AttributeId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'categoryId' => 1, 'attributeId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ self::TYPE_COLNAME => array(AttributeCategoryTableMap::ID => 0, AttributeCategoryTableMap::CATEGORY_ID => 1, AttributeCategoryTableMap::ATTRIBUTE_ID => 2, AttributeCategoryTableMap::CREATED_AT => 3, AttributeCategoryTableMap::UPDATED_AT => 4, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CATEGORY_ID' => 1, 'ATTRIBUTE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'category_id' => 1, 'attribute_id' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('attribute_category');
+ $this->setPhpName('AttributeCategory');
+ $this->setClassName('\\Thelia\\Model\\AttributeCategory');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ $this->setIsCrossRef(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null);
+ $this->addForeignKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', 'attribute', 'ID', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Attribute', '\\Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? AttributeCategoryTableMap::CLASS_DEFAULT : AttributeCategoryTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (AttributeCategory object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = AttributeCategoryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = AttributeCategoryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + AttributeCategoryTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AttributeCategoryTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ AttributeCategoryTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = AttributeCategoryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = AttributeCategoryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AttributeCategoryTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AttributeCategoryTableMap::ID);
+ $criteria->addSelectColumn(AttributeCategoryTableMap::CATEGORY_ID);
+ $criteria->addSelectColumn(AttributeCategoryTableMap::ATTRIBUTE_ID);
+ $criteria->addSelectColumn(AttributeCategoryTableMap::CREATED_AT);
+ $criteria->addSelectColumn(AttributeCategoryTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(AttributeCategoryTableMap::DATABASE_NAME)->getTable(AttributeCategoryTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeCategoryTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(AttributeCategoryTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new AttributeCategoryTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a AttributeCategory or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or AttributeCategory object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\AttributeCategory) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(AttributeCategoryTableMap::DATABASE_NAME);
+ $criteria->add(AttributeCategoryTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = AttributeCategoryQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { AttributeCategoryTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { AttributeCategoryTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the attribute_category table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return AttributeCategoryQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a AttributeCategory or Criteria object.
+ *
+ * @param mixed $criteria Criteria or AttributeCategory object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from AttributeCategory object
+ }
+
+ if ($criteria->containsKey(AttributeCategoryTableMap::ID) && $criteria->keyContainsValue(AttributeCategoryTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeCategoryTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = AttributeCategoryQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // AttributeCategoryTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+AttributeCategoryTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/AttributeCombinationTableMap.php b/core/lib/Thelia/Model/Map/AttributeCombinationTableMap.php
new file mode 100644
index 000000000..b3e3584a4
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/AttributeCombinationTableMap.php
@@ -0,0 +1,518 @@
+ array('Id', 'AttributeId', 'CombinationId', 'AttributeAvId', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'attributeId', 'combinationId', 'attributeAvId', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(AttributeCombinationTableMap::ID, AttributeCombinationTableMap::ATTRIBUTE_ID, AttributeCombinationTableMap::COMBINATION_ID, AttributeCombinationTableMap::ATTRIBUTE_AV_ID, AttributeCombinationTableMap::CREATED_AT, AttributeCombinationTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'ATTRIBUTE_ID', 'COMBINATION_ID', 'ATTRIBUTE_AV_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'attribute_id', 'combination_id', 'attribute_av_id', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'AttributeId' => 1, 'CombinationId' => 2, 'AttributeAvId' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'attributeId' => 1, 'combinationId' => 2, 'attributeAvId' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ self::TYPE_COLNAME => array(AttributeCombinationTableMap::ID => 0, AttributeCombinationTableMap::ATTRIBUTE_ID => 1, AttributeCombinationTableMap::COMBINATION_ID => 2, AttributeCombinationTableMap::ATTRIBUTE_AV_ID => 3, AttributeCombinationTableMap::CREATED_AT => 4, AttributeCombinationTableMap::UPDATED_AT => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'ATTRIBUTE_ID' => 1, 'COMBINATION_ID' => 2, 'ATTRIBUTE_AV_ID' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'attribute_id' => 1, 'combination_id' => 2, 'attribute_av_id' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('attribute_combination');
+ $this->setPhpName('AttributeCombination');
+ $this->setClassName('\\Thelia\\Model\\AttributeCombination');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignPrimaryKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER' , 'attribute', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('COMBINATION_ID', 'CombinationId', 'INTEGER' , 'combination', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('ATTRIBUTE_AV_ID', 'AttributeAvId', 'INTEGER' , 'attribute_av', 'ID', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Attribute', '\\Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('AttributeAv', '\\Thelia\\Model\\AttributeAv', RelationMap::MANY_TO_ONE, array('attribute_av_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Combination', '\\Thelia\\Model\\Combination', RelationMap::MANY_TO_ONE, array('combination_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\AttributeCombination $obj A \Thelia\Model\AttributeCombination object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getAttributeId(), (string) $obj->getCombinationId(), (string) $obj->getAttributeAvId()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\AttributeCombination object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\AttributeCombination) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getAttributeId(), (string) $value->getCombinationId(), (string) $value->getAttributeAvId()));
+
+ } elseif (is_array($value) && count($value) === 4) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1], (string) $value[2], (string) $value[3]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\AttributeCombination object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('CombinationId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 3 + $offset : static::translateFieldName('AttributeAvId', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('CombinationId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 3 + $offset : static::translateFieldName('AttributeAvId', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? AttributeCombinationTableMap::CLASS_DEFAULT : AttributeCombinationTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (AttributeCombination object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = AttributeCombinationTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = AttributeCombinationTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + AttributeCombinationTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AttributeCombinationTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ AttributeCombinationTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = AttributeCombinationTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = AttributeCombinationTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AttributeCombinationTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AttributeCombinationTableMap::ID);
+ $criteria->addSelectColumn(AttributeCombinationTableMap::ATTRIBUTE_ID);
+ $criteria->addSelectColumn(AttributeCombinationTableMap::COMBINATION_ID);
+ $criteria->addSelectColumn(AttributeCombinationTableMap::ATTRIBUTE_AV_ID);
+ $criteria->addSelectColumn(AttributeCombinationTableMap::CREATED_AT);
+ $criteria->addSelectColumn(AttributeCombinationTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID');
+ $criteria->addSelectColumn($alias . '.COMBINATION_ID');
+ $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(AttributeCombinationTableMap::DATABASE_NAME)->getTable(AttributeCombinationTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeCombinationTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(AttributeCombinationTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new AttributeCombinationTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a AttributeCombination or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or AttributeCombination object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeCombinationTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\AttributeCombination) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(AttributeCombinationTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(AttributeCombinationTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(AttributeCombinationTableMap::ATTRIBUTE_ID, $value[1]));
+ $criterion->addAnd($criteria->getNewCriterion(AttributeCombinationTableMap::COMBINATION_ID, $value[2]));
+ $criterion->addAnd($criteria->getNewCriterion(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $value[3]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = AttributeCombinationQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { AttributeCombinationTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { AttributeCombinationTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the attribute_combination table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return AttributeCombinationQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a AttributeCombination or Criteria object.
+ *
+ * @param mixed $criteria Criteria or AttributeCombination object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeCombinationTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from AttributeCombination object
+ }
+
+ if ($criteria->containsKey(AttributeCombinationTableMap::ID) && $criteria->keyContainsValue(AttributeCombinationTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeCombinationTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = AttributeCombinationQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // AttributeCombinationTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+AttributeCombinationTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php b/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php
new file mode 100644
index 000000000..b60cae5b8
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(AttributeI18nTableMap::ID, AttributeI18nTableMap::LOCALE, AttributeI18nTableMap::TITLE, AttributeI18nTableMap::DESCRIPTION, AttributeI18nTableMap::CHAPO, AttributeI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(AttributeI18nTableMap::ID => 0, AttributeI18nTableMap::LOCALE => 1, AttributeI18nTableMap::TITLE => 2, AttributeI18nTableMap::DESCRIPTION => 3, AttributeI18nTableMap::CHAPO => 4, AttributeI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('attribute_i18n');
+ $this->setPhpName('AttributeI18n');
+ $this->setClassName('\\Thelia\\Model\\AttributeI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Attribute', '\\Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\AttributeI18n $obj A \Thelia\Model\AttributeI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\AttributeI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\AttributeI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\AttributeI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? AttributeI18nTableMap::CLASS_DEFAULT : AttributeI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (AttributeI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = AttributeI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = AttributeI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + AttributeI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AttributeI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ AttributeI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = AttributeI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = AttributeI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AttributeI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AttributeI18nTableMap::ID);
+ $criteria->addSelectColumn(AttributeI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(AttributeI18nTableMap::TITLE);
+ $criteria->addSelectColumn(AttributeI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(AttributeI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(AttributeI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(AttributeI18nTableMap::DATABASE_NAME)->getTable(AttributeI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(AttributeI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new AttributeI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a AttributeI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or AttributeI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\AttributeI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(AttributeI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(AttributeI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(AttributeI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = AttributeI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { AttributeI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { AttributeI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the attribute_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return AttributeI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a AttributeI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or AttributeI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from AttributeI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = AttributeI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // AttributeI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+AttributeI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/AttributeTableMap.php b/core/lib/Thelia/Model/Map/AttributeTableMap.php
new file mode 100644
index 000000000..dca811cbc
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/AttributeTableMap.php
@@ -0,0 +1,465 @@
+ array('Id', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'position', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(AttributeTableMap::ID, AttributeTableMap::POSITION, AttributeTableMap::CREATED_AT, AttributeTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'position', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Position' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'position' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ self::TYPE_COLNAME => array(AttributeTableMap::ID => 0, AttributeTableMap::POSITION => 1, AttributeTableMap::CREATED_AT => 2, AttributeTableMap::UPDATED_AT => 3, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'POSITION' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'position' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('attribute');
+ $this->setPhpName('Attribute');
+ $this->setClassName('\\Thelia\\Model\\Attribute');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('AttributeAv', '\\Thelia\\Model\\AttributeAv', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT', 'AttributeAvs');
+ $this->addRelation('AttributeCombination', '\\Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT', 'AttributeCombinations');
+ $this->addRelation('AttributeCategory', '\\Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT', 'AttributeCategories');
+ $this->addRelation('AttributeI18n', '\\Thelia\\Model\\AttributeI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'AttributeI18ns');
+ $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Categories');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to attribute * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ AttributeAvTableMap::clearInstancePool();
+ AttributeCombinationTableMap::clearInstancePool();
+ AttributeCategoryTableMap::clearInstancePool();
+ AttributeI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? AttributeTableMap::CLASS_DEFAULT : AttributeTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Attribute object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = AttributeTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = AttributeTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + AttributeTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = AttributeTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ AttributeTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = AttributeTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = AttributeTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ AttributeTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(AttributeTableMap::ID);
+ $criteria->addSelectColumn(AttributeTableMap::POSITION);
+ $criteria->addSelectColumn(AttributeTableMap::CREATED_AT);
+ $criteria->addSelectColumn(AttributeTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(AttributeTableMap::DATABASE_NAME)->getTable(AttributeTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(AttributeTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new AttributeTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Attribute or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Attribute object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Attribute) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(AttributeTableMap::DATABASE_NAME);
+ $criteria->add(AttributeTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = AttributeQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { AttributeTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { AttributeTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the attribute table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return AttributeQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Attribute or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Attribute object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(AttributeTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Attribute object
+ }
+
+ if ($criteria->containsKey(AttributeTableMap::ID) && $criteria->keyContainsValue(AttributeTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = AttributeQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // AttributeTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+AttributeTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php
new file mode 100644
index 000000000..1611b2ebf
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(CategoryI18nTableMap::ID, CategoryI18nTableMap::LOCALE, CategoryI18nTableMap::TITLE, CategoryI18nTableMap::DESCRIPTION, CategoryI18nTableMap::CHAPO, CategoryI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(CategoryI18nTableMap::ID => 0, CategoryI18nTableMap::LOCALE => 1, CategoryI18nTableMap::TITLE => 2, CategoryI18nTableMap::DESCRIPTION => 3, CategoryI18nTableMap::CHAPO => 4, CategoryI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('category_i18n');
+ $this->setPhpName('CategoryI18n');
+ $this->setClassName('\\Thelia\\Model\\CategoryI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\CategoryI18n $obj A \Thelia\Model\CategoryI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\CategoryI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\CategoryI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CategoryI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CategoryI18nTableMap::CLASS_DEFAULT : CategoryI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CategoryI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CategoryI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CategoryI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CategoryI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CategoryI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CategoryI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CategoryI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CategoryI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CategoryI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CategoryI18nTableMap::ID);
+ $criteria->addSelectColumn(CategoryI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(CategoryI18nTableMap::TITLE);
+ $criteria->addSelectColumn(CategoryI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(CategoryI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(CategoryI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(CategoryI18nTableMap::DATABASE_NAME)->getTable(CategoryI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CategoryI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CategoryI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CategoryI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CategoryI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CategoryI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\CategoryI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CategoryI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(CategoryI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(CategoryI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = CategoryI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CategoryI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CategoryI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the category_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CategoryI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CategoryI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CategoryI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CategoryI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = CategoryI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CategoryI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CategoryI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/CategoryTableMap.php b/core/lib/Thelia/Model/Map/CategoryTableMap.php
new file mode 100644
index 000000000..83010e4fa
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/CategoryTableMap.php
@@ -0,0 +1,526 @@
+ array('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ self::TYPE_COLNAME => array(CategoryTableMap::ID, CategoryTableMap::PARENT, CategoryTableMap::LINK, CategoryTableMap::VISIBLE, CategoryTableMap::POSITION, CategoryTableMap::CREATED_AT, CategoryTableMap::UPDATED_AT, CategoryTableMap::VERSION, CategoryTableMap::VERSION_CREATED_AT, CategoryTableMap::VERSION_CREATED_BY, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ self::TYPE_FIELDNAME => array('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ),
+ self::TYPE_COLNAME => array(CategoryTableMap::ID => 0, CategoryTableMap::PARENT => 1, CategoryTableMap::LINK => 2, CategoryTableMap::VISIBLE => 3, CategoryTableMap::POSITION => 4, CategoryTableMap::CREATED_AT => 5, CategoryTableMap::UPDATED_AT => 6, CategoryTableMap::VERSION => 7, CategoryTableMap::VERSION_CREATED_AT => 8, CategoryTableMap::VERSION_CREATED_BY => 9, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'PARENT' => 1, 'LINK' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, 'VERSION' => 7, 'VERSION_CREATED_AT' => 8, 'VERSION_CREATED_BY' => 9, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, 'version' => 7, 'version_created_at' => 8, 'version_created_by' => 9, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('category');
+ $this->setPhpName('Category');
+ $this->setClassName('\\Thelia\\Model\\Category');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null);
+ $this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('ProductCategory', '\\Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'ProductCategories');
+ $this->addRelation('FeatureCategory', '\\Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'FeatureCategories');
+ $this->addRelation('AttributeCategory', '\\Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'AttributeCategories');
+ $this->addRelation('ContentAssoc', '\\Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs');
+ $this->addRelation('Image', '\\Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Images');
+ $this->addRelation('Document', '\\Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Documents');
+ $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Rewritings');
+ $this->addRelation('CategoryI18n', '\\Thelia\\Model\\CategoryI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CategoryI18ns');
+ $this->addRelation('CategoryVersion', '\\Thelia\\Model\\CategoryVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CategoryVersions');
+ $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Products');
+ $this->addRelation('Feature', '\\Thelia\\Model\\Feature', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Features');
+ $this->addRelation('Attribute', '\\Thelia\\Model\\Attribute', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Attributes');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to category * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ProductCategoryTableMap::clearInstancePool();
+ FeatureCategoryTableMap::clearInstancePool();
+ AttributeCategoryTableMap::clearInstancePool();
+ ContentAssocTableMap::clearInstancePool();
+ ImageTableMap::clearInstancePool();
+ DocumentTableMap::clearInstancePool();
+ RewritingTableMap::clearInstancePool();
+ CategoryI18nTableMap::clearInstancePool();
+ CategoryVersionTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CategoryTableMap::CLASS_DEFAULT : CategoryTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Category object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CategoryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CategoryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CategoryTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CategoryTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CategoryTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CategoryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CategoryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CategoryTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CategoryTableMap::ID);
+ $criteria->addSelectColumn(CategoryTableMap::PARENT);
+ $criteria->addSelectColumn(CategoryTableMap::LINK);
+ $criteria->addSelectColumn(CategoryTableMap::VISIBLE);
+ $criteria->addSelectColumn(CategoryTableMap::POSITION);
+ $criteria->addSelectColumn(CategoryTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CategoryTableMap::UPDATED_AT);
+ $criteria->addSelectColumn(CategoryTableMap::VERSION);
+ $criteria->addSelectColumn(CategoryTableMap::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(CategoryTableMap::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PARENT');
+ $criteria->addSelectColumn($alias . '.LINK');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(CategoryTableMap::DATABASE_NAME)->getTable(CategoryTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CategoryTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CategoryTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CategoryTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Category or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Category object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Category) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CategoryTableMap::DATABASE_NAME);
+ $criteria->add(CategoryTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CategoryQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CategoryTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CategoryTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the category table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CategoryQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Category or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Category object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Category object
+ }
+
+ if ($criteria->containsKey(CategoryTableMap::ID) && $criteria->keyContainsValue(CategoryTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CategoryTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CategoryQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CategoryTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CategoryTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/CategoryVersionTableMap.php b/core/lib/Thelia/Model/Map/CategoryVersionTableMap.php
new file mode 100644
index 000000000..afaa44e5a
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/CategoryVersionTableMap.php
@@ -0,0 +1,529 @@
+ array('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ self::TYPE_COLNAME => array(CategoryVersionTableMap::ID, CategoryVersionTableMap::PARENT, CategoryVersionTableMap::LINK, CategoryVersionTableMap::VISIBLE, CategoryVersionTableMap::POSITION, CategoryVersionTableMap::CREATED_AT, CategoryVersionTableMap::UPDATED_AT, CategoryVersionTableMap::VERSION, CategoryVersionTableMap::VERSION_CREATED_AT, CategoryVersionTableMap::VERSION_CREATED_BY, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ self::TYPE_FIELDNAME => array('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ),
+ self::TYPE_COLNAME => array(CategoryVersionTableMap::ID => 0, CategoryVersionTableMap::PARENT => 1, CategoryVersionTableMap::LINK => 2, CategoryVersionTableMap::VISIBLE => 3, CategoryVersionTableMap::POSITION => 4, CategoryVersionTableMap::CREATED_AT => 5, CategoryVersionTableMap::UPDATED_AT => 6, CategoryVersionTableMap::VERSION => 7, CategoryVersionTableMap::VERSION_CREATED_AT => 8, CategoryVersionTableMap::VERSION_CREATED_BY => 9, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'PARENT' => 1, 'LINK' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, 'VERSION' => 7, 'VERSION_CREATED_AT' => 8, 'VERSION_CREATED_BY' => 9, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, 'version' => 7, 'version_created_at' => 8, 'version_created_by' => 9, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('category_version');
+ $this->setPhpName('CategoryVersion');
+ $this->setClassName('\\Thelia\\Model\\CategoryVersion');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category', 'ID', true, null, null);
+ $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null);
+ $this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\CategoryVersion $obj A \Thelia\Model\CategoryVersion object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getVersion()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\CategoryVersion object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\CategoryVersion) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getVersion()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CategoryVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 7 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 7 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CategoryVersionTableMap::CLASS_DEFAULT : CategoryVersionTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CategoryVersion object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CategoryVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CategoryVersionTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CategoryVersionTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CategoryVersionTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CategoryVersionTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CategoryVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CategoryVersionTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CategoryVersionTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CategoryVersionTableMap::ID);
+ $criteria->addSelectColumn(CategoryVersionTableMap::PARENT);
+ $criteria->addSelectColumn(CategoryVersionTableMap::LINK);
+ $criteria->addSelectColumn(CategoryVersionTableMap::VISIBLE);
+ $criteria->addSelectColumn(CategoryVersionTableMap::POSITION);
+ $criteria->addSelectColumn(CategoryVersionTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CategoryVersionTableMap::UPDATED_AT);
+ $criteria->addSelectColumn(CategoryVersionTableMap::VERSION);
+ $criteria->addSelectColumn(CategoryVersionTableMap::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(CategoryVersionTableMap::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PARENT');
+ $criteria->addSelectColumn($alias . '.LINK');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(CategoryVersionTableMap::DATABASE_NAME)->getTable(CategoryVersionTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CategoryVersionTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CategoryVersionTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CategoryVersionTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CategoryVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CategoryVersion object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryVersionTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\CategoryVersion) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CategoryVersionTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(CategoryVersionTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(CategoryVersionTableMap::VERSION, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = CategoryVersionQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CategoryVersionTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CategoryVersionTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the category_version table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CategoryVersionQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CategoryVersion or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CategoryVersion object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CategoryVersionTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CategoryVersion object
+ }
+
+
+ // Set the correct dbName
+ $query = CategoryVersionQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CategoryVersionTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CategoryVersionTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/CombinationTableMap.php b/core/lib/Thelia/Model/Map/CombinationTableMap.php
new file mode 100644
index 000000000..96ce0507e
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/CombinationTableMap.php
@@ -0,0 +1,450 @@
+ array('Id', 'Ref', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CombinationTableMap::ID, CombinationTableMap::REF, CombinationTableMap::CREATED_AT, CombinationTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'ref', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ self::TYPE_COLNAME => array(CombinationTableMap::ID => 0, CombinationTableMap::REF => 1, CombinationTableMap::CREATED_AT => 2, CombinationTableMap::UPDATED_AT => 3, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('combination');
+ $this->setPhpName('Combination');
+ $this->setClassName('\\Thelia\\Model\\Combination');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', false, 255, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('AttributeCombination', '\\Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), 'CASCADE', 'RESTRICT', 'AttributeCombinations');
+ $this->addRelation('Stock', '\\Thelia\\Model\\Stock', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), 'SET NULL', 'RESTRICT', 'Stocks');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to combination * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ AttributeCombinationTableMap::clearInstancePool();
+ StockTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CombinationTableMap::CLASS_DEFAULT : CombinationTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Combination object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CombinationTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CombinationTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CombinationTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CombinationTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CombinationTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CombinationTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CombinationTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CombinationTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CombinationTableMap::ID);
+ $criteria->addSelectColumn(CombinationTableMap::REF);
+ $criteria->addSelectColumn(CombinationTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CombinationTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(CombinationTableMap::DATABASE_NAME)->getTable(CombinationTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CombinationTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CombinationTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CombinationTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Combination or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Combination object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Combination) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CombinationTableMap::DATABASE_NAME);
+ $criteria->add(CombinationTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CombinationQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CombinationTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CombinationTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the combination table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CombinationQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Combination or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Combination object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Combination object
+ }
+
+ if ($criteria->containsKey(CombinationTableMap::ID) && $criteria->keyContainsValue(CombinationTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CombinationTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CombinationQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CombinationTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CombinationTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php b/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php
new file mode 100644
index 000000000..a83f87b76
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(ConfigI18nTableMap::ID, ConfigI18nTableMap::LOCALE, ConfigI18nTableMap::TITLE, ConfigI18nTableMap::DESCRIPTION, ConfigI18nTableMap::CHAPO, ConfigI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(ConfigI18nTableMap::ID => 0, ConfigI18nTableMap::LOCALE => 1, ConfigI18nTableMap::TITLE => 2, ConfigI18nTableMap::DESCRIPTION => 3, ConfigI18nTableMap::CHAPO => 4, ConfigI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('config_i18n');
+ $this->setPhpName('ConfigI18n');
+ $this->setClassName('\\Thelia\\Model\\ConfigI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'config', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Config', '\\Thelia\\Model\\Config', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\ConfigI18n $obj A \Thelia\Model\ConfigI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\ConfigI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\ConfigI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ConfigI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ConfigI18nTableMap::CLASS_DEFAULT : ConfigI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ConfigI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ConfigI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ConfigI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ConfigI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ConfigI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ConfigI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ConfigI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ConfigI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ConfigI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ConfigI18nTableMap::ID);
+ $criteria->addSelectColumn(ConfigI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(ConfigI18nTableMap::TITLE);
+ $criteria->addSelectColumn(ConfigI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(ConfigI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(ConfigI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ConfigI18nTableMap::DATABASE_NAME)->getTable(ConfigI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ConfigI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ConfigI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ConfigI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ConfigI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ConfigI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ConfigI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\ConfigI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ConfigI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(ConfigI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(ConfigI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = ConfigI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ConfigI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ConfigI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the config_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ConfigI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ConfigI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or ConfigI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ConfigI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from ConfigI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = ConfigI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ConfigI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ConfigI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ConfigTableMap.php b/core/lib/Thelia/Model/Map/ConfigTableMap.php
new file mode 100644
index 000000000..8bd68a964
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ConfigTableMap.php
@@ -0,0 +1,482 @@
+ array('Id', 'Name', 'Value', 'Secured', 'Hidden', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'name', 'value', 'secured', 'hidden', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(ConfigTableMap::ID, ConfigTableMap::NAME, ConfigTableMap::VALUE, ConfigTableMap::SECURED, ConfigTableMap::HIDDEN, ConfigTableMap::CREATED_AT, ConfigTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'VALUE', 'SECURED', 'HIDDEN', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'name', 'value', 'secured', 'hidden', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'Value' => 2, 'Secured' => 3, 'Hidden' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'value' => 2, 'secured' => 3, 'hidden' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ self::TYPE_COLNAME => array(ConfigTableMap::ID => 0, ConfigTableMap::NAME => 1, ConfigTableMap::VALUE => 2, ConfigTableMap::SECURED => 3, ConfigTableMap::HIDDEN => 4, ConfigTableMap::CREATED_AT => 5, ConfigTableMap::UPDATED_AT => 6, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'VALUE' => 2, 'SECURED' => 3, 'HIDDEN' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'value' => 2, 'secured' => 3, 'hidden' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('config');
+ $this->setPhpName('Config');
+ $this->setClassName('\\Thelia\\Model\\Config');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('NAME', 'Name', 'VARCHAR', true, 255, null);
+ $this->addColumn('VALUE', 'Value', 'VARCHAR', true, 255, null);
+ $this->addColumn('SECURED', 'Secured', 'TINYINT', true, null, 1);
+ $this->addColumn('HIDDEN', 'Hidden', 'TINYINT', true, null, 1);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('ConfigI18n', '\\Thelia\\Model\\ConfigI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ConfigI18ns');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to config * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ConfigI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ConfigTableMap::CLASS_DEFAULT : ConfigTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Config object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ConfigTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ConfigTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ConfigTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ConfigTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ConfigTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ConfigTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ConfigTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ConfigTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ConfigTableMap::ID);
+ $criteria->addSelectColumn(ConfigTableMap::NAME);
+ $criteria->addSelectColumn(ConfigTableMap::VALUE);
+ $criteria->addSelectColumn(ConfigTableMap::SECURED);
+ $criteria->addSelectColumn(ConfigTableMap::HIDDEN);
+ $criteria->addSelectColumn(ConfigTableMap::CREATED_AT);
+ $criteria->addSelectColumn(ConfigTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.NAME');
+ $criteria->addSelectColumn($alias . '.VALUE');
+ $criteria->addSelectColumn($alias . '.SECURED');
+ $criteria->addSelectColumn($alias . '.HIDDEN');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ConfigTableMap::DATABASE_NAME)->getTable(ConfigTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ConfigTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ConfigTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ConfigTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Config or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Config object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Config) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ConfigTableMap::DATABASE_NAME);
+ $criteria->add(ConfigTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = ConfigQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ConfigTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ConfigTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the config table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ConfigQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Config or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Config object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Config object
+ }
+
+ if ($criteria->containsKey(ConfigTableMap::ID) && $criteria->keyContainsValue(ConfigTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ConfigTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = ConfigQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ConfigTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ConfigTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ContentAssocTableMap.php b/core/lib/Thelia/Model/Map/ContentAssocTableMap.php
new file mode 100644
index 000000000..b080bea83
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ContentAssocTableMap.php
@@ -0,0 +1,465 @@
+ array('Id', 'CategoryId', 'ProductId', 'ContentId', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'categoryId', 'productId', 'contentId', 'position', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(ContentAssocTableMap::ID, ContentAssocTableMap::CATEGORY_ID, ContentAssocTableMap::PRODUCT_ID, ContentAssocTableMap::CONTENT_ID, ContentAssocTableMap::POSITION, ContentAssocTableMap::CREATED_AT, ContentAssocTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CATEGORY_ID', 'PRODUCT_ID', 'CONTENT_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'category_id', 'product_id', 'content_id', 'position', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'CategoryId' => 1, 'ProductId' => 2, 'ContentId' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'categoryId' => 1, 'productId' => 2, 'contentId' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ self::TYPE_COLNAME => array(ContentAssocTableMap::ID => 0, ContentAssocTableMap::CATEGORY_ID => 1, ContentAssocTableMap::PRODUCT_ID => 2, ContentAssocTableMap::CONTENT_ID => 3, ContentAssocTableMap::POSITION => 4, ContentAssocTableMap::CREATED_AT => 5, ContentAssocTableMap::UPDATED_AT => 6, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CATEGORY_ID' => 1, 'PRODUCT_ID' => 2, 'CONTENT_ID' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'category_id' => 1, 'product_id' => 2, 'content_id' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('content_assoc');
+ $this->setPhpName('ContentAssoc');
+ $this->setClassName('\\Thelia\\Model\\ContentAssoc');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null);
+ $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ContentAssocTableMap::CLASS_DEFAULT : ContentAssocTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ContentAssoc object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ContentAssocTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ContentAssocTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ContentAssocTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ContentAssocTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ContentAssocTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ContentAssocTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ContentAssocTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ContentAssocTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ContentAssocTableMap::ID);
+ $criteria->addSelectColumn(ContentAssocTableMap::CATEGORY_ID);
+ $criteria->addSelectColumn(ContentAssocTableMap::PRODUCT_ID);
+ $criteria->addSelectColumn(ContentAssocTableMap::CONTENT_ID);
+ $criteria->addSelectColumn(ContentAssocTableMap::POSITION);
+ $criteria->addSelectColumn(ContentAssocTableMap::CREATED_AT);
+ $criteria->addSelectColumn(ContentAssocTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.CONTENT_ID');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ContentAssocTableMap::DATABASE_NAME)->getTable(ContentAssocTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentAssocTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ContentAssocTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ContentAssocTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ContentAssoc or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ContentAssoc object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\ContentAssoc) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ContentAssocTableMap::DATABASE_NAME);
+ $criteria->add(ContentAssocTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = ContentAssocQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ContentAssocTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ContentAssocTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the content_assoc table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ContentAssocQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ContentAssoc or Criteria object.
+ *
+ * @param mixed $criteria Criteria or ContentAssoc object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from ContentAssoc object
+ }
+
+ if ($criteria->containsKey(ContentAssocTableMap::ID) && $criteria->keyContainsValue(ContentAssocTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ContentAssocTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = ContentAssocQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ContentAssocTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ContentAssocTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ContentFolderTableMap.php b/core/lib/Thelia/Model/Map/ContentFolderTableMap.php
new file mode 100644
index 000000000..4fedae441
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ContentFolderTableMap.php
@@ -0,0 +1,496 @@
+ array('ContentId', 'FolderId', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('contentId', 'folderId', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(ContentFolderTableMap::CONTENT_ID, ContentFolderTableMap::FOLDER_ID, ContentFolderTableMap::CREATED_AT, ContentFolderTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('CONTENT_ID', 'FOLDER_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('content_id', 'folder_id', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('ContentId' => 0, 'FolderId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ self::TYPE_STUDLYPHPNAME => array('contentId' => 0, 'folderId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ self::TYPE_COLNAME => array(ContentFolderTableMap::CONTENT_ID => 0, ContentFolderTableMap::FOLDER_ID => 1, ContentFolderTableMap::CREATED_AT => 2, ContentFolderTableMap::UPDATED_AT => 3, ),
+ self::TYPE_RAW_COLNAME => array('CONTENT_ID' => 0, 'FOLDER_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ self::TYPE_FIELDNAME => array('content_id' => 0, 'folder_id' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('content_folder');
+ $this->setPhpName('ContentFolder');
+ $this->setClassName('\\Thelia\\Model\\ContentFolder');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ $this->setIsCrossRef(true);
+ // columns
+ $this->addForeignPrimaryKey('CONTENT_ID', 'ContentId', 'INTEGER' , 'content', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('FOLDER_ID', 'FolderId', 'INTEGER' , 'folder', 'ID', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\ContentFolder $obj A \Thelia\Model\ContentFolder object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getContentId(), (string) $obj->getFolderId()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\ContentFolder object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\ContentFolder) {
+ $key = serialize(array((string) $value->getContentId(), (string) $value->getFolderId()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ContentFolder object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ContentFolderTableMap::CLASS_DEFAULT : ContentFolderTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ContentFolder object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ContentFolderTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ContentFolderTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ContentFolderTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ContentFolderTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ContentFolderTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ContentFolderTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ContentFolderTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ContentFolderTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ContentFolderTableMap::CONTENT_ID);
+ $criteria->addSelectColumn(ContentFolderTableMap::FOLDER_ID);
+ $criteria->addSelectColumn(ContentFolderTableMap::CREATED_AT);
+ $criteria->addSelectColumn(ContentFolderTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.CONTENT_ID');
+ $criteria->addSelectColumn($alias . '.FOLDER_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ContentFolderTableMap::DATABASE_NAME)->getTable(ContentFolderTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentFolderTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ContentFolderTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ContentFolderTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ContentFolder or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ContentFolder object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentFolderTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\ContentFolder) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ContentFolderTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(ContentFolderTableMap::CONTENT_ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(ContentFolderTableMap::FOLDER_ID, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = ContentFolderQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ContentFolderTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ContentFolderTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the content_folder table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ContentFolderQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ContentFolder or Criteria object.
+ *
+ * @param mixed $criteria Criteria or ContentFolder object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentFolderTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from ContentFolder object
+ }
+
+
+ // Set the correct dbName
+ $query = ContentFolderQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ContentFolderTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ContentFolderTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ContentI18nTableMap.php b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php
new file mode 100644
index 000000000..ee9122a6c
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(ContentI18nTableMap::ID, ContentI18nTableMap::LOCALE, ContentI18nTableMap::TITLE, ContentI18nTableMap::DESCRIPTION, ContentI18nTableMap::CHAPO, ContentI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(ContentI18nTableMap::ID => 0, ContentI18nTableMap::LOCALE => 1, ContentI18nTableMap::TITLE => 2, ContentI18nTableMap::DESCRIPTION => 3, ContentI18nTableMap::CHAPO => 4, ContentI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('content_i18n');
+ $this->setPhpName('ContentI18n');
+ $this->setClassName('\\Thelia\\Model\\ContentI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\ContentI18n $obj A \Thelia\Model\ContentI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\ContentI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\ContentI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ContentI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ContentI18nTableMap::CLASS_DEFAULT : ContentI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ContentI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ContentI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ContentI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ContentI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ContentI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ContentI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ContentI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ContentI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ContentI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ContentI18nTableMap::ID);
+ $criteria->addSelectColumn(ContentI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(ContentI18nTableMap::TITLE);
+ $criteria->addSelectColumn(ContentI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(ContentI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(ContentI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ContentI18nTableMap::DATABASE_NAME)->getTable(ContentI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ContentI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ContentI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ContentI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ContentI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\ContentI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ContentI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(ContentI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(ContentI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = ContentI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ContentI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ContentI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the content_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ContentI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ContentI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or ContentI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from ContentI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = ContentI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ContentI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ContentI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ContentTableMap.php b/core/lib/Thelia/Model/Map/ContentTableMap.php
new file mode 100644
index 000000000..60b04ae36
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ContentTableMap.php
@@ -0,0 +1,504 @@
+ array('Id', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ self::TYPE_COLNAME => array(ContentTableMap::ID, ContentTableMap::VISIBLE, ContentTableMap::POSITION, ContentTableMap::CREATED_AT, ContentTableMap::UPDATED_AT, ContentTableMap::VERSION, ContentTableMap::VERSION_CREATED_AT, ContentTableMap::VERSION_CREATED_BY, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ self::TYPE_FIELDNAME => array('id', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, 'Version' => 5, 'VersionCreatedAt' => 6, 'VersionCreatedBy' => 7, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, 'version' => 5, 'versionCreatedAt' => 6, 'versionCreatedBy' => 7, ),
+ self::TYPE_COLNAME => array(ContentTableMap::ID => 0, ContentTableMap::VISIBLE => 1, ContentTableMap::POSITION => 2, ContentTableMap::CREATED_AT => 3, ContentTableMap::UPDATED_AT => 4, ContentTableMap::VERSION => 5, ContentTableMap::VERSION_CREATED_AT => 6, ContentTableMap::VERSION_CREATED_BY => 7, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'VISIBLE' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, 'VERSION' => 5, 'VERSION_CREATED_AT' => 6, 'VERSION_CREATED_BY' => 7, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, 'version' => 5, 'version_created_at' => 6, 'version_created_by' => 7, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('content');
+ $this->setPhpName('Content');
+ $this->setClassName('\\Thelia\\Model\\Content');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('ContentAssoc', '\\Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs');
+ $this->addRelation('Image', '\\Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Images');
+ $this->addRelation('Document', '\\Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Documents');
+ $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Rewritings');
+ $this->addRelation('ContentFolder', '\\Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentFolders');
+ $this->addRelation('ContentI18n', '\\Thelia\\Model\\ContentI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ContentI18ns');
+ $this->addRelation('ContentVersion', '\\Thelia\\Model\\ContentVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ContentVersions');
+ $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Folders');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to content * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ContentAssocTableMap::clearInstancePool();
+ ImageTableMap::clearInstancePool();
+ DocumentTableMap::clearInstancePool();
+ RewritingTableMap::clearInstancePool();
+ ContentFolderTableMap::clearInstancePool();
+ ContentI18nTableMap::clearInstancePool();
+ ContentVersionTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ContentTableMap::CLASS_DEFAULT : ContentTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Content object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ContentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ContentTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ContentTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ContentTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ContentTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ContentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ContentTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ContentTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ContentTableMap::ID);
+ $criteria->addSelectColumn(ContentTableMap::VISIBLE);
+ $criteria->addSelectColumn(ContentTableMap::POSITION);
+ $criteria->addSelectColumn(ContentTableMap::CREATED_AT);
+ $criteria->addSelectColumn(ContentTableMap::UPDATED_AT);
+ $criteria->addSelectColumn(ContentTableMap::VERSION);
+ $criteria->addSelectColumn(ContentTableMap::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(ContentTableMap::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ContentTableMap::DATABASE_NAME)->getTable(ContentTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ContentTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ContentTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Content or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Content object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Content) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ContentTableMap::DATABASE_NAME);
+ $criteria->add(ContentTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = ContentQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ContentTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ContentTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the content table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ContentQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Content or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Content object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Content object
+ }
+
+ if ($criteria->containsKey(ContentTableMap::ID) && $criteria->keyContainsValue(ContentTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ContentTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = ContentQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ContentTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ContentTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ContentVersionTableMap.php b/core/lib/Thelia/Model/Map/ContentVersionTableMap.php
new file mode 100644
index 000000000..d651d24c9
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ContentVersionTableMap.php
@@ -0,0 +1,513 @@
+ array('Id', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ self::TYPE_COLNAME => array(ContentVersionTableMap::ID, ContentVersionTableMap::VISIBLE, ContentVersionTableMap::POSITION, ContentVersionTableMap::CREATED_AT, ContentVersionTableMap::UPDATED_AT, ContentVersionTableMap::VERSION, ContentVersionTableMap::VERSION_CREATED_AT, ContentVersionTableMap::VERSION_CREATED_BY, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ self::TYPE_FIELDNAME => array('id', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, 'Version' => 5, 'VersionCreatedAt' => 6, 'VersionCreatedBy' => 7, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, 'version' => 5, 'versionCreatedAt' => 6, 'versionCreatedBy' => 7, ),
+ self::TYPE_COLNAME => array(ContentVersionTableMap::ID => 0, ContentVersionTableMap::VISIBLE => 1, ContentVersionTableMap::POSITION => 2, ContentVersionTableMap::CREATED_AT => 3, ContentVersionTableMap::UPDATED_AT => 4, ContentVersionTableMap::VERSION => 5, ContentVersionTableMap::VERSION_CREATED_AT => 6, ContentVersionTableMap::VERSION_CREATED_BY => 7, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'VISIBLE' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, 'VERSION' => 5, 'VERSION_CREATED_AT' => 6, 'VERSION_CREATED_BY' => 7, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, 'version' => 5, 'version_created_at' => 6, 'version_created_by' => 7, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('content_version');
+ $this->setPhpName('ContentVersion');
+ $this->setClassName('\\Thelia\\Model\\ContentVersion');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content', 'ID', true, null, null);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\ContentVersion $obj A \Thelia\Model\ContentVersion object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getVersion()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\ContentVersion object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\ContentVersion) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getVersion()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ContentVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 5 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 5 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ContentVersionTableMap::CLASS_DEFAULT : ContentVersionTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ContentVersion object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ContentVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ContentVersionTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ContentVersionTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ContentVersionTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ContentVersionTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ContentVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ContentVersionTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ContentVersionTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ContentVersionTableMap::ID);
+ $criteria->addSelectColumn(ContentVersionTableMap::VISIBLE);
+ $criteria->addSelectColumn(ContentVersionTableMap::POSITION);
+ $criteria->addSelectColumn(ContentVersionTableMap::CREATED_AT);
+ $criteria->addSelectColumn(ContentVersionTableMap::UPDATED_AT);
+ $criteria->addSelectColumn(ContentVersionTableMap::VERSION);
+ $criteria->addSelectColumn(ContentVersionTableMap::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(ContentVersionTableMap::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ContentVersionTableMap::DATABASE_NAME)->getTable(ContentVersionTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentVersionTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ContentVersionTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ContentVersionTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ContentVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ContentVersion object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentVersionTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\ContentVersion) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ContentVersionTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(ContentVersionTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(ContentVersionTableMap::VERSION, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = ContentVersionQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ContentVersionTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ContentVersionTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the content_version table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ContentVersionQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ContentVersion or Criteria object.
+ *
+ * @param mixed $criteria Criteria or ContentVersion object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ContentVersionTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from ContentVersion object
+ }
+
+
+ // Set the correct dbName
+ $query = ContentVersionQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ContentVersionTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ContentVersionTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/CountryI18nTableMap.php b/core/lib/Thelia/Model/Map/CountryI18nTableMap.php
new file mode 100644
index 000000000..cc60b09d2
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/CountryI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(CountryI18nTableMap::ID, CountryI18nTableMap::LOCALE, CountryI18nTableMap::TITLE, CountryI18nTableMap::DESCRIPTION, CountryI18nTableMap::CHAPO, CountryI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(CountryI18nTableMap::ID => 0, CountryI18nTableMap::LOCALE => 1, CountryI18nTableMap::TITLE => 2, CountryI18nTableMap::DESCRIPTION => 3, CountryI18nTableMap::CHAPO => 4, CountryI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('country_i18n');
+ $this->setPhpName('CountryI18n');
+ $this->setClassName('\\Thelia\\Model\\CountryI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'country', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Country', '\\Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\CountryI18n $obj A \Thelia\Model\CountryI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\CountryI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\CountryI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CountryI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CountryI18nTableMap::CLASS_DEFAULT : CountryI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CountryI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CountryI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CountryI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CountryI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CountryI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CountryI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CountryI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CountryI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CountryI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CountryI18nTableMap::ID);
+ $criteria->addSelectColumn(CountryI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(CountryI18nTableMap::TITLE);
+ $criteria->addSelectColumn(CountryI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(CountryI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(CountryI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(CountryI18nTableMap::DATABASE_NAME)->getTable(CountryI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CountryI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CountryI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CountryI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CountryI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CountryI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CountryI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\CountryI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CountryI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(CountryI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(CountryI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = CountryI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CountryI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CountryI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the country_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CountryI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CountryI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CountryI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CountryI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CountryI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = CountryI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CountryI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CountryI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/CountryTableMap.php b/core/lib/Thelia/Model/Map/CountryTableMap.php
new file mode 100644
index 000000000..c4b96c8bd
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/CountryTableMap.php
@@ -0,0 +1,481 @@
+ array('Id', 'AreaId', 'Isocode', 'Isoalpha2', 'Isoalpha3', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'isocode', 'isoalpha2', 'isoalpha3', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CountryTableMap::ID, CountryTableMap::AREA_ID, CountryTableMap::ISOCODE, CountryTableMap::ISOALPHA2, CountryTableMap::ISOALPHA3, CountryTableMap::CREATED_AT, CountryTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'ISOCODE', 'ISOALPHA2', 'ISOALPHA3', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'area_id', 'isocode', 'isoalpha2', 'isoalpha3', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Isocode' => 2, 'Isoalpha2' => 3, 'Isoalpha3' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ self::TYPE_COLNAME => array(CountryTableMap::ID => 0, CountryTableMap::AREA_ID => 1, CountryTableMap::ISOCODE => 2, CountryTableMap::ISOALPHA2 => 3, CountryTableMap::ISOALPHA3 => 4, CountryTableMap::CREATED_AT => 5, CountryTableMap::UPDATED_AT => 6, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'ISOCODE' => 2, 'ISOALPHA2' => 3, 'ISOALPHA3' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('country');
+ $this->setPhpName('Country');
+ $this->setClassName('\\Thelia\\Model\\Country');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', false, null, null);
+ $this->addColumn('ISOCODE', 'Isocode', 'VARCHAR', true, 4, null);
+ $this->addColumn('ISOALPHA2', 'Isoalpha2', 'VARCHAR', false, 2, null);
+ $this->addColumn('ISOALPHA3', 'Isoalpha3', 'VARCHAR', false, 4, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Area', '\\Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ $this->addRelation('TaxRuleCountry', '\\Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', 'RESTRICT', 'TaxRuleCountries');
+ $this->addRelation('CountryI18n', '\\Thelia\\Model\\CountryI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CountryI18ns');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to country * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ TaxRuleCountryTableMap::clearInstancePool();
+ CountryI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CountryTableMap::CLASS_DEFAULT : CountryTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Country object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CountryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CountryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CountryTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CountryTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CountryTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CountryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CountryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CountryTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CountryTableMap::ID);
+ $criteria->addSelectColumn(CountryTableMap::AREA_ID);
+ $criteria->addSelectColumn(CountryTableMap::ISOCODE);
+ $criteria->addSelectColumn(CountryTableMap::ISOALPHA2);
+ $criteria->addSelectColumn(CountryTableMap::ISOALPHA3);
+ $criteria->addSelectColumn(CountryTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CountryTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.AREA_ID');
+ $criteria->addSelectColumn($alias . '.ISOCODE');
+ $criteria->addSelectColumn($alias . '.ISOALPHA2');
+ $criteria->addSelectColumn($alias . '.ISOALPHA3');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(CountryTableMap::DATABASE_NAME)->getTable(CountryTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CountryTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CountryTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CountryTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Country or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Country object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CountryTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Country) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CountryTableMap::DATABASE_NAME);
+ $criteria->add(CountryTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CountryQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CountryTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CountryTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the country table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CountryQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Country or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Country object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CountryTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Country object
+ }
+
+
+ // Set the correct dbName
+ $query = CountryQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CountryTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CountryTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/CouponOrderTableMap.php b/core/lib/Thelia/Model/Map/CouponOrderTableMap.php
new file mode 100644
index 000000000..9d91ef068
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/CouponOrderTableMap.php
@@ -0,0 +1,455 @@
+ array('Id', 'OrderId', 'Code', 'Value', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'code', 'value', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CouponOrderTableMap::ID, CouponOrderTableMap::ORDER_ID, CouponOrderTableMap::CODE, CouponOrderTableMap::VALUE, CouponOrderTableMap::CREATED_AT, CouponOrderTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'CODE', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'order_id', 'code', 'value', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'Code' => 2, 'Value' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'code' => 2, 'value' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ self::TYPE_COLNAME => array(CouponOrderTableMap::ID => 0, CouponOrderTableMap::ORDER_ID => 1, CouponOrderTableMap::CODE => 2, CouponOrderTableMap::VALUE => 3, CouponOrderTableMap::CREATED_AT => 4, CouponOrderTableMap::UPDATED_AT => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'CODE' => 2, 'VALUE' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'code' => 2, 'value' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('coupon_order');
+ $this->setPhpName('CouponOrder');
+ $this->setClassName('\\Thelia\\Model\\CouponOrder');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
+ $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CouponOrderTableMap::CLASS_DEFAULT : CouponOrderTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CouponOrder object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CouponOrderTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CouponOrderTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CouponOrderTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CouponOrderTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CouponOrderTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CouponOrderTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CouponOrderTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CouponOrderTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CouponOrderTableMap::ID);
+ $criteria->addSelectColumn(CouponOrderTableMap::ORDER_ID);
+ $criteria->addSelectColumn(CouponOrderTableMap::CODE);
+ $criteria->addSelectColumn(CouponOrderTableMap::VALUE);
+ $criteria->addSelectColumn(CouponOrderTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CouponOrderTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.ORDER_ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.VALUE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(CouponOrderTableMap::DATABASE_NAME)->getTable(CouponOrderTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CouponOrderTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CouponOrderTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CouponOrderTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CouponOrder or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CouponOrder object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\CouponOrder) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CouponOrderTableMap::DATABASE_NAME);
+ $criteria->add(CouponOrderTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CouponOrderQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CouponOrderTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CouponOrderTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the coupon_order table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CouponOrderQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CouponOrder or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CouponOrder object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CouponOrder object
+ }
+
+ if ($criteria->containsKey(CouponOrderTableMap::ID) && $criteria->keyContainsValue(CouponOrderTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CouponOrderTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CouponOrderQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CouponOrderTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CouponOrderTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/CouponRuleTableMap.php b/core/lib/Thelia/Model/Map/CouponRuleTableMap.php
new file mode 100644
index 000000000..99faeac59
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/CouponRuleTableMap.php
@@ -0,0 +1,463 @@
+ array('Id', 'CouponId', 'Controller', 'Operation', 'Value', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'couponId', 'controller', 'operation', 'value', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CouponRuleTableMap::ID, CouponRuleTableMap::COUPON_ID, CouponRuleTableMap::CONTROLLER, CouponRuleTableMap::OPERATION, CouponRuleTableMap::VALUE, CouponRuleTableMap::CREATED_AT, CouponRuleTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'COUPON_ID', 'CONTROLLER', 'OPERATION', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'coupon_id', 'controller', 'operation', 'value', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'CouponId' => 1, 'Controller' => 2, 'Operation' => 3, 'Value' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'couponId' => 1, 'controller' => 2, 'operation' => 3, 'value' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ self::TYPE_COLNAME => array(CouponRuleTableMap::ID => 0, CouponRuleTableMap::COUPON_ID => 1, CouponRuleTableMap::CONTROLLER => 2, CouponRuleTableMap::OPERATION => 3, CouponRuleTableMap::VALUE => 4, CouponRuleTableMap::CREATED_AT => 5, CouponRuleTableMap::UPDATED_AT => 6, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'COUPON_ID' => 1, 'CONTROLLER' => 2, 'OPERATION' => 3, 'VALUE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'coupon_id' => 1, 'controller' => 2, 'operation' => 3, 'value' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('coupon_rule');
+ $this->setPhpName('CouponRule');
+ $this->setClassName('\\Thelia\\Model\\CouponRule');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('COUPON_ID', 'CouponId', 'INTEGER', 'coupon', 'ID', true, null, null);
+ $this->addColumn('CONTROLLER', 'Controller', 'VARCHAR', false, 255, null);
+ $this->addColumn('OPERATION', 'Operation', 'VARCHAR', false, 255, null);
+ $this->addColumn('VALUE', 'Value', 'FLOAT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Coupon', '\\Thelia\\Model\\Coupon', RelationMap::MANY_TO_ONE, array('coupon_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CouponRuleTableMap::CLASS_DEFAULT : CouponRuleTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CouponRule object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CouponRuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CouponRuleTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CouponRuleTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CouponRuleTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CouponRuleTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CouponRuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CouponRuleTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CouponRuleTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CouponRuleTableMap::ID);
+ $criteria->addSelectColumn(CouponRuleTableMap::COUPON_ID);
+ $criteria->addSelectColumn(CouponRuleTableMap::CONTROLLER);
+ $criteria->addSelectColumn(CouponRuleTableMap::OPERATION);
+ $criteria->addSelectColumn(CouponRuleTableMap::VALUE);
+ $criteria->addSelectColumn(CouponRuleTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CouponRuleTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.COUPON_ID');
+ $criteria->addSelectColumn($alias . '.CONTROLLER');
+ $criteria->addSelectColumn($alias . '.OPERATION');
+ $criteria->addSelectColumn($alias . '.VALUE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(CouponRuleTableMap::DATABASE_NAME)->getTable(CouponRuleTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CouponRuleTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CouponRuleTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CouponRuleTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CouponRule or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CouponRule object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponRuleTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\CouponRule) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CouponRuleTableMap::DATABASE_NAME);
+ $criteria->add(CouponRuleTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CouponRuleQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CouponRuleTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CouponRuleTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the coupon_rule table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CouponRuleQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CouponRule or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CouponRule object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponRuleTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CouponRule object
+ }
+
+ if ($criteria->containsKey(CouponRuleTableMap::ID) && $criteria->keyContainsValue(CouponRuleTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CouponRuleTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CouponRuleQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CouponRuleTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CouponRuleTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/CouponTableMap.php b/core/lib/Thelia/Model/Map/CouponTableMap.php
new file mode 100644
index 000000000..d1ff79ac0
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/CouponTableMap.php
@@ -0,0 +1,496 @@
+ array('Id', 'Code', 'Action', 'Value', 'Used', 'AvailableSince', 'DateLimit', 'Activate', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'code', 'action', 'value', 'used', 'availableSince', 'dateLimit', 'activate', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::ACTION, CouponTableMap::VALUE, CouponTableMap::USED, CouponTableMap::AVAILABLE_SINCE, CouponTableMap::DATE_LIMIT, CouponTableMap::ACTIVATE, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'ACTION', 'VALUE', 'USED', 'AVAILABLE_SINCE', 'DATE_LIMIT', 'ACTIVATE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'code', 'action', 'value', 'used', 'available_since', 'date_limit', 'activate', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Action' => 2, 'Value' => 3, 'Used' => 4, 'AvailableSince' => 5, 'DateLimit' => 6, 'Activate' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'action' => 2, 'value' => 3, 'used' => 4, 'availableSince' => 5, 'dateLimit' => 6, 'activate' => 7, 'createdAt' => 8, 'updatedAt' => 9, ),
+ self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::ACTION => 2, CouponTableMap::VALUE => 3, CouponTableMap::USED => 4, CouponTableMap::AVAILABLE_SINCE => 5, CouponTableMap::DATE_LIMIT => 6, CouponTableMap::ACTIVATE => 7, CouponTableMap::CREATED_AT => 8, CouponTableMap::UPDATED_AT => 9, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'ACTION' => 2, 'VALUE' => 3, 'USED' => 4, 'AVAILABLE_SINCE' => 5, 'DATE_LIMIT' => 6, 'ACTIVATE' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'action' => 2, 'value' => 3, 'used' => 4, 'available_since' => 5, 'date_limit' => 6, 'activate' => 7, 'created_at' => 8, 'updated_at' => 9, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('coupon');
+ $this->setPhpName('Coupon');
+ $this->setClassName('\\Thelia\\Model\\Coupon');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
+ $this->addColumn('ACTION', 'Action', 'VARCHAR', true, 255, null);
+ $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null);
+ $this->addColumn('USED', 'Used', 'TINYINT', false, null, null);
+ $this->addColumn('AVAILABLE_SINCE', 'AvailableSince', 'TIMESTAMP', false, null, null);
+ $this->addColumn('DATE_LIMIT', 'DateLimit', 'TIMESTAMP', false, null, null);
+ $this->addColumn('ACTIVATE', 'Activate', 'TINYINT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('CouponRule', '\\Thelia\\Model\\CouponRule', RelationMap::ONE_TO_MANY, array('id' => 'coupon_id', ), 'CASCADE', 'RESTRICT', 'CouponRules');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to coupon * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CouponRuleTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CouponTableMap::CLASS_DEFAULT : CouponTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Coupon object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CouponTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CouponTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CouponTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CouponTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CouponTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CouponTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CouponTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CouponTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CouponTableMap::ID);
+ $criteria->addSelectColumn(CouponTableMap::CODE);
+ $criteria->addSelectColumn(CouponTableMap::ACTION);
+ $criteria->addSelectColumn(CouponTableMap::VALUE);
+ $criteria->addSelectColumn(CouponTableMap::USED);
+ $criteria->addSelectColumn(CouponTableMap::AVAILABLE_SINCE);
+ $criteria->addSelectColumn(CouponTableMap::DATE_LIMIT);
+ $criteria->addSelectColumn(CouponTableMap::ACTIVATE);
+ $criteria->addSelectColumn(CouponTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CouponTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.ACTION');
+ $criteria->addSelectColumn($alias . '.VALUE');
+ $criteria->addSelectColumn($alias . '.USED');
+ $criteria->addSelectColumn($alias . '.AVAILABLE_SINCE');
+ $criteria->addSelectColumn($alias . '.DATE_LIMIT');
+ $criteria->addSelectColumn($alias . '.ACTIVATE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(CouponTableMap::DATABASE_NAME)->getTable(CouponTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CouponTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CouponTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CouponTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Coupon or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Coupon object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Coupon) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CouponTableMap::DATABASE_NAME);
+ $criteria->add(CouponTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CouponQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CouponTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CouponTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the coupon table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CouponQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Coupon or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Coupon object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CouponTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Coupon object
+ }
+
+ if ($criteria->containsKey(CouponTableMap::ID) && $criteria->keyContainsValue(CouponTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CouponTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CouponQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CouponTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CouponTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/CurrencyTableMap.php b/core/lib/Thelia/Model/Map/CurrencyTableMap.php
new file mode 100644
index 000000000..36ed58310
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/CurrencyTableMap.php
@@ -0,0 +1,480 @@
+ array('Id', 'Name', 'Code', 'Symbol', 'Rate', 'ByDefault', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'name', 'code', 'symbol', 'rate', 'byDefault', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CurrencyTableMap::ID, CurrencyTableMap::NAME, CurrencyTableMap::CODE, CurrencyTableMap::SYMBOL, CurrencyTableMap::RATE, CurrencyTableMap::BY_DEFAULT, CurrencyTableMap::CREATED_AT, CurrencyTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'CODE', 'SYMBOL', 'RATE', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'name', 'code', 'symbol', 'rate', 'by_default', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'Code' => 2, 'Symbol' => 3, 'Rate' => 4, 'ByDefault' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'code' => 2, 'symbol' => 3, 'rate' => 4, 'byDefault' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ self::TYPE_COLNAME => array(CurrencyTableMap::ID => 0, CurrencyTableMap::NAME => 1, CurrencyTableMap::CODE => 2, CurrencyTableMap::SYMBOL => 3, CurrencyTableMap::RATE => 4, CurrencyTableMap::BY_DEFAULT => 5, CurrencyTableMap::CREATED_AT => 6, CurrencyTableMap::UPDATED_AT => 7, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'CODE' => 2, 'SYMBOL' => 3, 'RATE' => 4, 'BY_DEFAULT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'code' => 2, 'symbol' => 3, 'rate' => 4, 'by_default' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('currency');
+ $this->setPhpName('Currency');
+ $this->setClassName('\\Thelia\\Model\\Currency');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('NAME', 'Name', 'VARCHAR', false, 45, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null);
+ $this->addColumn('SYMBOL', 'Symbol', 'VARCHAR', false, 45, null);
+ $this->addColumn('RATE', 'Rate', 'FLOAT', false, null, null);
+ $this->addColumn('BY_DEFAULT', 'ByDefault', 'TINYINT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'SET NULL', 'RESTRICT', 'Orders');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to currency * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CurrencyTableMap::CLASS_DEFAULT : CurrencyTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Currency object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CurrencyTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CurrencyTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CurrencyTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CurrencyTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CurrencyTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CurrencyTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CurrencyTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CurrencyTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CurrencyTableMap::ID);
+ $criteria->addSelectColumn(CurrencyTableMap::NAME);
+ $criteria->addSelectColumn(CurrencyTableMap::CODE);
+ $criteria->addSelectColumn(CurrencyTableMap::SYMBOL);
+ $criteria->addSelectColumn(CurrencyTableMap::RATE);
+ $criteria->addSelectColumn(CurrencyTableMap::BY_DEFAULT);
+ $criteria->addSelectColumn(CurrencyTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CurrencyTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.NAME');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.SYMBOL');
+ $criteria->addSelectColumn($alias . '.RATE');
+ $criteria->addSelectColumn($alias . '.BY_DEFAULT');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(CurrencyTableMap::DATABASE_NAME)->getTable(CurrencyTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CurrencyTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CurrencyTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CurrencyTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Currency or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Currency object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CurrencyTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Currency) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CurrencyTableMap::DATABASE_NAME);
+ $criteria->add(CurrencyTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CurrencyQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CurrencyTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CurrencyTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the currency table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CurrencyQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Currency or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Currency object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CurrencyTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Currency object
+ }
+
+ if ($criteria->containsKey(CurrencyTableMap::ID) && $criteria->keyContainsValue(CurrencyTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CurrencyTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CurrencyQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CurrencyTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CurrencyTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/CustomerTableMap.php b/core/lib/Thelia/Model/Map/CustomerTableMap.php
new file mode 100644
index 000000000..030d233d9
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/CustomerTableMap.php
@@ -0,0 +1,611 @@
+ array('Id', 'Ref', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'Cellphone', 'Email', 'Password', 'Algo', 'Salt', 'Reseller', 'Lang', 'Sponsor', 'Discount', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'cellphone', 'email', 'password', 'algo', 'salt', 'reseller', 'lang', 'sponsor', 'discount', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CustomerTableMap::ID, CustomerTableMap::REF, CustomerTableMap::CUSTOMER_TITLE_ID, CustomerTableMap::COMPANY, CustomerTableMap::FIRSTNAME, CustomerTableMap::LASTNAME, CustomerTableMap::ADDRESS1, CustomerTableMap::ADDRESS2, CustomerTableMap::ADDRESS3, CustomerTableMap::ZIPCODE, CustomerTableMap::CITY, CustomerTableMap::COUNTRY_ID, CustomerTableMap::PHONE, CustomerTableMap::CELLPHONE, CustomerTableMap::EMAIL, CustomerTableMap::PASSWORD, CustomerTableMap::ALGO, CustomerTableMap::SALT, CustomerTableMap::RESELLER, CustomerTableMap::LANG, CustomerTableMap::SPONSOR, CustomerTableMap::DISCOUNT, CustomerTableMap::CREATED_AT, CustomerTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CELLPHONE', 'EMAIL', 'PASSWORD', 'ALGO', 'SALT', 'RESELLER', 'LANG', 'SPONSOR', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'ref', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'cellphone', 'email', 'password', 'algo', 'salt', 'reseller', 'lang', 'sponsor', 'discount', 'created_at', 'updated_at', ),
+ self::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, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'CustomerTitleId' => 2, 'Company' => 3, 'Firstname' => 4, 'Lastname' => 5, 'Address1' => 6, 'Address2' => 7, 'Address3' => 8, 'Zipcode' => 9, 'City' => 10, 'CountryId' => 11, 'Phone' => 12, 'Cellphone' => 13, 'Email' => 14, 'Password' => 15, 'Algo' => 16, 'Salt' => 17, 'Reseller' => 18, 'Lang' => 19, 'Sponsor' => 20, 'Discount' => 21, 'CreatedAt' => 22, 'UpdatedAt' => 23, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'customerTitleId' => 2, 'company' => 3, 'firstname' => 4, 'lastname' => 5, 'address1' => 6, 'address2' => 7, 'address3' => 8, 'zipcode' => 9, 'city' => 10, 'countryId' => 11, 'phone' => 12, 'cellphone' => 13, 'email' => 14, 'password' => 15, 'algo' => 16, 'salt' => 17, 'reseller' => 18, 'lang' => 19, 'sponsor' => 20, 'discount' => 21, 'createdAt' => 22, 'updatedAt' => 23, ),
+ self::TYPE_COLNAME => array(CustomerTableMap::ID => 0, CustomerTableMap::REF => 1, CustomerTableMap::CUSTOMER_TITLE_ID => 2, CustomerTableMap::COMPANY => 3, CustomerTableMap::FIRSTNAME => 4, CustomerTableMap::LASTNAME => 5, CustomerTableMap::ADDRESS1 => 6, CustomerTableMap::ADDRESS2 => 7, CustomerTableMap::ADDRESS3 => 8, CustomerTableMap::ZIPCODE => 9, CustomerTableMap::CITY => 10, CustomerTableMap::COUNTRY_ID => 11, CustomerTableMap::PHONE => 12, CustomerTableMap::CELLPHONE => 13, CustomerTableMap::EMAIL => 14, CustomerTableMap::PASSWORD => 15, CustomerTableMap::ALGO => 16, CustomerTableMap::SALT => 17, CustomerTableMap::RESELLER => 18, CustomerTableMap::LANG => 19, CustomerTableMap::SPONSOR => 20, CustomerTableMap::DISCOUNT => 21, CustomerTableMap::CREATED_AT => 22, CustomerTableMap::UPDATED_AT => 23, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CUSTOMER_TITLE_ID' => 2, 'COMPANY' => 3, 'FIRSTNAME' => 4, 'LASTNAME' => 5, 'ADDRESS1' => 6, 'ADDRESS2' => 7, 'ADDRESS3' => 8, 'ZIPCODE' => 9, 'CITY' => 10, 'COUNTRY_ID' => 11, 'PHONE' => 12, 'CELLPHONE' => 13, 'EMAIL' => 14, 'PASSWORD' => 15, 'ALGO' => 16, 'SALT' => 17, 'RESELLER' => 18, 'LANG' => 19, 'SPONSOR' => 20, 'DISCOUNT' => 21, 'CREATED_AT' => 22, 'UPDATED_AT' => 23, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'customer_title_id' => 2, 'company' => 3, 'firstname' => 4, 'lastname' => 5, 'address1' => 6, 'address2' => 7, 'address3' => 8, 'zipcode' => 9, 'city' => 10, 'country_id' => 11, 'phone' => 12, 'cellphone' => 13, 'email' => 14, 'password' => 15, 'algo' => 16, 'salt' => 17, 'reseller' => 18, 'lang' => 19, 'sponsor' => 20, 'discount' => 21, 'created_at' => 22, 'updated_at' => 23, ),
+ self::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, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('customer');
+ $this->setPhpName('Customer');
+ $this->setClassName('\\Thelia\\Model\\Customer');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', true, 50, null);
+ $this->addForeignKey('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', 'customer_title', 'ID', false, null, null);
+ $this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null);
+ $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null);
+ $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS1', 'Address1', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS2', 'Address2', 'VARCHAR', false, 255, null);
+ $this->addColumn('ADDRESS3', 'Address3', 'VARCHAR', false, 255, null);
+ $this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', false, 10, null);
+ $this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null);
+ $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null);
+ $this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null);
+ $this->addColumn('CELLPHONE', 'Cellphone', 'VARCHAR', false, 20, null);
+ $this->addColumn('EMAIL', 'Email', 'VARCHAR', false, 50, null);
+ $this->addColumn('PASSWORD', 'Password', 'VARCHAR', false, 255, null);
+ $this->addColumn('ALGO', 'Algo', 'VARCHAR', false, 128, null);
+ $this->addColumn('SALT', 'Salt', 'VARCHAR', false, 128, null);
+ $this->addColumn('RESELLER', 'Reseller', 'TINYINT', false, null, null);
+ $this->addColumn('LANG', 'Lang', 'VARCHAR', false, 10, null);
+ $this->addColumn('SPONSOR', 'Sponsor', 'VARCHAR', false, 50, null);
+ $this->addColumn('DISCOUNT', 'Discount', 'FLOAT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ $this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Addresses');
+ $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Orders');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to customer * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ AddressTableMap::clearInstancePool();
+ OrderTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CustomerTableMap::CLASS_DEFAULT : CustomerTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Customer object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CustomerTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CustomerTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CustomerTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CustomerTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CustomerTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CustomerTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CustomerTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CustomerTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CustomerTableMap::ID);
+ $criteria->addSelectColumn(CustomerTableMap::REF);
+ $criteria->addSelectColumn(CustomerTableMap::CUSTOMER_TITLE_ID);
+ $criteria->addSelectColumn(CustomerTableMap::COMPANY);
+ $criteria->addSelectColumn(CustomerTableMap::FIRSTNAME);
+ $criteria->addSelectColumn(CustomerTableMap::LASTNAME);
+ $criteria->addSelectColumn(CustomerTableMap::ADDRESS1);
+ $criteria->addSelectColumn(CustomerTableMap::ADDRESS2);
+ $criteria->addSelectColumn(CustomerTableMap::ADDRESS3);
+ $criteria->addSelectColumn(CustomerTableMap::ZIPCODE);
+ $criteria->addSelectColumn(CustomerTableMap::CITY);
+ $criteria->addSelectColumn(CustomerTableMap::COUNTRY_ID);
+ $criteria->addSelectColumn(CustomerTableMap::PHONE);
+ $criteria->addSelectColumn(CustomerTableMap::CELLPHONE);
+ $criteria->addSelectColumn(CustomerTableMap::EMAIL);
+ $criteria->addSelectColumn(CustomerTableMap::PASSWORD);
+ $criteria->addSelectColumn(CustomerTableMap::ALGO);
+ $criteria->addSelectColumn(CustomerTableMap::SALT);
+ $criteria->addSelectColumn(CustomerTableMap::RESELLER);
+ $criteria->addSelectColumn(CustomerTableMap::LANG);
+ $criteria->addSelectColumn(CustomerTableMap::SPONSOR);
+ $criteria->addSelectColumn(CustomerTableMap::DISCOUNT);
+ $criteria->addSelectColumn(CustomerTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CustomerTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID');
+ $criteria->addSelectColumn($alias . '.COMPANY');
+ $criteria->addSelectColumn($alias . '.FIRSTNAME');
+ $criteria->addSelectColumn($alias . '.LASTNAME');
+ $criteria->addSelectColumn($alias . '.ADDRESS1');
+ $criteria->addSelectColumn($alias . '.ADDRESS2');
+ $criteria->addSelectColumn($alias . '.ADDRESS3');
+ $criteria->addSelectColumn($alias . '.ZIPCODE');
+ $criteria->addSelectColumn($alias . '.CITY');
+ $criteria->addSelectColumn($alias . '.COUNTRY_ID');
+ $criteria->addSelectColumn($alias . '.PHONE');
+ $criteria->addSelectColumn($alias . '.CELLPHONE');
+ $criteria->addSelectColumn($alias . '.EMAIL');
+ $criteria->addSelectColumn($alias . '.PASSWORD');
+ $criteria->addSelectColumn($alias . '.ALGO');
+ $criteria->addSelectColumn($alias . '.SALT');
+ $criteria->addSelectColumn($alias . '.RESELLER');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.SPONSOR');
+ $criteria->addSelectColumn($alias . '.DISCOUNT');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(CustomerTableMap::DATABASE_NAME)->getTable(CustomerTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CustomerTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CustomerTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CustomerTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Customer or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Customer object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Customer) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CustomerTableMap::DATABASE_NAME);
+ $criteria->add(CustomerTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CustomerQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CustomerTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CustomerTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the customer table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CustomerQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Customer or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Customer object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Customer object
+ }
+
+ if ($criteria->containsKey(CustomerTableMap::ID) && $criteria->keyContainsValue(CustomerTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CustomerTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CustomerQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CustomerTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CustomerTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php
new file mode 100644
index 000000000..d403756fa
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php
@@ -0,0 +1,481 @@
+ array('Id', 'Locale', 'Short', 'Long', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'short', 'long', ),
+ self::TYPE_COLNAME => array(CustomerTitleI18nTableMap::ID, CustomerTitleI18nTableMap::LOCALE, CustomerTitleI18nTableMap::SHORT, CustomerTitleI18nTableMap::LONG, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'SHORT', 'LONG', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'short', 'long', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Short' => 2, 'Long' => 3, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'short' => 2, 'long' => 3, ),
+ self::TYPE_COLNAME => array(CustomerTitleI18nTableMap::ID => 0, CustomerTitleI18nTableMap::LOCALE => 1, CustomerTitleI18nTableMap::SHORT => 2, CustomerTitleI18nTableMap::LONG => 3, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'SHORT' => 2, 'LONG' => 3, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'short' => 2, 'long' => 3, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('customer_title_i18n');
+ $this->setPhpName('CustomerTitleI18n');
+ $this->setClassName('\\Thelia\\Model\\CustomerTitleI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'customer_title', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('SHORT', 'Short', 'VARCHAR', false, 10, null);
+ $this->addColumn('LONG', 'Long', 'VARCHAR', false, 45, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\CustomerTitleI18n $obj A \Thelia\Model\CustomerTitleI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\CustomerTitleI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\CustomerTitleI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CustomerTitleI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CustomerTitleI18nTableMap::CLASS_DEFAULT : CustomerTitleI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CustomerTitleI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CustomerTitleI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CustomerTitleI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CustomerTitleI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CustomerTitleI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CustomerTitleI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CustomerTitleI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CustomerTitleI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CustomerTitleI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CustomerTitleI18nTableMap::ID);
+ $criteria->addSelectColumn(CustomerTitleI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(CustomerTitleI18nTableMap::SHORT);
+ $criteria->addSelectColumn(CustomerTitleI18nTableMap::LONG);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.SHORT');
+ $criteria->addSelectColumn($alias . '.LONG');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(CustomerTitleI18nTableMap::DATABASE_NAME)->getTable(CustomerTitleI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CustomerTitleI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CustomerTitleI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CustomerTitleI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CustomerTitleI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CustomerTitleI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\CustomerTitleI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CustomerTitleI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(CustomerTitleI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(CustomerTitleI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = CustomerTitleI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CustomerTitleI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CustomerTitleI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the customer_title_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CustomerTitleI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CustomerTitleI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CustomerTitleI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CustomerTitleI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = CustomerTitleI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CustomerTitleI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CustomerTitleI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php
new file mode 100644
index 000000000..a392ee4dd
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php
@@ -0,0 +1,469 @@
+ array('Id', 'ByDefault', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'byDefault', 'position', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(CustomerTitleTableMap::ID, CustomerTitleTableMap::BY_DEFAULT, CustomerTitleTableMap::POSITION, CustomerTitleTableMap::CREATED_AT, CustomerTitleTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'BY_DEFAULT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'by_default', 'position', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'ByDefault' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'byDefault' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ self::TYPE_COLNAME => array(CustomerTitleTableMap::ID => 0, CustomerTitleTableMap::BY_DEFAULT => 1, CustomerTitleTableMap::POSITION => 2, CustomerTitleTableMap::CREATED_AT => 3, CustomerTitleTableMap::UPDATED_AT => 4, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'BY_DEFAULT' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'by_default' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('customer_title');
+ $this->setPhpName('CustomerTitle');
+ $this->setClassName('\\Thelia\\Model\\CustomerTitle');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('BY_DEFAULT', 'ByDefault', 'INTEGER', true, null, 0);
+ $this->addColumn('POSITION', 'Position', 'VARCHAR', true, 45, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'SET NULL', 'RESTRICT', 'Customers');
+ $this->addRelation('Address', '\\Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'RESTRICT', 'RESTRICT', 'Addresses');
+ $this->addRelation('CustomerTitleI18n', '\\Thelia\\Model\\CustomerTitleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CustomerTitleI18ns');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'short, long', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to customer_title * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ CustomerTableMap::clearInstancePool();
+ CustomerTitleI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? CustomerTitleTableMap::CLASS_DEFAULT : CustomerTitleTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (CustomerTitle object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = CustomerTitleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = CustomerTitleTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + CustomerTitleTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = CustomerTitleTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ CustomerTitleTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = CustomerTitleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = CustomerTitleTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ CustomerTitleTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(CustomerTitleTableMap::ID);
+ $criteria->addSelectColumn(CustomerTitleTableMap::BY_DEFAULT);
+ $criteria->addSelectColumn(CustomerTitleTableMap::POSITION);
+ $criteria->addSelectColumn(CustomerTitleTableMap::CREATED_AT);
+ $criteria->addSelectColumn(CustomerTitleTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.BY_DEFAULT');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(CustomerTitleTableMap::DATABASE_NAME)->getTable(CustomerTitleTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(CustomerTitleTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(CustomerTitleTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new CustomerTitleTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a CustomerTitle or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or CustomerTitle object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\CustomerTitle) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(CustomerTitleTableMap::DATABASE_NAME);
+ $criteria->add(CustomerTitleTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = CustomerTitleQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { CustomerTitleTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { CustomerTitleTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the customer_title table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return CustomerTitleQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a CustomerTitle or Criteria object.
+ *
+ * @param mixed $criteria Criteria or CustomerTitle object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from CustomerTitle object
+ }
+
+ if ($criteria->containsKey(CustomerTitleTableMap::ID) && $criteria->keyContainsValue(CustomerTitleTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.CustomerTitleTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = CustomerTitleQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // CustomerTitleTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+CustomerTitleTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/DelivzoneTableMap.php b/core/lib/Thelia/Model/Map/DelivzoneTableMap.php
new file mode 100644
index 000000000..ca7c5fa4d
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/DelivzoneTableMap.php
@@ -0,0 +1,447 @@
+ array('Id', 'AreaId', 'Delivery', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'delivery', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(DelivzoneTableMap::ID, DelivzoneTableMap::AREA_ID, DelivzoneTableMap::DELIVERY, DelivzoneTableMap::CREATED_AT, DelivzoneTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'DELIVERY', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'area_id', 'delivery', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Delivery' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'delivery' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ self::TYPE_COLNAME => array(DelivzoneTableMap::ID => 0, DelivzoneTableMap::AREA_ID => 1, DelivzoneTableMap::DELIVERY => 2, DelivzoneTableMap::CREATED_AT => 3, DelivzoneTableMap::UPDATED_AT => 4, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'DELIVERY' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'delivery' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('delivzone');
+ $this->setPhpName('Delivzone');
+ $this->setClassName('\\Thelia\\Model\\Delivzone');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', false, null, null);
+ $this->addColumn('DELIVERY', 'Delivery', 'VARCHAR', true, 45, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Area', '\\Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? DelivzoneTableMap::CLASS_DEFAULT : DelivzoneTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Delivzone object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = DelivzoneTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = DelivzoneTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + DelivzoneTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = DelivzoneTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ DelivzoneTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = DelivzoneTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = DelivzoneTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ DelivzoneTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(DelivzoneTableMap::ID);
+ $criteria->addSelectColumn(DelivzoneTableMap::AREA_ID);
+ $criteria->addSelectColumn(DelivzoneTableMap::DELIVERY);
+ $criteria->addSelectColumn(DelivzoneTableMap::CREATED_AT);
+ $criteria->addSelectColumn(DelivzoneTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.AREA_ID');
+ $criteria->addSelectColumn($alias . '.DELIVERY');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(DelivzoneTableMap::DATABASE_NAME)->getTable(DelivzoneTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(DelivzoneTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(DelivzoneTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new DelivzoneTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Delivzone or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Delivzone object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Delivzone) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(DelivzoneTableMap::DATABASE_NAME);
+ $criteria->add(DelivzoneTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = DelivzoneQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { DelivzoneTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { DelivzoneTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the delivzone table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return DelivzoneQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Delivzone or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Delivzone object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Delivzone object
+ }
+
+ if ($criteria->containsKey(DelivzoneTableMap::ID) && $criteria->keyContainsValue(DelivzoneTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.DelivzoneTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = DelivzoneQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // DelivzoneTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+DelivzoneTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php
new file mode 100644
index 000000000..d0356e8c6
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(DocumentI18nTableMap::ID, DocumentI18nTableMap::LOCALE, DocumentI18nTableMap::TITLE, DocumentI18nTableMap::DESCRIPTION, DocumentI18nTableMap::CHAPO, DocumentI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(DocumentI18nTableMap::ID => 0, DocumentI18nTableMap::LOCALE => 1, DocumentI18nTableMap::TITLE => 2, DocumentI18nTableMap::DESCRIPTION => 3, DocumentI18nTableMap::CHAPO => 4, DocumentI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('document_i18n');
+ $this->setPhpName('DocumentI18n');
+ $this->setClassName('\\Thelia\\Model\\DocumentI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'document', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Document', '\\Thelia\\Model\\Document', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\DocumentI18n $obj A \Thelia\Model\DocumentI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\DocumentI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\DocumentI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\DocumentI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? DocumentI18nTableMap::CLASS_DEFAULT : DocumentI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (DocumentI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = DocumentI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = DocumentI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + DocumentI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = DocumentI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ DocumentI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = DocumentI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = DocumentI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ DocumentI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(DocumentI18nTableMap::ID);
+ $criteria->addSelectColumn(DocumentI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(DocumentI18nTableMap::TITLE);
+ $criteria->addSelectColumn(DocumentI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(DocumentI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(DocumentI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(DocumentI18nTableMap::DATABASE_NAME)->getTable(DocumentI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(DocumentI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(DocumentI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new DocumentI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a DocumentI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or DocumentI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\DocumentI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(DocumentI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(DocumentI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(DocumentI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = DocumentI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { DocumentI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { DocumentI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the document_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return DocumentI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a DocumentI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or DocumentI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from DocumentI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = DocumentI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // DocumentI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+DocumentI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/DocumentTableMap.php b/core/lib/Thelia/Model/Map/DocumentTableMap.php
new file mode 100644
index 000000000..50bb37b95
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/DocumentTableMap.php
@@ -0,0 +1,502 @@
+ array('Id', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'categoryId', 'folderId', 'contentId', 'file', 'position', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(DocumentTableMap::ID, DocumentTableMap::PRODUCT_ID, DocumentTableMap::CATEGORY_ID, DocumentTableMap::FOLDER_ID, DocumentTableMap::CONTENT_ID, DocumentTableMap::FILE, DocumentTableMap::POSITION, DocumentTableMap::CREATED_AT, DocumentTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'product_id', 'category_id', 'folder_id', 'content_id', 'file', 'position', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'CategoryId' => 2, 'FolderId' => 3, 'ContentId' => 4, 'File' => 5, 'Position' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'categoryId' => 2, 'folderId' => 3, 'contentId' => 4, 'file' => 5, 'position' => 6, 'createdAt' => 7, 'updatedAt' => 8, ),
+ self::TYPE_COLNAME => array(DocumentTableMap::ID => 0, DocumentTableMap::PRODUCT_ID => 1, DocumentTableMap::CATEGORY_ID => 2, DocumentTableMap::FOLDER_ID => 3, DocumentTableMap::CONTENT_ID => 4, DocumentTableMap::FILE => 5, DocumentTableMap::POSITION => 6, DocumentTableMap::CREATED_AT => 7, DocumentTableMap::UPDATED_AT => 8, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'CATEGORY_ID' => 2, 'FOLDER_ID' => 3, 'CONTENT_ID' => 4, 'FILE' => 5, 'POSITION' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'category_id' => 2, 'folder_id' => 3, 'content_id' => 4, 'file' => 5, 'position' => 6, 'created_at' => 7, 'updated_at' => 8, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('document');
+ $this->setPhpName('Document');
+ $this->setClassName('\\Thelia\\Model\\Document');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null);
+ $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null);
+ $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null);
+ $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('DocumentI18n', '\\Thelia\\Model\\DocumentI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'DocumentI18ns');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to document * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ DocumentI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? DocumentTableMap::CLASS_DEFAULT : DocumentTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Document object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = DocumentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = DocumentTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + DocumentTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = DocumentTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ DocumentTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = DocumentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = DocumentTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ DocumentTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(DocumentTableMap::ID);
+ $criteria->addSelectColumn(DocumentTableMap::PRODUCT_ID);
+ $criteria->addSelectColumn(DocumentTableMap::CATEGORY_ID);
+ $criteria->addSelectColumn(DocumentTableMap::FOLDER_ID);
+ $criteria->addSelectColumn(DocumentTableMap::CONTENT_ID);
+ $criteria->addSelectColumn(DocumentTableMap::FILE);
+ $criteria->addSelectColumn(DocumentTableMap::POSITION);
+ $criteria->addSelectColumn(DocumentTableMap::CREATED_AT);
+ $criteria->addSelectColumn(DocumentTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ $criteria->addSelectColumn($alias . '.FOLDER_ID');
+ $criteria->addSelectColumn($alias . '.CONTENT_ID');
+ $criteria->addSelectColumn($alias . '.FILE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(DocumentTableMap::DATABASE_NAME)->getTable(DocumentTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(DocumentTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(DocumentTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new DocumentTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Document or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Document object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Document) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(DocumentTableMap::DATABASE_NAME);
+ $criteria->add(DocumentTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = DocumentQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { DocumentTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { DocumentTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the document table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return DocumentQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Document or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Document object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Document object
+ }
+
+ if ($criteria->containsKey(DocumentTableMap::ID) && $criteria->keyContainsValue(DocumentTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.DocumentTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = DocumentQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // DocumentTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+DocumentTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php b/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php
new file mode 100644
index 000000000..b3114e7ba
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(FeatureAvI18nTableMap::ID, FeatureAvI18nTableMap::LOCALE, FeatureAvI18nTableMap::TITLE, FeatureAvI18nTableMap::DESCRIPTION, FeatureAvI18nTableMap::CHAPO, FeatureAvI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(FeatureAvI18nTableMap::ID => 0, FeatureAvI18nTableMap::LOCALE => 1, FeatureAvI18nTableMap::TITLE => 2, FeatureAvI18nTableMap::DESCRIPTION => 3, FeatureAvI18nTableMap::CHAPO => 4, FeatureAvI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('feature_av_i18n');
+ $this->setPhpName('FeatureAvI18n');
+ $this->setClassName('\\Thelia\\Model\\FeatureAvI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_av', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('FeatureAv', '\\Thelia\\Model\\FeatureAv', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\FeatureAvI18n $obj A \Thelia\Model\FeatureAvI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\FeatureAvI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\FeatureAvI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\FeatureAvI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? FeatureAvI18nTableMap::CLASS_DEFAULT : FeatureAvI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (FeatureAvI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = FeatureAvI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = FeatureAvI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + FeatureAvI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FeatureAvI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ FeatureAvI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = FeatureAvI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = FeatureAvI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FeatureAvI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FeatureAvI18nTableMap::ID);
+ $criteria->addSelectColumn(FeatureAvI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(FeatureAvI18nTableMap::TITLE);
+ $criteria->addSelectColumn(FeatureAvI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(FeatureAvI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(FeatureAvI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(FeatureAvI18nTableMap::DATABASE_NAME)->getTable(FeatureAvI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureAvI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(FeatureAvI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new FeatureAvI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a FeatureAvI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or FeatureAvI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\FeatureAvI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(FeatureAvI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(FeatureAvI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(FeatureAvI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = FeatureAvI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { FeatureAvI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { FeatureAvI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the feature_av_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return FeatureAvI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a FeatureAvI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or FeatureAvI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from FeatureAvI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = FeatureAvI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // FeatureAvI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+FeatureAvI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/FeatureAvTableMap.php b/core/lib/Thelia/Model/Map/FeatureAvTableMap.php
new file mode 100644
index 000000000..f447f8dc5
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/FeatureAvTableMap.php
@@ -0,0 +1,461 @@
+ array('Id', 'FeatureId', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'featureId', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(FeatureAvTableMap::ID, FeatureAvTableMap::FEATURE_ID, FeatureAvTableMap::CREATED_AT, FeatureAvTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'FEATURE_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'feature_id', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'FeatureId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'featureId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ self::TYPE_COLNAME => array(FeatureAvTableMap::ID => 0, FeatureAvTableMap::FEATURE_ID => 1, FeatureAvTableMap::CREATED_AT => 2, FeatureAvTableMap::UPDATED_AT => 3, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'FEATURE_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'feature_id' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('feature_av');
+ $this->setPhpName('FeatureAv');
+ $this->setClassName('\\Thelia\\Model\\FeatureAv');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Feature', '\\Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('FeatureProd', '\\Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'feature_av_id', ), 'CASCADE', 'RESTRICT', 'FeatureProds');
+ $this->addRelation('FeatureAvI18n', '\\Thelia\\Model\\FeatureAvI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'FeatureAvI18ns');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to feature_av * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ FeatureProdTableMap::clearInstancePool();
+ FeatureAvI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? FeatureAvTableMap::CLASS_DEFAULT : FeatureAvTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (FeatureAv object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = FeatureAvTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = FeatureAvTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + FeatureAvTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FeatureAvTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ FeatureAvTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = FeatureAvTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = FeatureAvTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FeatureAvTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FeatureAvTableMap::ID);
+ $criteria->addSelectColumn(FeatureAvTableMap::FEATURE_ID);
+ $criteria->addSelectColumn(FeatureAvTableMap::CREATED_AT);
+ $criteria->addSelectColumn(FeatureAvTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.FEATURE_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(FeatureAvTableMap::DATABASE_NAME)->getTable(FeatureAvTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureAvTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(FeatureAvTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new FeatureAvTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a FeatureAv or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or FeatureAv object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\FeatureAv) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(FeatureAvTableMap::DATABASE_NAME);
+ $criteria->add(FeatureAvTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = FeatureAvQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { FeatureAvTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { FeatureAvTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the feature_av table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return FeatureAvQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a FeatureAv or Criteria object.
+ *
+ * @param mixed $criteria Criteria or FeatureAv object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from FeatureAv object
+ }
+
+ if ($criteria->containsKey(FeatureAvTableMap::ID) && $criteria->keyContainsValue(FeatureAvTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureAvTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = FeatureAvQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // FeatureAvTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+FeatureAvTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/FeatureCategoryTableMap.php b/core/lib/Thelia/Model/Map/FeatureCategoryTableMap.php
new file mode 100644
index 000000000..3e20805b6
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/FeatureCategoryTableMap.php
@@ -0,0 +1,449 @@
+ array('Id', 'FeatureId', 'CategoryId', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'featureId', 'categoryId', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(FeatureCategoryTableMap::ID, FeatureCategoryTableMap::FEATURE_ID, FeatureCategoryTableMap::CATEGORY_ID, FeatureCategoryTableMap::CREATED_AT, FeatureCategoryTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'FEATURE_ID', 'CATEGORY_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'feature_id', 'category_id', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'FeatureId' => 1, 'CategoryId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'featureId' => 1, 'categoryId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ self::TYPE_COLNAME => array(FeatureCategoryTableMap::ID => 0, FeatureCategoryTableMap::FEATURE_ID => 1, FeatureCategoryTableMap::CATEGORY_ID => 2, FeatureCategoryTableMap::CREATED_AT => 3, FeatureCategoryTableMap::UPDATED_AT => 4, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'FEATURE_ID' => 1, 'CATEGORY_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'feature_id' => 1, 'category_id' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('feature_category');
+ $this->setPhpName('FeatureCategory');
+ $this->setClassName('\\Thelia\\Model\\FeatureCategory');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ $this->setIsCrossRef(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Feature', '\\Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? FeatureCategoryTableMap::CLASS_DEFAULT : FeatureCategoryTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (FeatureCategory object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = FeatureCategoryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = FeatureCategoryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + FeatureCategoryTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FeatureCategoryTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ FeatureCategoryTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = FeatureCategoryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = FeatureCategoryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FeatureCategoryTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FeatureCategoryTableMap::ID);
+ $criteria->addSelectColumn(FeatureCategoryTableMap::FEATURE_ID);
+ $criteria->addSelectColumn(FeatureCategoryTableMap::CATEGORY_ID);
+ $criteria->addSelectColumn(FeatureCategoryTableMap::CREATED_AT);
+ $criteria->addSelectColumn(FeatureCategoryTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.FEATURE_ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(FeatureCategoryTableMap::DATABASE_NAME)->getTable(FeatureCategoryTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureCategoryTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(FeatureCategoryTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new FeatureCategoryTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a FeatureCategory or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or FeatureCategory object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\FeatureCategory) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(FeatureCategoryTableMap::DATABASE_NAME);
+ $criteria->add(FeatureCategoryTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = FeatureCategoryQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { FeatureCategoryTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { FeatureCategoryTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the feature_category table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return FeatureCategoryQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a FeatureCategory or Criteria object.
+ *
+ * @param mixed $criteria Criteria or FeatureCategory object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from FeatureCategory object
+ }
+
+ if ($criteria->containsKey(FeatureCategoryTableMap::ID) && $criteria->keyContainsValue(FeatureCategoryTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureCategoryTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = FeatureCategoryQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // FeatureCategoryTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+FeatureCategoryTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php b/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php
new file mode 100644
index 000000000..af0dfc263
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(FeatureI18nTableMap::ID, FeatureI18nTableMap::LOCALE, FeatureI18nTableMap::TITLE, FeatureI18nTableMap::DESCRIPTION, FeatureI18nTableMap::CHAPO, FeatureI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(FeatureI18nTableMap::ID => 0, FeatureI18nTableMap::LOCALE => 1, FeatureI18nTableMap::TITLE => 2, FeatureI18nTableMap::DESCRIPTION => 3, FeatureI18nTableMap::CHAPO => 4, FeatureI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('feature_i18n');
+ $this->setPhpName('FeatureI18n');
+ $this->setClassName('\\Thelia\\Model\\FeatureI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Feature', '\\Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\FeatureI18n $obj A \Thelia\Model\FeatureI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\FeatureI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\FeatureI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\FeatureI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? FeatureI18nTableMap::CLASS_DEFAULT : FeatureI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (FeatureI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = FeatureI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = FeatureI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + FeatureI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FeatureI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ FeatureI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = FeatureI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = FeatureI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FeatureI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FeatureI18nTableMap::ID);
+ $criteria->addSelectColumn(FeatureI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(FeatureI18nTableMap::TITLE);
+ $criteria->addSelectColumn(FeatureI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(FeatureI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(FeatureI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(FeatureI18nTableMap::DATABASE_NAME)->getTable(FeatureI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(FeatureI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new FeatureI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a FeatureI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or FeatureI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\FeatureI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(FeatureI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(FeatureI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(FeatureI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = FeatureI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { FeatureI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { FeatureI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the feature_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return FeatureI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a FeatureI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or FeatureI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from FeatureI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = FeatureI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // FeatureI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+FeatureI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/FeatureProdTableMap.php b/core/lib/Thelia/Model/Map/FeatureProdTableMap.php
new file mode 100644
index 000000000..9d952afc3
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/FeatureProdTableMap.php
@@ -0,0 +1,473 @@
+ array('Id', 'ProductId', 'FeatureId', 'FeatureAvId', 'ByDefault', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'featureId', 'featureAvId', 'byDefault', 'position', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(FeatureProdTableMap::ID, FeatureProdTableMap::PRODUCT_ID, FeatureProdTableMap::FEATURE_ID, FeatureProdTableMap::FEATURE_AV_ID, FeatureProdTableMap::BY_DEFAULT, FeatureProdTableMap::POSITION, FeatureProdTableMap::CREATED_AT, FeatureProdTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'FEATURE_ID', 'FEATURE_AV_ID', 'BY_DEFAULT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'product_id', 'feature_id', 'feature_av_id', 'by_default', 'position', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'FeatureId' => 2, 'FeatureAvId' => 3, 'ByDefault' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'featureId' => 2, 'featureAvId' => 3, 'byDefault' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ self::TYPE_COLNAME => array(FeatureProdTableMap::ID => 0, FeatureProdTableMap::PRODUCT_ID => 1, FeatureProdTableMap::FEATURE_ID => 2, FeatureProdTableMap::FEATURE_AV_ID => 3, FeatureProdTableMap::BY_DEFAULT => 4, FeatureProdTableMap::POSITION => 5, FeatureProdTableMap::CREATED_AT => 6, FeatureProdTableMap::UPDATED_AT => 7, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'FEATURE_ID' => 2, 'FEATURE_AV_ID' => 3, 'BY_DEFAULT' => 4, 'POSITION' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'feature_id' => 2, 'feature_av_id' => 3, 'by_default' => 4, 'position' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('feature_prod');
+ $this->setPhpName('FeatureProd');
+ $this->setClassName('\\Thelia\\Model\\FeatureProd');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
+ $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null);
+ $this->addForeignKey('FEATURE_AV_ID', 'FeatureAvId', 'INTEGER', 'feature_av', 'ID', false, null, null);
+ $this->addColumn('BY_DEFAULT', 'ByDefault', 'VARCHAR', false, 255, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Feature', '\\Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('FeatureAv', '\\Thelia\\Model\\FeatureAv', RelationMap::MANY_TO_ONE, array('feature_av_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? FeatureProdTableMap::CLASS_DEFAULT : FeatureProdTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (FeatureProd object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = FeatureProdTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = FeatureProdTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + FeatureProdTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FeatureProdTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ FeatureProdTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = FeatureProdTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = FeatureProdTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FeatureProdTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FeatureProdTableMap::ID);
+ $criteria->addSelectColumn(FeatureProdTableMap::PRODUCT_ID);
+ $criteria->addSelectColumn(FeatureProdTableMap::FEATURE_ID);
+ $criteria->addSelectColumn(FeatureProdTableMap::FEATURE_AV_ID);
+ $criteria->addSelectColumn(FeatureProdTableMap::BY_DEFAULT);
+ $criteria->addSelectColumn(FeatureProdTableMap::POSITION);
+ $criteria->addSelectColumn(FeatureProdTableMap::CREATED_AT);
+ $criteria->addSelectColumn(FeatureProdTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.FEATURE_ID');
+ $criteria->addSelectColumn($alias . '.FEATURE_AV_ID');
+ $criteria->addSelectColumn($alias . '.BY_DEFAULT');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(FeatureProdTableMap::DATABASE_NAME)->getTable(FeatureProdTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureProdTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(FeatureProdTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new FeatureProdTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a FeatureProd or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or FeatureProd object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureProdTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\FeatureProd) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(FeatureProdTableMap::DATABASE_NAME);
+ $criteria->add(FeatureProdTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = FeatureProdQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { FeatureProdTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { FeatureProdTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the feature_prod table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return FeatureProdQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a FeatureProd or Criteria object.
+ *
+ * @param mixed $criteria Criteria or FeatureProd object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureProdTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from FeatureProd object
+ }
+
+ if ($criteria->containsKey(FeatureProdTableMap::ID) && $criteria->keyContainsValue(FeatureProdTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureProdTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = FeatureProdQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // FeatureProdTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+FeatureProdTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/FeatureTableMap.php b/core/lib/Thelia/Model/Map/FeatureTableMap.php
new file mode 100644
index 000000000..8d851559e
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/FeatureTableMap.php
@@ -0,0 +1,473 @@
+ array('Id', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'visible', 'position', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(FeatureTableMap::ID, FeatureTableMap::VISIBLE, FeatureTableMap::POSITION, FeatureTableMap::CREATED_AT, FeatureTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'visible', 'position', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
+ self::TYPE_COLNAME => array(FeatureTableMap::ID => 0, FeatureTableMap::VISIBLE => 1, FeatureTableMap::POSITION => 2, FeatureTableMap::CREATED_AT => 3, FeatureTableMap::UPDATED_AT => 4, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'VISIBLE' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('feature');
+ $this->setPhpName('Feature');
+ $this->setClassName('\\Thelia\\Model\\Feature');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('VISIBLE', 'Visible', 'INTEGER', false, null, 0);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('FeatureAv', '\\Thelia\\Model\\FeatureAv', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT', 'FeatureAvs');
+ $this->addRelation('FeatureProd', '\\Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT', 'FeatureProds');
+ $this->addRelation('FeatureCategory', '\\Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT', 'FeatureCategories');
+ $this->addRelation('FeatureI18n', '\\Thelia\\Model\\FeatureI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'FeatureI18ns');
+ $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Categories');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to feature * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ FeatureAvTableMap::clearInstancePool();
+ FeatureProdTableMap::clearInstancePool();
+ FeatureCategoryTableMap::clearInstancePool();
+ FeatureI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? FeatureTableMap::CLASS_DEFAULT : FeatureTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Feature object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = FeatureTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = FeatureTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + FeatureTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FeatureTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ FeatureTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = FeatureTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = FeatureTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FeatureTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FeatureTableMap::ID);
+ $criteria->addSelectColumn(FeatureTableMap::VISIBLE);
+ $criteria->addSelectColumn(FeatureTableMap::POSITION);
+ $criteria->addSelectColumn(FeatureTableMap::CREATED_AT);
+ $criteria->addSelectColumn(FeatureTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(FeatureTableMap::DATABASE_NAME)->getTable(FeatureTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(FeatureTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new FeatureTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Feature or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Feature object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Feature) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(FeatureTableMap::DATABASE_NAME);
+ $criteria->add(FeatureTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = FeatureQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { FeatureTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { FeatureTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the feature table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return FeatureQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Feature or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Feature object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FeatureTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Feature object
+ }
+
+ if ($criteria->containsKey(FeatureTableMap::ID) && $criteria->keyContainsValue(FeatureTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = FeatureQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // FeatureTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+FeatureTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/FolderI18nTableMap.php b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php
new file mode 100644
index 000000000..fc85b17ec
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(FolderI18nTableMap::ID, FolderI18nTableMap::LOCALE, FolderI18nTableMap::TITLE, FolderI18nTableMap::DESCRIPTION, FolderI18nTableMap::CHAPO, FolderI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(FolderI18nTableMap::ID => 0, FolderI18nTableMap::LOCALE => 1, FolderI18nTableMap::TITLE => 2, FolderI18nTableMap::DESCRIPTION => 3, FolderI18nTableMap::CHAPO => 4, FolderI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('folder_i18n');
+ $this->setPhpName('FolderI18n');
+ $this->setClassName('\\Thelia\\Model\\FolderI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\FolderI18n $obj A \Thelia\Model\FolderI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\FolderI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\FolderI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\FolderI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? FolderI18nTableMap::CLASS_DEFAULT : FolderI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (FolderI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = FolderI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = FolderI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + FolderI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FolderI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ FolderI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = FolderI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = FolderI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FolderI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FolderI18nTableMap::ID);
+ $criteria->addSelectColumn(FolderI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(FolderI18nTableMap::TITLE);
+ $criteria->addSelectColumn(FolderI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(FolderI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(FolderI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(FolderI18nTableMap::DATABASE_NAME)->getTable(FolderI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(FolderI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(FolderI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new FolderI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a FolderI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or FolderI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\FolderI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(FolderI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(FolderI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(FolderI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = FolderI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { FolderI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { FolderI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the folder_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return FolderI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a FolderI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or FolderI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from FolderI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = FolderI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // FolderI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+FolderI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/FolderTableMap.php b/core/lib/Thelia/Model/Map/FolderTableMap.php
new file mode 100644
index 000000000..794e3691c
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/FolderTableMap.php
@@ -0,0 +1,518 @@
+ array('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ self::TYPE_COLNAME => array(FolderTableMap::ID, FolderTableMap::PARENT, FolderTableMap::LINK, FolderTableMap::VISIBLE, FolderTableMap::POSITION, FolderTableMap::CREATED_AT, FolderTableMap::UPDATED_AT, FolderTableMap::VERSION, FolderTableMap::VERSION_CREATED_AT, FolderTableMap::VERSION_CREATED_BY, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ self::TYPE_FIELDNAME => array('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ),
+ self::TYPE_COLNAME => array(FolderTableMap::ID => 0, FolderTableMap::PARENT => 1, FolderTableMap::LINK => 2, FolderTableMap::VISIBLE => 3, FolderTableMap::POSITION => 4, FolderTableMap::CREATED_AT => 5, FolderTableMap::UPDATED_AT => 6, FolderTableMap::VERSION => 7, FolderTableMap::VERSION_CREATED_AT => 8, FolderTableMap::VERSION_CREATED_BY => 9, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'PARENT' => 1, 'LINK' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, 'VERSION' => 7, 'VERSION_CREATED_AT' => 8, 'VERSION_CREATED_BY' => 9, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, 'version' => 7, 'version_created_at' => 8, 'version_created_by' => 9, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('folder');
+ $this->setPhpName('Folder');
+ $this->setClassName('\\Thelia\\Model\\Folder');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('PARENT', 'Parent', 'INTEGER', true, null, null);
+ $this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Image', '\\Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'Images');
+ $this->addRelation('Document', '\\Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'Documents');
+ $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'Rewritings');
+ $this->addRelation('ContentFolder', '\\Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'ContentFolders');
+ $this->addRelation('FolderI18n', '\\Thelia\\Model\\FolderI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'FolderI18ns');
+ $this->addRelation('FolderVersion', '\\Thelia\\Model\\FolderVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'FolderVersions');
+ $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Contents');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to folder * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ImageTableMap::clearInstancePool();
+ DocumentTableMap::clearInstancePool();
+ RewritingTableMap::clearInstancePool();
+ ContentFolderTableMap::clearInstancePool();
+ FolderI18nTableMap::clearInstancePool();
+ FolderVersionTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? FolderTableMap::CLASS_DEFAULT : FolderTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Folder object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = FolderTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = FolderTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + FolderTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FolderTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ FolderTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = FolderTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = FolderTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FolderTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FolderTableMap::ID);
+ $criteria->addSelectColumn(FolderTableMap::PARENT);
+ $criteria->addSelectColumn(FolderTableMap::LINK);
+ $criteria->addSelectColumn(FolderTableMap::VISIBLE);
+ $criteria->addSelectColumn(FolderTableMap::POSITION);
+ $criteria->addSelectColumn(FolderTableMap::CREATED_AT);
+ $criteria->addSelectColumn(FolderTableMap::UPDATED_AT);
+ $criteria->addSelectColumn(FolderTableMap::VERSION);
+ $criteria->addSelectColumn(FolderTableMap::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(FolderTableMap::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PARENT');
+ $criteria->addSelectColumn($alias . '.LINK');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(FolderTableMap::DATABASE_NAME)->getTable(FolderTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(FolderTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(FolderTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new FolderTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Folder or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Folder object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Folder) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(FolderTableMap::DATABASE_NAME);
+ $criteria->add(FolderTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = FolderQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { FolderTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { FolderTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the folder table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return FolderQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Folder or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Folder object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Folder object
+ }
+
+ if ($criteria->containsKey(FolderTableMap::ID) && $criteria->keyContainsValue(FolderTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.FolderTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = FolderQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // FolderTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+FolderTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/FolderVersionTableMap.php b/core/lib/Thelia/Model/Map/FolderVersionTableMap.php
new file mode 100644
index 000000000..c686b7da1
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/FolderVersionTableMap.php
@@ -0,0 +1,529 @@
+ array('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ self::TYPE_COLNAME => array(FolderVersionTableMap::ID, FolderVersionTableMap::PARENT, FolderVersionTableMap::LINK, FolderVersionTableMap::VISIBLE, FolderVersionTableMap::POSITION, FolderVersionTableMap::CREATED_AT, FolderVersionTableMap::UPDATED_AT, FolderVersionTableMap::VERSION, FolderVersionTableMap::VERSION_CREATED_AT, FolderVersionTableMap::VERSION_CREATED_BY, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ self::TYPE_FIELDNAME => array('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ),
+ self::TYPE_COLNAME => array(FolderVersionTableMap::ID => 0, FolderVersionTableMap::PARENT => 1, FolderVersionTableMap::LINK => 2, FolderVersionTableMap::VISIBLE => 3, FolderVersionTableMap::POSITION => 4, FolderVersionTableMap::CREATED_AT => 5, FolderVersionTableMap::UPDATED_AT => 6, FolderVersionTableMap::VERSION => 7, FolderVersionTableMap::VERSION_CREATED_AT => 8, FolderVersionTableMap::VERSION_CREATED_BY => 9, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'PARENT' => 1, 'LINK' => 2, 'VISIBLE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, 'VERSION' => 7, 'VERSION_CREATED_AT' => 8, 'VERSION_CREATED_BY' => 9, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, 'version' => 7, 'version_created_at' => 8, 'version_created_by' => 9, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('folder_version');
+ $this->setPhpName('FolderVersion');
+ $this->setClassName('\\Thelia\\Model\\FolderVersion');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder', 'ID', true, null, null);
+ $this->addColumn('PARENT', 'Parent', 'INTEGER', true, null, null);
+ $this->addColumn('LINK', 'Link', 'VARCHAR', false, 255, null);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\FolderVersion $obj A \Thelia\Model\FolderVersion object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getVersion()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\FolderVersion object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\FolderVersion) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getVersion()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\FolderVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 7 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 7 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? FolderVersionTableMap::CLASS_DEFAULT : FolderVersionTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (FolderVersion object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = FolderVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = FolderVersionTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + FolderVersionTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = FolderVersionTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ FolderVersionTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = FolderVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = FolderVersionTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ FolderVersionTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(FolderVersionTableMap::ID);
+ $criteria->addSelectColumn(FolderVersionTableMap::PARENT);
+ $criteria->addSelectColumn(FolderVersionTableMap::LINK);
+ $criteria->addSelectColumn(FolderVersionTableMap::VISIBLE);
+ $criteria->addSelectColumn(FolderVersionTableMap::POSITION);
+ $criteria->addSelectColumn(FolderVersionTableMap::CREATED_AT);
+ $criteria->addSelectColumn(FolderVersionTableMap::UPDATED_AT);
+ $criteria->addSelectColumn(FolderVersionTableMap::VERSION);
+ $criteria->addSelectColumn(FolderVersionTableMap::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(FolderVersionTableMap::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PARENT');
+ $criteria->addSelectColumn($alias . '.LINK');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(FolderVersionTableMap::DATABASE_NAME)->getTable(FolderVersionTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(FolderVersionTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(FolderVersionTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new FolderVersionTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a FolderVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or FolderVersion object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderVersionTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\FolderVersion) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(FolderVersionTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(FolderVersionTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(FolderVersionTableMap::VERSION, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = FolderVersionQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { FolderVersionTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { FolderVersionTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the folder_version table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return FolderVersionQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a FolderVersion or Criteria object.
+ *
+ * @param mixed $criteria Criteria or FolderVersion object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(FolderVersionTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from FolderVersion object
+ }
+
+
+ // Set the correct dbName
+ $query = FolderVersionQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // FolderVersionTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+FolderVersionTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/GroupI18nTableMap.php b/core/lib/Thelia/Model/Map/GroupI18nTableMap.php
new file mode 100644
index 000000000..585127821
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/GroupI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(GroupI18nTableMap::ID, GroupI18nTableMap::LOCALE, GroupI18nTableMap::TITLE, GroupI18nTableMap::DESCRIPTION, GroupI18nTableMap::CHAPO, GroupI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(GroupI18nTableMap::ID => 0, GroupI18nTableMap::LOCALE => 1, GroupI18nTableMap::TITLE => 2, GroupI18nTableMap::DESCRIPTION => 3, GroupI18nTableMap::CHAPO => 4, GroupI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('group_i18n');
+ $this->setPhpName('GroupI18n');
+ $this->setClassName('\\Thelia\\Model\\GroupI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'group', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Group', '\\Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\GroupI18n $obj A \Thelia\Model\GroupI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\GroupI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\GroupI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\GroupI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? GroupI18nTableMap::CLASS_DEFAULT : GroupI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (GroupI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = GroupI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = GroupI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + GroupI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = GroupI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ GroupI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = GroupI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = GroupI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ GroupI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(GroupI18nTableMap::ID);
+ $criteria->addSelectColumn(GroupI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(GroupI18nTableMap::TITLE);
+ $criteria->addSelectColumn(GroupI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(GroupI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(GroupI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(GroupI18nTableMap::DATABASE_NAME)->getTable(GroupI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(GroupI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(GroupI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new GroupI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a GroupI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or GroupI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\GroupI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(GroupI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(GroupI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(GroupI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = GroupI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { GroupI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { GroupI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the group_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return GroupI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a GroupI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or GroupI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from GroupI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = GroupI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // GroupI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+GroupI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/GroupModuleTableMap.php b/core/lib/Thelia/Model/Map/GroupModuleTableMap.php
new file mode 100644
index 000000000..49361d253
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/GroupModuleTableMap.php
@@ -0,0 +1,456 @@
+ array('Id', 'GroupId', 'ModuleId', 'Access', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'groupId', 'moduleId', 'access', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(GroupModuleTableMap::ID, GroupModuleTableMap::GROUP_ID, GroupModuleTableMap::MODULE_ID, GroupModuleTableMap::ACCESS, GroupModuleTableMap::CREATED_AT, GroupModuleTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'GROUP_ID', 'MODULE_ID', 'ACCESS', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'group_id', 'module_id', 'access', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'GroupId' => 1, 'ModuleId' => 2, 'Access' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'groupId' => 1, 'moduleId' => 2, 'access' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ self::TYPE_COLNAME => array(GroupModuleTableMap::ID => 0, GroupModuleTableMap::GROUP_ID => 1, GroupModuleTableMap::MODULE_ID => 2, GroupModuleTableMap::ACCESS => 3, GroupModuleTableMap::CREATED_AT => 4, GroupModuleTableMap::UPDATED_AT => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'GROUP_ID' => 1, 'MODULE_ID' => 2, 'ACCESS' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'group_id' => 1, 'module_id' => 2, 'access' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('group_module');
+ $this->setPhpName('GroupModule');
+ $this->setClassName('\\Thelia\\Model\\GroupModule');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('GROUP_ID', 'GroupId', 'INTEGER', 'group', 'ID', true, null, null);
+ $this->addForeignKey('MODULE_ID', 'ModuleId', 'INTEGER', 'module', 'ID', false, null, null);
+ $this->addColumn('ACCESS', 'Access', 'TINYINT', false, null, 0);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Group', '\\Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'CASCADE');
+ $this->addRelation('Module', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('module_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? GroupModuleTableMap::CLASS_DEFAULT : GroupModuleTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (GroupModule object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = GroupModuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = GroupModuleTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + GroupModuleTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = GroupModuleTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ GroupModuleTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = GroupModuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = GroupModuleTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ GroupModuleTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(GroupModuleTableMap::ID);
+ $criteria->addSelectColumn(GroupModuleTableMap::GROUP_ID);
+ $criteria->addSelectColumn(GroupModuleTableMap::MODULE_ID);
+ $criteria->addSelectColumn(GroupModuleTableMap::ACCESS);
+ $criteria->addSelectColumn(GroupModuleTableMap::CREATED_AT);
+ $criteria->addSelectColumn(GroupModuleTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.GROUP_ID');
+ $criteria->addSelectColumn($alias . '.MODULE_ID');
+ $criteria->addSelectColumn($alias . '.ACCESS');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(GroupModuleTableMap::DATABASE_NAME)->getTable(GroupModuleTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(GroupModuleTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(GroupModuleTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new GroupModuleTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a GroupModule or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or GroupModule object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\GroupModule) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(GroupModuleTableMap::DATABASE_NAME);
+ $criteria->add(GroupModuleTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = GroupModuleQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { GroupModuleTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { GroupModuleTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the group_module table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return GroupModuleQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a GroupModule or Criteria object.
+ *
+ * @param mixed $criteria Criteria or GroupModule object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from GroupModule object
+ }
+
+ if ($criteria->containsKey(GroupModuleTableMap::ID) && $criteria->keyContainsValue(GroupModuleTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupModuleTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = GroupModuleQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // GroupModuleTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+GroupModuleTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/GroupResourceTableMap.php b/core/lib/Thelia/Model/Map/GroupResourceTableMap.php
new file mode 100644
index 000000000..9304d8e59
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/GroupResourceTableMap.php
@@ -0,0 +1,525 @@
+ array('Id', 'GroupId', 'ResourceId', 'Read', 'Write', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'groupId', 'resourceId', 'read', 'write', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(GroupResourceTableMap::ID, GroupResourceTableMap::GROUP_ID, GroupResourceTableMap::RESOURCE_ID, GroupResourceTableMap::READ, GroupResourceTableMap::WRITE, GroupResourceTableMap::CREATED_AT, GroupResourceTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'GROUP_ID', 'RESOURCE_ID', 'READ', 'WRITE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'group_id', 'resource_id', 'read', 'write', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'GroupId' => 1, 'ResourceId' => 2, 'Read' => 3, 'Write' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'groupId' => 1, 'resourceId' => 2, 'read' => 3, 'write' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ self::TYPE_COLNAME => array(GroupResourceTableMap::ID => 0, GroupResourceTableMap::GROUP_ID => 1, GroupResourceTableMap::RESOURCE_ID => 2, GroupResourceTableMap::READ => 3, GroupResourceTableMap::WRITE => 4, GroupResourceTableMap::CREATED_AT => 5, GroupResourceTableMap::UPDATED_AT => 6, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'GROUP_ID' => 1, 'RESOURCE_ID' => 2, 'READ' => 3, 'WRITE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'group_id' => 1, 'resource_id' => 2, 'read' => 3, 'write' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('group_resource');
+ $this->setPhpName('GroupResource');
+ $this->setClassName('\\Thelia\\Model\\GroupResource');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ $this->setIsCrossRef(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignPrimaryKey('GROUP_ID', 'GroupId', 'INTEGER' , 'group', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('RESOURCE_ID', 'ResourceId', 'INTEGER' , 'resource', 'ID', true, null, null);
+ $this->addColumn('READ', 'Read', 'TINYINT', false, null, 0);
+ $this->addColumn('WRITE', 'Write', 'TINYINT', false, null, 0);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Group', '\\Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Resource', '\\Thelia\\Model\\Resource', RelationMap::MANY_TO_ONE, array('resource_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\GroupResource $obj A \Thelia\Model\GroupResource object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getGroupId(), (string) $obj->getResourceId()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\GroupResource object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\GroupResource) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getGroupId(), (string) $value->getResourceId()));
+
+ } elseif (is_array($value) && count($value) === 3) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1], (string) $value[2]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\GroupResource object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('ResourceId', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('ResourceId', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? GroupResourceTableMap::CLASS_DEFAULT : GroupResourceTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (GroupResource object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = GroupResourceTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = GroupResourceTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + GroupResourceTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = GroupResourceTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ GroupResourceTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = GroupResourceTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = GroupResourceTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ GroupResourceTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(GroupResourceTableMap::ID);
+ $criteria->addSelectColumn(GroupResourceTableMap::GROUP_ID);
+ $criteria->addSelectColumn(GroupResourceTableMap::RESOURCE_ID);
+ $criteria->addSelectColumn(GroupResourceTableMap::READ);
+ $criteria->addSelectColumn(GroupResourceTableMap::WRITE);
+ $criteria->addSelectColumn(GroupResourceTableMap::CREATED_AT);
+ $criteria->addSelectColumn(GroupResourceTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.GROUP_ID');
+ $criteria->addSelectColumn($alias . '.RESOURCE_ID');
+ $criteria->addSelectColumn($alias . '.READ');
+ $criteria->addSelectColumn($alias . '.WRITE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(GroupResourceTableMap::DATABASE_NAME)->getTable(GroupResourceTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(GroupResourceTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(GroupResourceTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new GroupResourceTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a GroupResource or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or GroupResource object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\GroupResource) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(GroupResourceTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(GroupResourceTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(GroupResourceTableMap::GROUP_ID, $value[1]));
+ $criterion->addAnd($criteria->getNewCriterion(GroupResourceTableMap::RESOURCE_ID, $value[2]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = GroupResourceQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { GroupResourceTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { GroupResourceTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the group_resource table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return GroupResourceQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a GroupResource or Criteria object.
+ *
+ * @param mixed $criteria Criteria or GroupResource object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from GroupResource object
+ }
+
+ if ($criteria->containsKey(GroupResourceTableMap::ID) && $criteria->keyContainsValue(GroupResourceTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupResourceTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = GroupResourceQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // GroupResourceTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+GroupResourceTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/GroupTableMap.php b/core/lib/Thelia/Model/Map/GroupTableMap.php
new file mode 100644
index 000000000..a8c830005
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/GroupTableMap.php
@@ -0,0 +1,466 @@
+ array('Id', 'Code', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'code', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(GroupTableMap::ID, GroupTableMap::CODE, GroupTableMap::CREATED_AT, GroupTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'code', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ self::TYPE_COLNAME => array(GroupTableMap::ID => 0, GroupTableMap::CODE => 1, GroupTableMap::CREATED_AT => 2, GroupTableMap::UPDATED_AT => 3, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('group');
+ $this->setPhpName('Group');
+ $this->setClassName('\\Thelia\\Model\\Group');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', true, 30, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('AdminGroup', '\\Thelia\\Model\\AdminGroup', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', 'RESTRICT', 'AdminGroups');
+ $this->addRelation('GroupResource', '\\Thelia\\Model\\GroupResource', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', 'RESTRICT', 'GroupResources');
+ $this->addRelation('GroupModule', '\\Thelia\\Model\\GroupModule', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', 'CASCADE', 'GroupModules');
+ $this->addRelation('GroupI18n', '\\Thelia\\Model\\GroupI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'GroupI18ns');
+ $this->addRelation('Admin', '\\Thelia\\Model\\Admin', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Admins');
+ $this->addRelation('Resource', '\\Thelia\\Model\\Resource', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Resources');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to group * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ AdminGroupTableMap::clearInstancePool();
+ GroupResourceTableMap::clearInstancePool();
+ GroupModuleTableMap::clearInstancePool();
+ GroupI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? GroupTableMap::CLASS_DEFAULT : GroupTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Group object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = GroupTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = GroupTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + GroupTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = GroupTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ GroupTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = GroupTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = GroupTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ GroupTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(GroupTableMap::ID);
+ $criteria->addSelectColumn(GroupTableMap::CODE);
+ $criteria->addSelectColumn(GroupTableMap::CREATED_AT);
+ $criteria->addSelectColumn(GroupTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(GroupTableMap::DATABASE_NAME)->getTable(GroupTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(GroupTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(GroupTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new GroupTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Group or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Group object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Group) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(GroupTableMap::DATABASE_NAME);
+ $criteria->add(GroupTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = GroupQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { GroupTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { GroupTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the group table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return GroupQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Group or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Group object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Group object
+ }
+
+ if ($criteria->containsKey(GroupTableMap::ID) && $criteria->keyContainsValue(GroupTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = GroupQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // GroupTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+GroupTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ImageI18nTableMap.php b/core/lib/Thelia/Model/Map/ImageI18nTableMap.php
new file mode 100644
index 000000000..4f3b197a6
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ImageI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(ImageI18nTableMap::ID, ImageI18nTableMap::LOCALE, ImageI18nTableMap::TITLE, ImageI18nTableMap::DESCRIPTION, ImageI18nTableMap::CHAPO, ImageI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(ImageI18nTableMap::ID => 0, ImageI18nTableMap::LOCALE => 1, ImageI18nTableMap::TITLE => 2, ImageI18nTableMap::DESCRIPTION => 3, ImageI18nTableMap::CHAPO => 4, ImageI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('image_i18n');
+ $this->setPhpName('ImageI18n');
+ $this->setClassName('\\Thelia\\Model\\ImageI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'image', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Image', '\\Thelia\\Model\\Image', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\ImageI18n $obj A \Thelia\Model\ImageI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\ImageI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\ImageI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ImageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ImageI18nTableMap::CLASS_DEFAULT : ImageI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ImageI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ImageI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ImageI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ImageI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ImageI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ImageI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ImageI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ImageI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ImageI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ImageI18nTableMap::ID);
+ $criteria->addSelectColumn(ImageI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(ImageI18nTableMap::TITLE);
+ $criteria->addSelectColumn(ImageI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(ImageI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(ImageI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ImageI18nTableMap::DATABASE_NAME)->getTable(ImageI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ImageI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ImageI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ImageI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ImageI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ImageI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\ImageI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ImageI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(ImageI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(ImageI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = ImageI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ImageI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ImageI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the image_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ImageI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ImageI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or ImageI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from ImageI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = ImageI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ImageI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ImageI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ImageTableMap.php b/core/lib/Thelia/Model/Map/ImageTableMap.php
new file mode 100644
index 000000000..0f8d82b20
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ImageTableMap.php
@@ -0,0 +1,502 @@
+ array('Id', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'categoryId', 'folderId', 'contentId', 'file', 'position', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(ImageTableMap::ID, ImageTableMap::PRODUCT_ID, ImageTableMap::CATEGORY_ID, ImageTableMap::FOLDER_ID, ImageTableMap::CONTENT_ID, ImageTableMap::FILE, ImageTableMap::POSITION, ImageTableMap::CREATED_AT, ImageTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'product_id', 'category_id', 'folder_id', 'content_id', 'file', 'position', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'CategoryId' => 2, 'FolderId' => 3, 'ContentId' => 4, 'File' => 5, 'Position' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'categoryId' => 2, 'folderId' => 3, 'contentId' => 4, 'file' => 5, 'position' => 6, 'createdAt' => 7, 'updatedAt' => 8, ),
+ self::TYPE_COLNAME => array(ImageTableMap::ID => 0, ImageTableMap::PRODUCT_ID => 1, ImageTableMap::CATEGORY_ID => 2, ImageTableMap::FOLDER_ID => 3, ImageTableMap::CONTENT_ID => 4, ImageTableMap::FILE => 5, ImageTableMap::POSITION => 6, ImageTableMap::CREATED_AT => 7, ImageTableMap::UPDATED_AT => 8, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'CATEGORY_ID' => 2, 'FOLDER_ID' => 3, 'CONTENT_ID' => 4, 'FILE' => 5, 'POSITION' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'category_id' => 2, 'folder_id' => 3, 'content_id' => 4, 'file' => 5, 'position' => 6, 'created_at' => 7, 'updated_at' => 8, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('image');
+ $this->setPhpName('Image');
+ $this->setClassName('\\Thelia\\Model\\Image');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null);
+ $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null);
+ $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null);
+ $this->addColumn('FILE', 'File', 'VARCHAR', true, 255, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('ImageI18n', '\\Thelia\\Model\\ImageI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ImageI18ns');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to image * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ImageI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ImageTableMap::CLASS_DEFAULT : ImageTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Image object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ImageTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ImageTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ImageTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ImageTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ImageTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ImageTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ImageTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ImageTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ImageTableMap::ID);
+ $criteria->addSelectColumn(ImageTableMap::PRODUCT_ID);
+ $criteria->addSelectColumn(ImageTableMap::CATEGORY_ID);
+ $criteria->addSelectColumn(ImageTableMap::FOLDER_ID);
+ $criteria->addSelectColumn(ImageTableMap::CONTENT_ID);
+ $criteria->addSelectColumn(ImageTableMap::FILE);
+ $criteria->addSelectColumn(ImageTableMap::POSITION);
+ $criteria->addSelectColumn(ImageTableMap::CREATED_AT);
+ $criteria->addSelectColumn(ImageTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ $criteria->addSelectColumn($alias . '.FOLDER_ID');
+ $criteria->addSelectColumn($alias . '.CONTENT_ID');
+ $criteria->addSelectColumn($alias . '.FILE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ImageTableMap::DATABASE_NAME)->getTable(ImageTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ImageTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ImageTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ImageTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Image or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Image object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Image) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ImageTableMap::DATABASE_NAME);
+ $criteria->add(ImageTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = ImageQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ImageTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ImageTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the image table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ImageQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Image or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Image object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Image object
+ }
+
+ if ($criteria->containsKey(ImageTableMap::ID) && $criteria->keyContainsValue(ImageTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ImageTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = ImageQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ImageTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ImageTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/LangTableMap.php b/core/lib/Thelia/Model/Map/LangTableMap.php
new file mode 100644
index 000000000..86e3ebe16
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/LangTableMap.php
@@ -0,0 +1,470 @@
+ array('Id', 'Title', 'Code', 'Locale', 'Url', 'ByDefault', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'title', 'code', 'locale', 'url', 'byDefault', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(LangTableMap::ID, LangTableMap::TITLE, LangTableMap::CODE, LangTableMap::LOCALE, LangTableMap::URL, LangTableMap::BY_DEFAULT, LangTableMap::CREATED_AT, LangTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'TITLE', 'CODE', 'LOCALE', 'URL', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'title', 'code', 'locale', 'url', 'by_default', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Title' => 1, 'Code' => 2, 'Locale' => 3, 'Url' => 4, 'ByDefault' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'title' => 1, 'code' => 2, 'locale' => 3, 'url' => 4, 'byDefault' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ self::TYPE_COLNAME => array(LangTableMap::ID => 0, LangTableMap::TITLE => 1, LangTableMap::CODE => 2, LangTableMap::LOCALE => 3, LangTableMap::URL => 4, LangTableMap::BY_DEFAULT => 5, LangTableMap::CREATED_AT => 6, LangTableMap::UPDATED_AT => 7, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'TITLE' => 1, 'CODE' => 2, 'LOCALE' => 3, 'URL' => 4, 'BY_DEFAULT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'title' => 1, 'code' => 2, 'locale' => 3, 'url' => 4, 'by_default' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('lang');
+ $this->setPhpName('Lang');
+ $this->setClassName('\\Thelia\\Model\\Lang');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 100, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', false, 10, null);
+ $this->addColumn('LOCALE', 'Locale', 'VARCHAR', false, 45, null);
+ $this->addColumn('URL', 'Url', 'VARCHAR', false, 255, null);
+ $this->addColumn('BY_DEFAULT', 'ByDefault', 'TINYINT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? LangTableMap::CLASS_DEFAULT : LangTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Lang object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = LangTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = LangTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + LangTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = LangTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ LangTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = LangTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = LangTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ LangTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(LangTableMap::ID);
+ $criteria->addSelectColumn(LangTableMap::TITLE);
+ $criteria->addSelectColumn(LangTableMap::CODE);
+ $criteria->addSelectColumn(LangTableMap::LOCALE);
+ $criteria->addSelectColumn(LangTableMap::URL);
+ $criteria->addSelectColumn(LangTableMap::BY_DEFAULT);
+ $criteria->addSelectColumn(LangTableMap::CREATED_AT);
+ $criteria->addSelectColumn(LangTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.URL');
+ $criteria->addSelectColumn($alias . '.BY_DEFAULT');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(LangTableMap::DATABASE_NAME)->getTable(LangTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(LangTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(LangTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new LangTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Lang or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Lang object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(LangTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Lang) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(LangTableMap::DATABASE_NAME);
+ $criteria->add(LangTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = LangQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { LangTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { LangTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the lang table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return LangQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Lang or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Lang object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(LangTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Lang object
+ }
+
+ if ($criteria->containsKey(LangTableMap::ID) && $criteria->keyContainsValue(LangTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.LangTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = LangQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // LangTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+LangTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/MessageI18nTableMap.php b/core/lib/Thelia/Model/Map/MessageI18nTableMap.php
new file mode 100644
index 000000000..f084515c0
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/MessageI18nTableMap.php
@@ -0,0 +1,489 @@
+ array('Id', 'Locale', 'Title', 'Description', 'DescriptionHtml', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'descriptionHtml', ),
+ self::TYPE_COLNAME => array(MessageI18nTableMap::ID, MessageI18nTableMap::LOCALE, MessageI18nTableMap::TITLE, MessageI18nTableMap::DESCRIPTION, MessageI18nTableMap::DESCRIPTION_HTML, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'DESCRIPTION_HTML', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'description_html', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'DescriptionHtml' => 4, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'descriptionHtml' => 4, ),
+ self::TYPE_COLNAME => array(MessageI18nTableMap::ID => 0, MessageI18nTableMap::LOCALE => 1, MessageI18nTableMap::TITLE => 2, MessageI18nTableMap::DESCRIPTION => 3, MessageI18nTableMap::DESCRIPTION_HTML => 4, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'DESCRIPTION_HTML' => 4, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'description_html' => 4, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('message_i18n');
+ $this->setPhpName('MessageI18n');
+ $this->setClassName('\\Thelia\\Model\\MessageI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'message', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('DESCRIPTION_HTML', 'DescriptionHtml', 'CLOB', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Message', '\\Thelia\\Model\\Message', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\MessageI18n $obj A \Thelia\Model\MessageI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\MessageI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\MessageI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\MessageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? MessageI18nTableMap::CLASS_DEFAULT : MessageI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (MessageI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = MessageI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = MessageI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + MessageI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = MessageI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ MessageI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = MessageI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = MessageI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ MessageI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(MessageI18nTableMap::ID);
+ $criteria->addSelectColumn(MessageI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(MessageI18nTableMap::TITLE);
+ $criteria->addSelectColumn(MessageI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(MessageI18nTableMap::DESCRIPTION_HTML);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION_HTML');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(MessageI18nTableMap::DATABASE_NAME)->getTable(MessageI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(MessageI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(MessageI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new MessageI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a MessageI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or MessageI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\MessageI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(MessageI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(MessageI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(MessageI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = MessageI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { MessageI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { MessageI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the message_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return MessageI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a MessageI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or MessageI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from MessageI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = MessageI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // MessageI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+MessageI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/MessageTableMap.php b/core/lib/Thelia/Model/Map/MessageTableMap.php
new file mode 100644
index 000000000..de2a205f9
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/MessageTableMap.php
@@ -0,0 +1,501 @@
+ array('Id', 'Code', 'Secured', 'Ref', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'code', 'secured', 'ref', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ self::TYPE_COLNAME => array(MessageTableMap::ID, MessageTableMap::CODE, MessageTableMap::SECURED, MessageTableMap::REF, MessageTableMap::CREATED_AT, MessageTableMap::UPDATED_AT, MessageTableMap::VERSION, MessageTableMap::VERSION_CREATED_AT, MessageTableMap::VERSION_CREATED_BY, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'SECURED', 'REF', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ self::TYPE_FIELDNAME => array('id', 'code', 'secured', 'ref', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Secured' => 2, 'Ref' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, 'Version' => 6, 'VersionCreatedAt' => 7, 'VersionCreatedBy' => 8, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'secured' => 2, 'ref' => 3, 'createdAt' => 4, 'updatedAt' => 5, 'version' => 6, 'versionCreatedAt' => 7, 'versionCreatedBy' => 8, ),
+ self::TYPE_COLNAME => array(MessageTableMap::ID => 0, MessageTableMap::CODE => 1, MessageTableMap::SECURED => 2, MessageTableMap::REF => 3, MessageTableMap::CREATED_AT => 4, MessageTableMap::UPDATED_AT => 5, MessageTableMap::VERSION => 6, MessageTableMap::VERSION_CREATED_AT => 7, MessageTableMap::VERSION_CREATED_BY => 8, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'SECURED' => 2, 'REF' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, 'VERSION' => 6, 'VERSION_CREATED_AT' => 7, 'VERSION_CREATED_BY' => 8, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'secured' => 2, 'ref' => 3, 'created_at' => 4, 'updated_at' => 5, 'version' => 6, 'version_created_at' => 7, 'version_created_by' => 8, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('message');
+ $this->setPhpName('Message');
+ $this->setClassName('\\Thelia\\Model\\Message');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
+ $this->addColumn('SECURED', 'Secured', 'TINYINT', false, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', false, 255, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('MessageI18n', '\\Thelia\\Model\\MessageI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'MessageI18ns');
+ $this->addRelation('MessageVersion', '\\Thelia\\Model\\MessageVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'MessageVersions');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, description_html', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to message * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ MessageI18nTableMap::clearInstancePool();
+ MessageVersionTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? MessageTableMap::CLASS_DEFAULT : MessageTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Message object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = MessageTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = MessageTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + MessageTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = MessageTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ MessageTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = MessageTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = MessageTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ MessageTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(MessageTableMap::ID);
+ $criteria->addSelectColumn(MessageTableMap::CODE);
+ $criteria->addSelectColumn(MessageTableMap::SECURED);
+ $criteria->addSelectColumn(MessageTableMap::REF);
+ $criteria->addSelectColumn(MessageTableMap::CREATED_AT);
+ $criteria->addSelectColumn(MessageTableMap::UPDATED_AT);
+ $criteria->addSelectColumn(MessageTableMap::VERSION);
+ $criteria->addSelectColumn(MessageTableMap::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(MessageTableMap::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.SECURED');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(MessageTableMap::DATABASE_NAME)->getTable(MessageTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(MessageTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(MessageTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new MessageTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Message or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Message object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Message) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(MessageTableMap::DATABASE_NAME);
+ $criteria->add(MessageTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = MessageQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { MessageTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { MessageTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the message table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return MessageQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Message or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Message object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Message object
+ }
+
+ if ($criteria->containsKey(MessageTableMap::ID) && $criteria->keyContainsValue(MessageTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.MessageTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = MessageQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // MessageTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+MessageTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/MessageVersionTableMap.php b/core/lib/Thelia/Model/Map/MessageVersionTableMap.php
new file mode 100644
index 000000000..f6587e60a
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/MessageVersionTableMap.php
@@ -0,0 +1,521 @@
+ array('Id', 'Code', 'Secured', 'Ref', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'code', 'secured', 'ref', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ self::TYPE_COLNAME => array(MessageVersionTableMap::ID, MessageVersionTableMap::CODE, MessageVersionTableMap::SECURED, MessageVersionTableMap::REF, MessageVersionTableMap::CREATED_AT, MessageVersionTableMap::UPDATED_AT, MessageVersionTableMap::VERSION, MessageVersionTableMap::VERSION_CREATED_AT, MessageVersionTableMap::VERSION_CREATED_BY, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'SECURED', 'REF', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ self::TYPE_FIELDNAME => array('id', 'code', 'secured', 'ref', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Secured' => 2, 'Ref' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, 'Version' => 6, 'VersionCreatedAt' => 7, 'VersionCreatedBy' => 8, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'secured' => 2, 'ref' => 3, 'createdAt' => 4, 'updatedAt' => 5, 'version' => 6, 'versionCreatedAt' => 7, 'versionCreatedBy' => 8, ),
+ self::TYPE_COLNAME => array(MessageVersionTableMap::ID => 0, MessageVersionTableMap::CODE => 1, MessageVersionTableMap::SECURED => 2, MessageVersionTableMap::REF => 3, MessageVersionTableMap::CREATED_AT => 4, MessageVersionTableMap::UPDATED_AT => 5, MessageVersionTableMap::VERSION => 6, MessageVersionTableMap::VERSION_CREATED_AT => 7, MessageVersionTableMap::VERSION_CREATED_BY => 8, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'SECURED' => 2, 'REF' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, 'VERSION' => 6, 'VERSION_CREATED_AT' => 7, 'VERSION_CREATED_BY' => 8, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'secured' => 2, 'ref' => 3, 'created_at' => 4, 'updated_at' => 5, 'version' => 6, 'version_created_at' => 7, 'version_created_by' => 8, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('message_version');
+ $this->setPhpName('MessageVersion');
+ $this->setClassName('\\Thelia\\Model\\MessageVersion');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'message', 'ID', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null);
+ $this->addColumn('SECURED', 'Secured', 'TINYINT', false, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', false, 255, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Message', '\\Thelia\\Model\\Message', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\MessageVersion $obj A \Thelia\Model\MessageVersion object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getVersion()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\MessageVersion object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\MessageVersion) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getVersion()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\MessageVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 6 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 6 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? MessageVersionTableMap::CLASS_DEFAULT : MessageVersionTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (MessageVersion object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = MessageVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = MessageVersionTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + MessageVersionTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = MessageVersionTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ MessageVersionTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = MessageVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = MessageVersionTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ MessageVersionTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(MessageVersionTableMap::ID);
+ $criteria->addSelectColumn(MessageVersionTableMap::CODE);
+ $criteria->addSelectColumn(MessageVersionTableMap::SECURED);
+ $criteria->addSelectColumn(MessageVersionTableMap::REF);
+ $criteria->addSelectColumn(MessageVersionTableMap::CREATED_AT);
+ $criteria->addSelectColumn(MessageVersionTableMap::UPDATED_AT);
+ $criteria->addSelectColumn(MessageVersionTableMap::VERSION);
+ $criteria->addSelectColumn(MessageVersionTableMap::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(MessageVersionTableMap::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.SECURED');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(MessageVersionTableMap::DATABASE_NAME)->getTable(MessageVersionTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(MessageVersionTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(MessageVersionTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new MessageVersionTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a MessageVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or MessageVersion object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageVersionTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\MessageVersion) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(MessageVersionTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(MessageVersionTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(MessageVersionTableMap::VERSION, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = MessageVersionQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { MessageVersionTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { MessageVersionTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the message_version table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return MessageVersionQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a MessageVersion or Criteria object.
+ *
+ * @param mixed $criteria Criteria or MessageVersion object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(MessageVersionTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from MessageVersion object
+ }
+
+
+ // Set the correct dbName
+ $query = MessageVersionQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // MessageVersionTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+MessageVersionTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php b/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php
new file mode 100644
index 000000000..67b7a34ef
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(ModuleI18nTableMap::ID, ModuleI18nTableMap::LOCALE, ModuleI18nTableMap::TITLE, ModuleI18nTableMap::DESCRIPTION, ModuleI18nTableMap::CHAPO, ModuleI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(ModuleI18nTableMap::ID => 0, ModuleI18nTableMap::LOCALE => 1, ModuleI18nTableMap::TITLE => 2, ModuleI18nTableMap::DESCRIPTION => 3, ModuleI18nTableMap::CHAPO => 4, ModuleI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('module_i18n');
+ $this->setPhpName('ModuleI18n');
+ $this->setClassName('\\Thelia\\Model\\ModuleI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'module', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Module', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\ModuleI18n $obj A \Thelia\Model\ModuleI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\ModuleI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\ModuleI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ModuleI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ModuleI18nTableMap::CLASS_DEFAULT : ModuleI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ModuleI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ModuleI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ModuleI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ModuleI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ModuleI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ModuleI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ModuleI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ModuleI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ModuleI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ModuleI18nTableMap::ID);
+ $criteria->addSelectColumn(ModuleI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(ModuleI18nTableMap::TITLE);
+ $criteria->addSelectColumn(ModuleI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(ModuleI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(ModuleI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ModuleI18nTableMap::DATABASE_NAME)->getTable(ModuleI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ModuleI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ModuleI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ModuleI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ModuleI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ModuleI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ModuleI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\ModuleI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ModuleI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(ModuleI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(ModuleI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = ModuleI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ModuleI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ModuleI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the module_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ModuleI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ModuleI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or ModuleI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ModuleI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from ModuleI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = ModuleI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ModuleI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ModuleI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ModuleTableMap.php b/core/lib/Thelia/Model/Map/ModuleTableMap.php
new file mode 100644
index 000000000..5370c1da1
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ModuleTableMap.php
@@ -0,0 +1,484 @@
+ array('Id', 'Code', 'Type', 'Activate', 'Position', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'activate', 'position', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(ModuleTableMap::ID, ModuleTableMap::CODE, ModuleTableMap::TYPE, ModuleTableMap::ACTIVATE, ModuleTableMap::POSITION, ModuleTableMap::CREATED_AT, ModuleTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'ACTIVATE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'code', 'type', 'activate', 'position', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Activate' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'activate' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ self::TYPE_COLNAME => array(ModuleTableMap::ID => 0, ModuleTableMap::CODE => 1, ModuleTableMap::TYPE => 2, ModuleTableMap::ACTIVATE => 3, ModuleTableMap::POSITION => 4, ModuleTableMap::CREATED_AT => 5, ModuleTableMap::UPDATED_AT => 6, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'ACTIVATE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'activate' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('module');
+ $this->setPhpName('Module');
+ $this->setClassName('\\Thelia\\Model\\Module');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', true, 55, null);
+ $this->addColumn('TYPE', 'Type', 'TINYINT', true, null, null);
+ $this->addColumn('ACTIVATE', 'Activate', 'TINYINT', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('GroupModule', '\\Thelia\\Model\\GroupModule', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT', 'GroupModules');
+ $this->addRelation('ModuleI18n', '\\Thelia\\Model\\ModuleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ModuleI18ns');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to module * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ GroupModuleTableMap::clearInstancePool();
+ ModuleI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ModuleTableMap::CLASS_DEFAULT : ModuleTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Module object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ModuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ModuleTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ModuleTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ModuleTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ModuleTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ModuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ModuleTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ModuleTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ModuleTableMap::ID);
+ $criteria->addSelectColumn(ModuleTableMap::CODE);
+ $criteria->addSelectColumn(ModuleTableMap::TYPE);
+ $criteria->addSelectColumn(ModuleTableMap::ACTIVATE);
+ $criteria->addSelectColumn(ModuleTableMap::POSITION);
+ $criteria->addSelectColumn(ModuleTableMap::CREATED_AT);
+ $criteria->addSelectColumn(ModuleTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.TYPE');
+ $criteria->addSelectColumn($alias . '.ACTIVATE');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ModuleTableMap::DATABASE_NAME)->getTable(ModuleTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ModuleTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ModuleTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ModuleTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Module or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Module object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ModuleTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Module) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ModuleTableMap::DATABASE_NAME);
+ $criteria->add(ModuleTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = ModuleQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ModuleTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ModuleTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the module table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ModuleQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Module or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Module object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ModuleTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Module object
+ }
+
+ if ($criteria->containsKey(ModuleTableMap::ID) && $criteria->keyContainsValue(ModuleTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ModuleTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = ModuleQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ModuleTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ModuleTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/OrderAddressTableMap.php b/core/lib/Thelia/Model/Map/OrderAddressTableMap.php
new file mode 100644
index 000000000..18753e7f0
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/OrderAddressTableMap.php
@@ -0,0 +1,529 @@
+ array('Id', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'Phone', 'CountryId', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'phone', 'countryId', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(OrderAddressTableMap::ID, OrderAddressTableMap::CUSTOMER_TITLE_ID, OrderAddressTableMap::COMPANY, OrderAddressTableMap::FIRSTNAME, OrderAddressTableMap::LASTNAME, OrderAddressTableMap::ADDRESS1, OrderAddressTableMap::ADDRESS2, OrderAddressTableMap::ADDRESS3, OrderAddressTableMap::ZIPCODE, OrderAddressTableMap::CITY, OrderAddressTableMap::PHONE, OrderAddressTableMap::COUNTRY_ID, OrderAddressTableMap::CREATED_AT, OrderAddressTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'PHONE', 'COUNTRY_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'phone', 'country_id', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'CustomerTitleId' => 1, 'Company' => 2, 'Firstname' => 3, 'Lastname' => 4, 'Address1' => 5, 'Address2' => 6, 'Address3' => 7, 'Zipcode' => 8, 'City' => 9, 'Phone' => 10, 'CountryId' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'customerTitleId' => 1, 'company' => 2, 'firstname' => 3, 'lastname' => 4, 'address1' => 5, 'address2' => 6, 'address3' => 7, 'zipcode' => 8, 'city' => 9, 'phone' => 10, 'countryId' => 11, 'createdAt' => 12, 'updatedAt' => 13, ),
+ self::TYPE_COLNAME => array(OrderAddressTableMap::ID => 0, OrderAddressTableMap::CUSTOMER_TITLE_ID => 1, OrderAddressTableMap::COMPANY => 2, OrderAddressTableMap::FIRSTNAME => 3, OrderAddressTableMap::LASTNAME => 4, OrderAddressTableMap::ADDRESS1 => 5, OrderAddressTableMap::ADDRESS2 => 6, OrderAddressTableMap::ADDRESS3 => 7, OrderAddressTableMap::ZIPCODE => 8, OrderAddressTableMap::CITY => 9, OrderAddressTableMap::PHONE => 10, OrderAddressTableMap::COUNTRY_ID => 11, OrderAddressTableMap::CREATED_AT => 12, OrderAddressTableMap::UPDATED_AT => 13, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CUSTOMER_TITLE_ID' => 1, 'COMPANY' => 2, 'FIRSTNAME' => 3, 'LASTNAME' => 4, 'ADDRESS1' => 5, 'ADDRESS2' => 6, 'ADDRESS3' => 7, 'ZIPCODE' => 8, 'CITY' => 9, 'PHONE' => 10, 'COUNTRY_ID' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'customer_title_id' => 1, 'company' => 2, 'firstname' => 3, 'lastname' => 4, 'address1' => 5, 'address2' => 6, 'address3' => 7, 'zipcode' => 8, 'city' => 9, 'phone' => 10, 'country_id' => 11, 'created_at' => 12, 'updated_at' => 13, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('order_address');
+ $this->setPhpName('OrderAddress');
+ $this->setClassName('\\Thelia\\Model\\OrderAddress');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CUSTOMER_TITLE_ID', 'CustomerTitleId', 'INTEGER', false, null, null);
+ $this->addColumn('COMPANY', 'Company', 'VARCHAR', false, 255, null);
+ $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null);
+ $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS1', 'Address1', 'VARCHAR', true, 255, null);
+ $this->addColumn('ADDRESS2', 'Address2', 'VARCHAR', false, 255, null);
+ $this->addColumn('ADDRESS3', 'Address3', 'VARCHAR', false, 255, null);
+ $this->addColumn('ZIPCODE', 'Zipcode', 'VARCHAR', true, 10, null);
+ $this->addColumn('CITY', 'City', 'VARCHAR', true, 255, null);
+ $this->addColumn('PHONE', 'Phone', 'VARCHAR', false, 20, null);
+ $this->addColumn('COUNTRY_ID', 'CountryId', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('OrderRelatedByAddressInvoice', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'address_invoice', ), 'SET NULL', 'RESTRICT', 'OrdersRelatedByAddressInvoice');
+ $this->addRelation('OrderRelatedByAddressDelivery', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'address_delivery', ), 'SET NULL', 'RESTRICT', 'OrdersRelatedByAddressDelivery');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to order_address * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? OrderAddressTableMap::CLASS_DEFAULT : OrderAddressTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (OrderAddress object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = OrderAddressTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = OrderAddressTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + OrderAddressTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderAddressTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ OrderAddressTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = OrderAddressTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = OrderAddressTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderAddressTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderAddressTableMap::ID);
+ $criteria->addSelectColumn(OrderAddressTableMap::CUSTOMER_TITLE_ID);
+ $criteria->addSelectColumn(OrderAddressTableMap::COMPANY);
+ $criteria->addSelectColumn(OrderAddressTableMap::FIRSTNAME);
+ $criteria->addSelectColumn(OrderAddressTableMap::LASTNAME);
+ $criteria->addSelectColumn(OrderAddressTableMap::ADDRESS1);
+ $criteria->addSelectColumn(OrderAddressTableMap::ADDRESS2);
+ $criteria->addSelectColumn(OrderAddressTableMap::ADDRESS3);
+ $criteria->addSelectColumn(OrderAddressTableMap::ZIPCODE);
+ $criteria->addSelectColumn(OrderAddressTableMap::CITY);
+ $criteria->addSelectColumn(OrderAddressTableMap::PHONE);
+ $criteria->addSelectColumn(OrderAddressTableMap::COUNTRY_ID);
+ $criteria->addSelectColumn(OrderAddressTableMap::CREATED_AT);
+ $criteria->addSelectColumn(OrderAddressTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_TITLE_ID');
+ $criteria->addSelectColumn($alias . '.COMPANY');
+ $criteria->addSelectColumn($alias . '.FIRSTNAME');
+ $criteria->addSelectColumn($alias . '.LASTNAME');
+ $criteria->addSelectColumn($alias . '.ADDRESS1');
+ $criteria->addSelectColumn($alias . '.ADDRESS2');
+ $criteria->addSelectColumn($alias . '.ADDRESS3');
+ $criteria->addSelectColumn($alias . '.ZIPCODE');
+ $criteria->addSelectColumn($alias . '.CITY');
+ $criteria->addSelectColumn($alias . '.PHONE');
+ $criteria->addSelectColumn($alias . '.COUNTRY_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(OrderAddressTableMap::DATABASE_NAME)->getTable(OrderAddressTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderAddressTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(OrderAddressTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderAddressTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a OrderAddress or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or OrderAddress object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderAddressTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\OrderAddress) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(OrderAddressTableMap::DATABASE_NAME);
+ $criteria->add(OrderAddressTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = OrderAddressQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { OrderAddressTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { OrderAddressTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the order_address table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return OrderAddressQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a OrderAddress or Criteria object.
+ *
+ * @param mixed $criteria Criteria or OrderAddress object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderAddressTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from OrderAddress object
+ }
+
+ if ($criteria->containsKey(OrderAddressTableMap::ID) && $criteria->keyContainsValue(OrderAddressTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderAddressTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = OrderAddressQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // OrderAddressTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+OrderAddressTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/OrderFeatureTableMap.php b/core/lib/Thelia/Model/Map/OrderFeatureTableMap.php
new file mode 100644
index 000000000..e2981b7e3
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/OrderFeatureTableMap.php
@@ -0,0 +1,455 @@
+ array('Id', 'OrderProductId', 'FeatureDesc', 'FeatureAvDesc', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'orderProductId', 'featureDesc', 'featureAvDesc', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(OrderFeatureTableMap::ID, OrderFeatureTableMap::ORDER_PRODUCT_ID, OrderFeatureTableMap::FEATURE_DESC, OrderFeatureTableMap::FEATURE_AV_DESC, OrderFeatureTableMap::CREATED_AT, OrderFeatureTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'ORDER_PRODUCT_ID', 'FEATURE_DESC', 'FEATURE_AV_DESC', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'order_product_id', 'feature_desc', 'feature_av_desc', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'OrderProductId' => 1, 'FeatureDesc' => 2, 'FeatureAvDesc' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderProductId' => 1, 'featureDesc' => 2, 'featureAvDesc' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ self::TYPE_COLNAME => array(OrderFeatureTableMap::ID => 0, OrderFeatureTableMap::ORDER_PRODUCT_ID => 1, OrderFeatureTableMap::FEATURE_DESC => 2, OrderFeatureTableMap::FEATURE_AV_DESC => 3, OrderFeatureTableMap::CREATED_AT => 4, OrderFeatureTableMap::UPDATED_AT => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_PRODUCT_ID' => 1, 'FEATURE_DESC' => 2, 'FEATURE_AV_DESC' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'order_product_id' => 1, 'feature_desc' => 2, 'feature_av_desc' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('order_feature');
+ $this->setPhpName('OrderFeature');
+ $this->setClassName('\\Thelia\\Model\\OrderFeature');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('ORDER_PRODUCT_ID', 'OrderProductId', 'INTEGER', 'order_product', 'ID', true, null, null);
+ $this->addColumn('FEATURE_DESC', 'FeatureDesc', 'VARCHAR', false, 255, null);
+ $this->addColumn('FEATURE_AV_DESC', 'FeatureAvDesc', 'VARCHAR', false, 255, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('OrderProduct', '\\Thelia\\Model\\OrderProduct', RelationMap::MANY_TO_ONE, array('order_product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? OrderFeatureTableMap::CLASS_DEFAULT : OrderFeatureTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (OrderFeature object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = OrderFeatureTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = OrderFeatureTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + OrderFeatureTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderFeatureTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ OrderFeatureTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = OrderFeatureTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = OrderFeatureTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderFeatureTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderFeatureTableMap::ID);
+ $criteria->addSelectColumn(OrderFeatureTableMap::ORDER_PRODUCT_ID);
+ $criteria->addSelectColumn(OrderFeatureTableMap::FEATURE_DESC);
+ $criteria->addSelectColumn(OrderFeatureTableMap::FEATURE_AV_DESC);
+ $criteria->addSelectColumn(OrderFeatureTableMap::CREATED_AT);
+ $criteria->addSelectColumn(OrderFeatureTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.ORDER_PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.FEATURE_DESC');
+ $criteria->addSelectColumn($alias . '.FEATURE_AV_DESC');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(OrderFeatureTableMap::DATABASE_NAME)->getTable(OrderFeatureTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderFeatureTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(OrderFeatureTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderFeatureTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a OrderFeature or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or OrderFeature object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderFeatureTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\OrderFeature) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(OrderFeatureTableMap::DATABASE_NAME);
+ $criteria->add(OrderFeatureTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = OrderFeatureQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { OrderFeatureTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { OrderFeatureTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the order_feature table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return OrderFeatureQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a OrderFeature or Criteria object.
+ *
+ * @param mixed $criteria Criteria or OrderFeature object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderFeatureTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from OrderFeature object
+ }
+
+ if ($criteria->containsKey(OrderFeatureTableMap::ID) && $criteria->keyContainsValue(OrderFeatureTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderFeatureTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = OrderFeatureQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // OrderFeatureTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+OrderFeatureTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/OrderProductTableMap.php b/core/lib/Thelia/Model/Map/OrderProductTableMap.php
new file mode 100644
index 000000000..038d12863
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/OrderProductTableMap.php
@@ -0,0 +1,513 @@
+ array('Id', 'OrderId', 'ProductRef', 'Title', 'Description', 'Chapo', 'Quantity', 'Price', 'Tax', 'Parent', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::TITLE, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::CHAPO, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::TAX, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'TITLE', 'DESCRIPTION', 'CHAPO', 'QUANTITY', 'PRICE', 'TAX', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'Quantity' => 6, 'Price' => 7, 'Tax' => 8, 'Parent' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'createdAt' => 10, 'updatedAt' => 11, ),
+ self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::TITLE => 3, OrderProductTableMap::DESCRIPTION => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::QUANTITY => 6, OrderProductTableMap::PRICE => 7, OrderProductTableMap::TAX => 8, OrderProductTableMap::PARENT => 9, OrderProductTableMap::CREATED_AT => 10, OrderProductTableMap::UPDATED_AT => 11, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'QUANTITY' => 6, 'PRICE' => 7, 'TAX' => 8, 'PARENT' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'created_at' => 10, 'updated_at' => 11, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('order_product');
+ $this->setPhpName('OrderProduct');
+ $this->setClassName('\\Thelia\\Model\\OrderProduct');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null);
+ $this->addColumn('PRODUCT_REF', 'ProductRef', 'VARCHAR', false, 255, null);
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null);
+ $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null);
+ $this->addColumn('TAX', 'Tax', 'FLOAT', false, null, null);
+ $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('OrderFeature', '\\Thelia\\Model\\OrderFeature', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderFeatures');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to order_product * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderFeatureTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? OrderProductTableMap::CLASS_DEFAULT : OrderProductTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (OrderProduct object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = OrderProductTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = OrderProductTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + OrderProductTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderProductTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ OrderProductTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = OrderProductTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = OrderProductTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderProductTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderProductTableMap::ID);
+ $criteria->addSelectColumn(OrderProductTableMap::ORDER_ID);
+ $criteria->addSelectColumn(OrderProductTableMap::PRODUCT_REF);
+ $criteria->addSelectColumn(OrderProductTableMap::TITLE);
+ $criteria->addSelectColumn(OrderProductTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(OrderProductTableMap::CHAPO);
+ $criteria->addSelectColumn(OrderProductTableMap::QUANTITY);
+ $criteria->addSelectColumn(OrderProductTableMap::PRICE);
+ $criteria->addSelectColumn(OrderProductTableMap::TAX);
+ $criteria->addSelectColumn(OrderProductTableMap::PARENT);
+ $criteria->addSelectColumn(OrderProductTableMap::CREATED_AT);
+ $criteria->addSelectColumn(OrderProductTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.ORDER_ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_REF');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.QUANTITY');
+ $criteria->addSelectColumn($alias . '.PRICE');
+ $criteria->addSelectColumn($alias . '.TAX');
+ $criteria->addSelectColumn($alias . '.PARENT');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(OrderProductTableMap::DATABASE_NAME)->getTable(OrderProductTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderProductTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(OrderProductTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderProductTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a OrderProduct or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or OrderProduct object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\OrderProduct) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(OrderProductTableMap::DATABASE_NAME);
+ $criteria->add(OrderProductTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = OrderProductQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { OrderProductTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { OrderProductTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the order_product table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return OrderProductQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a OrderProduct or Criteria object.
+ *
+ * @param mixed $criteria Criteria or OrderProduct object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from OrderProduct object
+ }
+
+ if ($criteria->containsKey(OrderProductTableMap::ID) && $criteria->keyContainsValue(OrderProductTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderProductTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = OrderProductQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // OrderProductTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+OrderProductTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php
new file mode 100644
index 000000000..5d78c474c
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(OrderStatusI18nTableMap::ID, OrderStatusI18nTableMap::LOCALE, OrderStatusI18nTableMap::TITLE, OrderStatusI18nTableMap::DESCRIPTION, OrderStatusI18nTableMap::CHAPO, OrderStatusI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(OrderStatusI18nTableMap::ID => 0, OrderStatusI18nTableMap::LOCALE => 1, OrderStatusI18nTableMap::TITLE => 2, OrderStatusI18nTableMap::DESCRIPTION => 3, OrderStatusI18nTableMap::CHAPO => 4, OrderStatusI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('order_status_i18n');
+ $this->setPhpName('OrderStatusI18n');
+ $this->setClassName('\\Thelia\\Model\\OrderStatusI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order_status', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('OrderStatus', '\\Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\OrderStatusI18n $obj A \Thelia\Model\OrderStatusI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\OrderStatusI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\OrderStatusI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\OrderStatusI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? OrderStatusI18nTableMap::CLASS_DEFAULT : OrderStatusI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (OrderStatusI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = OrderStatusI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = OrderStatusI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + OrderStatusI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderStatusI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ OrderStatusI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = OrderStatusI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = OrderStatusI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderStatusI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderStatusI18nTableMap::ID);
+ $criteria->addSelectColumn(OrderStatusI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(OrderStatusI18nTableMap::TITLE);
+ $criteria->addSelectColumn(OrderStatusI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(OrderStatusI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(OrderStatusI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(OrderStatusI18nTableMap::DATABASE_NAME)->getTable(OrderStatusI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderStatusI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(OrderStatusI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderStatusI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a OrderStatusI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or OrderStatusI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\OrderStatusI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(OrderStatusI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(OrderStatusI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(OrderStatusI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = OrderStatusI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { OrderStatusI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { OrderStatusI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the order_status_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return OrderStatusI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a OrderStatusI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or OrderStatusI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from OrderStatusI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = OrderStatusI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // OrderStatusI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+OrderStatusI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php
new file mode 100644
index 000000000..eecfe5a03
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php
@@ -0,0 +1,460 @@
+ array('Id', 'Code', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'code', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(OrderStatusTableMap::ID, OrderStatusTableMap::CODE, OrderStatusTableMap::CREATED_AT, OrderStatusTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'code', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ self::TYPE_COLNAME => array(OrderStatusTableMap::ID => 0, OrderStatusTableMap::CODE => 1, OrderStatusTableMap::CREATED_AT => 2, OrderStatusTableMap::UPDATED_AT => 3, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('order_status');
+ $this->setPhpName('OrderStatus');
+ $this->setClassName('\\Thelia\\Model\\OrderStatus');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'SET NULL', 'RESTRICT', 'Orders');
+ $this->addRelation('OrderStatusI18n', '\\Thelia\\Model\\OrderStatusI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'OrderStatusI18ns');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to order_status * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderTableMap::clearInstancePool();
+ OrderStatusI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? OrderStatusTableMap::CLASS_DEFAULT : OrderStatusTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (OrderStatus object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = OrderStatusTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = OrderStatusTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + OrderStatusTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderStatusTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ OrderStatusTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = OrderStatusTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = OrderStatusTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderStatusTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderStatusTableMap::ID);
+ $criteria->addSelectColumn(OrderStatusTableMap::CODE);
+ $criteria->addSelectColumn(OrderStatusTableMap::CREATED_AT);
+ $criteria->addSelectColumn(OrderStatusTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(OrderStatusTableMap::DATABASE_NAME)->getTable(OrderStatusTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderStatusTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(OrderStatusTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderStatusTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a OrderStatus or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or OrderStatus object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\OrderStatus) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(OrderStatusTableMap::DATABASE_NAME);
+ $criteria->add(OrderStatusTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = OrderStatusQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { OrderStatusTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { OrderStatusTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the order_status table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return OrderStatusQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a OrderStatus or Criteria object.
+ *
+ * @param mixed $criteria Criteria or OrderStatus object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from OrderStatus object
+ }
+
+ if ($criteria->containsKey(OrderStatusTableMap::ID) && $criteria->keyContainsValue(OrderStatusTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderStatusTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = OrderStatusQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // OrderStatusTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+OrderStatusTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/OrderTableMap.php b/core/lib/Thelia/Model/Map/OrderTableMap.php
new file mode 100644
index 000000000..91d9b29de
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/OrderTableMap.php
@@ -0,0 +1,567 @@
+ array('Id', 'Ref', 'CustomerId', 'AddressInvoice', 'AddressDelivery', 'InvoiceDate', 'CurrencyId', 'CurrencyRate', 'Transaction', 'DeliveryNum', 'Invoice', 'Postage', 'Payment', 'Carrier', 'StatusId', 'Lang', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'customerId', 'addressInvoice', 'addressDelivery', 'invoiceDate', 'currencyId', 'currencyRate', 'transaction', 'deliveryNum', 'invoice', 'postage', 'payment', 'carrier', 'statusId', 'lang', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(OrderTableMap::ID, OrderTableMap::REF, OrderTableMap::CUSTOMER_ID, OrderTableMap::ADDRESS_INVOICE, OrderTableMap::ADDRESS_DELIVERY, OrderTableMap::INVOICE_DATE, OrderTableMap::CURRENCY_ID, OrderTableMap::CURRENCY_RATE, OrderTableMap::TRANSACTION, OrderTableMap::DELIVERY_NUM, OrderTableMap::INVOICE, OrderTableMap::POSTAGE, OrderTableMap::PAYMENT, OrderTableMap::CARRIER, OrderTableMap::STATUS_ID, OrderTableMap::LANG, OrderTableMap::CREATED_AT, OrderTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CUSTOMER_ID', 'ADDRESS_INVOICE', 'ADDRESS_DELIVERY', 'INVOICE_DATE', 'CURRENCY_ID', 'CURRENCY_RATE', 'TRANSACTION', 'DELIVERY_NUM', 'INVOICE', 'POSTAGE', 'PAYMENT', 'CARRIER', 'STATUS_ID', 'LANG', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'ref', 'customer_id', 'address_invoice', 'address_delivery', 'invoice_date', 'currency_id', 'currency_rate', 'transaction', 'delivery_num', 'invoice', 'postage', 'payment', 'carrier', 'status_id', 'lang', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'CustomerId' => 2, 'AddressInvoice' => 3, 'AddressDelivery' => 4, 'InvoiceDate' => 5, 'CurrencyId' => 6, 'CurrencyRate' => 7, 'Transaction' => 8, 'DeliveryNum' => 9, 'Invoice' => 10, 'Postage' => 11, 'Payment' => 12, 'Carrier' => 13, 'StatusId' => 14, 'Lang' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'customerId' => 2, 'addressInvoice' => 3, 'addressDelivery' => 4, 'invoiceDate' => 5, 'currencyId' => 6, 'currencyRate' => 7, 'transaction' => 8, 'deliveryNum' => 9, 'invoice' => 10, 'postage' => 11, 'payment' => 12, 'carrier' => 13, 'statusId' => 14, 'lang' => 15, 'createdAt' => 16, 'updatedAt' => 17, ),
+ self::TYPE_COLNAME => array(OrderTableMap::ID => 0, OrderTableMap::REF => 1, OrderTableMap::CUSTOMER_ID => 2, OrderTableMap::ADDRESS_INVOICE => 3, OrderTableMap::ADDRESS_DELIVERY => 4, OrderTableMap::INVOICE_DATE => 5, OrderTableMap::CURRENCY_ID => 6, OrderTableMap::CURRENCY_RATE => 7, OrderTableMap::TRANSACTION => 8, OrderTableMap::DELIVERY_NUM => 9, OrderTableMap::INVOICE => 10, OrderTableMap::POSTAGE => 11, OrderTableMap::PAYMENT => 12, OrderTableMap::CARRIER => 13, OrderTableMap::STATUS_ID => 14, OrderTableMap::LANG => 15, OrderTableMap::CREATED_AT => 16, OrderTableMap::UPDATED_AT => 17, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CUSTOMER_ID' => 2, 'ADDRESS_INVOICE' => 3, 'ADDRESS_DELIVERY' => 4, 'INVOICE_DATE' => 5, 'CURRENCY_ID' => 6, 'CURRENCY_RATE' => 7, 'TRANSACTION' => 8, 'DELIVERY_NUM' => 9, 'INVOICE' => 10, 'POSTAGE' => 11, 'PAYMENT' => 12, 'CARRIER' => 13, 'STATUS_ID' => 14, 'LANG' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'customer_id' => 2, 'address_invoice' => 3, 'address_delivery' => 4, 'invoice_date' => 5, 'currency_id' => 6, 'currency_rate' => 7, 'transaction' => 8, 'delivery_num' => 9, 'invoice' => 10, 'postage' => 11, 'payment' => 12, 'carrier' => 13, 'status_id' => 14, 'lang' => 15, 'created_at' => 16, 'updated_at' => 17, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('order');
+ $this->setPhpName('Order');
+ $this->setClassName('\\Thelia\\Model\\Order');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', false, 45, null);
+ $this->addForeignKey('CUSTOMER_ID', 'CustomerId', 'INTEGER', 'customer', 'ID', true, null, null);
+ $this->addForeignKey('ADDRESS_INVOICE', 'AddressInvoice', 'INTEGER', 'order_address', 'ID', false, null, null);
+ $this->addForeignKey('ADDRESS_DELIVERY', 'AddressDelivery', 'INTEGER', 'order_address', 'ID', false, null, null);
+ $this->addColumn('INVOICE_DATE', 'InvoiceDate', 'DATE', false, null, null);
+ $this->addForeignKey('CURRENCY_ID', 'CurrencyId', 'INTEGER', 'currency', 'ID', false, null, null);
+ $this->addColumn('CURRENCY_RATE', 'CurrencyRate', 'FLOAT', true, null, null);
+ $this->addColumn('TRANSACTION', 'Transaction', 'VARCHAR', false, 100, null);
+ $this->addColumn('DELIVERY_NUM', 'DeliveryNum', 'VARCHAR', false, 100, null);
+ $this->addColumn('INVOICE', 'Invoice', 'VARCHAR', false, 100, null);
+ $this->addColumn('POSTAGE', 'Postage', 'FLOAT', false, null, null);
+ $this->addColumn('PAYMENT', 'Payment', 'VARCHAR', true, 45, null);
+ $this->addColumn('CARRIER', 'Carrier', 'VARCHAR', true, 45, null);
+ $this->addForeignKey('STATUS_ID', 'StatusId', 'INTEGER', 'order_status', 'ID', false, null, null);
+ $this->addColumn('LANG', 'Lang', 'VARCHAR', true, 10, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Currency', '\\Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ $this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('OrderAddressRelatedByAddressInvoice', '\\Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('address_invoice' => 'id', ), 'SET NULL', 'RESTRICT');
+ $this->addRelation('OrderAddressRelatedByAddressDelivery', '\\Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('address_delivery' => 'id', ), 'SET NULL', 'RESTRICT');
+ $this->addRelation('OrderStatus', '\\Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('status_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ $this->addRelation('OrderProduct', '\\Thelia\\Model\\OrderProduct', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'OrderProducts');
+ $this->addRelation('CouponOrder', '\\Thelia\\Model\\CouponOrder', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'CouponOrders');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to order * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ OrderProductTableMap::clearInstancePool();
+ CouponOrderTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? OrderTableMap::CLASS_DEFAULT : OrderTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Order object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = OrderTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = OrderTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + OrderTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = OrderTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ OrderTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = OrderTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = OrderTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ OrderTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(OrderTableMap::ID);
+ $criteria->addSelectColumn(OrderTableMap::REF);
+ $criteria->addSelectColumn(OrderTableMap::CUSTOMER_ID);
+ $criteria->addSelectColumn(OrderTableMap::ADDRESS_INVOICE);
+ $criteria->addSelectColumn(OrderTableMap::ADDRESS_DELIVERY);
+ $criteria->addSelectColumn(OrderTableMap::INVOICE_DATE);
+ $criteria->addSelectColumn(OrderTableMap::CURRENCY_ID);
+ $criteria->addSelectColumn(OrderTableMap::CURRENCY_RATE);
+ $criteria->addSelectColumn(OrderTableMap::TRANSACTION);
+ $criteria->addSelectColumn(OrderTableMap::DELIVERY_NUM);
+ $criteria->addSelectColumn(OrderTableMap::INVOICE);
+ $criteria->addSelectColumn(OrderTableMap::POSTAGE);
+ $criteria->addSelectColumn(OrderTableMap::PAYMENT);
+ $criteria->addSelectColumn(OrderTableMap::CARRIER);
+ $criteria->addSelectColumn(OrderTableMap::STATUS_ID);
+ $criteria->addSelectColumn(OrderTableMap::LANG);
+ $criteria->addSelectColumn(OrderTableMap::CREATED_AT);
+ $criteria->addSelectColumn(OrderTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.CUSTOMER_ID');
+ $criteria->addSelectColumn($alias . '.ADDRESS_INVOICE');
+ $criteria->addSelectColumn($alias . '.ADDRESS_DELIVERY');
+ $criteria->addSelectColumn($alias . '.INVOICE_DATE');
+ $criteria->addSelectColumn($alias . '.CURRENCY_ID');
+ $criteria->addSelectColumn($alias . '.CURRENCY_RATE');
+ $criteria->addSelectColumn($alias . '.TRANSACTION');
+ $criteria->addSelectColumn($alias . '.DELIVERY_NUM');
+ $criteria->addSelectColumn($alias . '.INVOICE');
+ $criteria->addSelectColumn($alias . '.POSTAGE');
+ $criteria->addSelectColumn($alias . '.PAYMENT');
+ $criteria->addSelectColumn($alias . '.CARRIER');
+ $criteria->addSelectColumn($alias . '.STATUS_ID');
+ $criteria->addSelectColumn($alias . '.LANG');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(OrderTableMap::DATABASE_NAME)->getTable(OrderTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(OrderTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new OrderTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Order or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Order object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Order) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(OrderTableMap::DATABASE_NAME);
+ $criteria->add(OrderTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = OrderQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { OrderTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { OrderTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the order table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return OrderQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Order or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Order object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(OrderTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Order object
+ }
+
+ if ($criteria->containsKey(OrderTableMap::ID) && $criteria->keyContainsValue(OrderTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = OrderQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // OrderTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+OrderTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php b/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php
new file mode 100644
index 000000000..6a8361f27
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php
@@ -0,0 +1,496 @@
+ array('ProductId', 'CategoryId', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('productId', 'categoryId', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(ProductCategoryTableMap::PRODUCT_ID, ProductCategoryTableMap::CATEGORY_ID, ProductCategoryTableMap::CREATED_AT, ProductCategoryTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('PRODUCT_ID', 'CATEGORY_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('product_id', 'category_id', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('ProductId' => 0, 'CategoryId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ self::TYPE_STUDLYPHPNAME => array('productId' => 0, 'categoryId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ self::TYPE_COLNAME => array(ProductCategoryTableMap::PRODUCT_ID => 0, ProductCategoryTableMap::CATEGORY_ID => 1, ProductCategoryTableMap::CREATED_AT => 2, ProductCategoryTableMap::UPDATED_AT => 3, ),
+ self::TYPE_RAW_COLNAME => array('PRODUCT_ID' => 0, 'CATEGORY_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ self::TYPE_FIELDNAME => array('product_id' => 0, 'category_id' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('product_category');
+ $this->setPhpName('ProductCategory');
+ $this->setClassName('\\Thelia\\Model\\ProductCategory');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ $this->setIsCrossRef(true);
+ // columns
+ $this->addForeignPrimaryKey('PRODUCT_ID', 'ProductId', 'INTEGER' , 'product', 'ID', true, null, null);
+ $this->addForeignPrimaryKey('CATEGORY_ID', 'CategoryId', 'INTEGER' , 'category', 'ID', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\ProductCategory $obj A \Thelia\Model\ProductCategory object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getProductId(), (string) $obj->getCategoryId()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\ProductCategory object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\ProductCategory) {
+ $key = serialize(array((string) $value->getProductId(), (string) $value->getCategoryId()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ProductCategory object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ProductCategoryTableMap::CLASS_DEFAULT : ProductCategoryTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ProductCategory object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ProductCategoryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ProductCategoryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ProductCategoryTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ProductCategoryTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ProductCategoryTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ProductCategoryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ProductCategoryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ProductCategoryTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ProductCategoryTableMap::PRODUCT_ID);
+ $criteria->addSelectColumn(ProductCategoryTableMap::CATEGORY_ID);
+ $criteria->addSelectColumn(ProductCategoryTableMap::CREATED_AT);
+ $criteria->addSelectColumn(ProductCategoryTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ProductCategoryTableMap::DATABASE_NAME)->getTable(ProductCategoryTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProductCategoryTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ProductCategoryTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ProductCategoryTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ProductCategory or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ProductCategory object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductCategoryTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\ProductCategory) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ProductCategoryTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(ProductCategoryTableMap::PRODUCT_ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(ProductCategoryTableMap::CATEGORY_ID, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = ProductCategoryQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ProductCategoryTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ProductCategoryTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the product_category table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ProductCategoryQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ProductCategory or Criteria object.
+ *
+ * @param mixed $criteria Criteria or ProductCategory object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductCategoryTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from ProductCategory object
+ }
+
+
+ // Set the correct dbName
+ $query = ProductCategoryQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ProductCategoryTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ProductCategoryTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php
new file mode 100644
index 000000000..8da33f15d
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(ProductI18nTableMap::ID, ProductI18nTableMap::LOCALE, ProductI18nTableMap::TITLE, ProductI18nTableMap::DESCRIPTION, ProductI18nTableMap::CHAPO, ProductI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(ProductI18nTableMap::ID => 0, ProductI18nTableMap::LOCALE => 1, ProductI18nTableMap::TITLE => 2, ProductI18nTableMap::DESCRIPTION => 3, ProductI18nTableMap::CHAPO => 4, ProductI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('product_i18n');
+ $this->setPhpName('ProductI18n');
+ $this->setClassName('\\Thelia\\Model\\ProductI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\ProductI18n $obj A \Thelia\Model\ProductI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\ProductI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\ProductI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ProductI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ProductI18nTableMap::CLASS_DEFAULT : ProductI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ProductI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ProductI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ProductI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ProductI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ProductI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ProductI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ProductI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ProductI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ProductI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ProductI18nTableMap::ID);
+ $criteria->addSelectColumn(ProductI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(ProductI18nTableMap::TITLE);
+ $criteria->addSelectColumn(ProductI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(ProductI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(ProductI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ProductI18nTableMap::DATABASE_NAME)->getTable(ProductI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProductI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ProductI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ProductI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ProductI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ProductI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\ProductI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ProductI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(ProductI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(ProductI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = ProductI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ProductI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ProductI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the product_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ProductI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ProductI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or ProductI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from ProductI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = ProductI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ProductI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ProductI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php
new file mode 100644
index 000000000..b009a97af
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ProductTableMap.php
@@ -0,0 +1,586 @@
+ array('Id', 'TaxRuleId', 'Ref', 'Price', 'Price2', 'Ecotax', 'Newness', 'Promo', 'Quantity', 'Visible', 'Weight', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'taxRuleId', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'quantity', 'visible', 'weight', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ self::TYPE_COLNAME => array(ProductTableMap::ID, ProductTableMap::TAX_RULE_ID, ProductTableMap::REF, ProductTableMap::PRICE, ProductTableMap::PRICE2, ProductTableMap::ECOTAX, ProductTableMap::NEWNESS, ProductTableMap::PROMO, ProductTableMap::QUANTITY, ProductTableMap::VISIBLE, ProductTableMap::WEIGHT, ProductTableMap::POSITION, ProductTableMap::CREATED_AT, ProductTableMap::UPDATED_AT, ProductTableMap::VERSION, ProductTableMap::VERSION_CREATED_AT, ProductTableMap::VERSION_CREATED_BY, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'TAX_RULE_ID', 'REF', 'PRICE', 'PRICE2', 'ECOTAX', 'NEWNESS', 'PROMO', 'QUANTITY', 'VISIBLE', 'WEIGHT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ self::TYPE_FIELDNAME => array('id', 'tax_rule_id', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'quantity', 'visible', 'weight', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'TaxRuleId' => 1, 'Ref' => 2, 'Price' => 3, 'Price2' => 4, 'Ecotax' => 5, 'Newness' => 6, 'Promo' => 7, 'Quantity' => 8, 'Visible' => 9, 'Weight' => 10, 'Position' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, 'VersionCreatedAt' => 15, 'VersionCreatedBy' => 16, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'taxRuleId' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'quantity' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, 'versionCreatedAt' => 15, 'versionCreatedBy' => 16, ),
+ self::TYPE_COLNAME => array(ProductTableMap::ID => 0, ProductTableMap::TAX_RULE_ID => 1, ProductTableMap::REF => 2, ProductTableMap::PRICE => 3, ProductTableMap::PRICE2 => 4, ProductTableMap::ECOTAX => 5, ProductTableMap::NEWNESS => 6, ProductTableMap::PROMO => 7, ProductTableMap::QUANTITY => 8, ProductTableMap::VISIBLE => 9, ProductTableMap::WEIGHT => 10, ProductTableMap::POSITION => 11, ProductTableMap::CREATED_AT => 12, ProductTableMap::UPDATED_AT => 13, ProductTableMap::VERSION => 14, ProductTableMap::VERSION_CREATED_AT => 15, ProductTableMap::VERSION_CREATED_BY => 16, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'TAX_RULE_ID' => 1, 'REF' => 2, 'PRICE' => 3, 'PRICE2' => 4, 'ECOTAX' => 5, 'NEWNESS' => 6, 'PROMO' => 7, 'QUANTITY' => 8, 'VISIBLE' => 9, 'WEIGHT' => 10, 'POSITION' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, 'VERSION_CREATED_AT' => 15, 'VERSION_CREATED_BY' => 16, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'tax_rule_id' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'quantity' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, 'version_created_at' => 15, 'version_created_by' => 16, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('product');
+ $this->setPhpName('Product');
+ $this->setClassName('\\Thelia\\Model\\Product');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', 'tax_rule', 'ID', false, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null);
+ $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null);
+ $this->addColumn('PRICE2', 'Price2', 'FLOAT', false, null, null);
+ $this->addColumn('ECOTAX', 'Ecotax', 'FLOAT', false, null, null);
+ $this->addColumn('NEWNESS', 'Newness', 'TINYINT', false, null, 0);
+ $this->addColumn('PROMO', 'Promo', 'TINYINT', false, null, 0);
+ $this->addColumn('QUANTITY', 'Quantity', 'INTEGER', false, null, 0);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 0);
+ $this->addColumn('WEIGHT', 'Weight', 'FLOAT', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION', 'Version', 'INTEGER', false, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('TaxRule', '\\Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ $this->addRelation('ProductCategory', '\\Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductCategories');
+ $this->addRelation('FeatureProd', '\\Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'FeatureProds');
+ $this->addRelation('Stock', '\\Thelia\\Model\\Stock', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Stocks');
+ $this->addRelation('ContentAssoc', '\\Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs');
+ $this->addRelation('Image', '\\Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Images');
+ $this->addRelation('Document', '\\Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Documents');
+ $this->addRelation('AccessoryRelatedByProductId', '\\Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'AccessoriesRelatedByProductId');
+ $this->addRelation('AccessoryRelatedByAccessory', '\\Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'accessory', ), 'CASCADE', 'RESTRICT', 'AccessoriesRelatedByAccessory');
+ $this->addRelation('Rewriting', '\\Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Rewritings');
+ $this->addRelation('ProductI18n', '\\Thelia\\Model\\ProductI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ProductI18ns');
+ $this->addRelation('ProductVersion', '\\Thelia\\Model\\ProductVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ProductVersions');
+ $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Categories');
+ $this->addRelation('ProductRelatedByAccessory', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'ProductsRelatedByAccessory');
+ $this->addRelation('ProductRelatedByProductId', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'ProductsRelatedByProductId');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to product * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ProductCategoryTableMap::clearInstancePool();
+ FeatureProdTableMap::clearInstancePool();
+ StockTableMap::clearInstancePool();
+ ContentAssocTableMap::clearInstancePool();
+ ImageTableMap::clearInstancePool();
+ DocumentTableMap::clearInstancePool();
+ AccessoryTableMap::clearInstancePool();
+ RewritingTableMap::clearInstancePool();
+ ProductI18nTableMap::clearInstancePool();
+ ProductVersionTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ProductTableMap::CLASS_DEFAULT : ProductTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Product object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ProductTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ProductTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ProductTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ProductTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ProductTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ProductTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ProductTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ProductTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ProductTableMap::ID);
+ $criteria->addSelectColumn(ProductTableMap::TAX_RULE_ID);
+ $criteria->addSelectColumn(ProductTableMap::REF);
+ $criteria->addSelectColumn(ProductTableMap::PRICE);
+ $criteria->addSelectColumn(ProductTableMap::PRICE2);
+ $criteria->addSelectColumn(ProductTableMap::ECOTAX);
+ $criteria->addSelectColumn(ProductTableMap::NEWNESS);
+ $criteria->addSelectColumn(ProductTableMap::PROMO);
+ $criteria->addSelectColumn(ProductTableMap::QUANTITY);
+ $criteria->addSelectColumn(ProductTableMap::VISIBLE);
+ $criteria->addSelectColumn(ProductTableMap::WEIGHT);
+ $criteria->addSelectColumn(ProductTableMap::POSITION);
+ $criteria->addSelectColumn(ProductTableMap::CREATED_AT);
+ $criteria->addSelectColumn(ProductTableMap::UPDATED_AT);
+ $criteria->addSelectColumn(ProductTableMap::VERSION);
+ $criteria->addSelectColumn(ProductTableMap::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(ProductTableMap::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.TAX_RULE_ID');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.PRICE');
+ $criteria->addSelectColumn($alias . '.PRICE2');
+ $criteria->addSelectColumn($alias . '.ECOTAX');
+ $criteria->addSelectColumn($alias . '.NEWNESS');
+ $criteria->addSelectColumn($alias . '.PROMO');
+ $criteria->addSelectColumn($alias . '.QUANTITY');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.WEIGHT');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ProductTableMap::DATABASE_NAME)->getTable(ProductTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProductTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ProductTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ProductTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Product or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Product object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Product) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ProductTableMap::DATABASE_NAME);
+ $criteria->add(ProductTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = ProductQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ProductTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ProductTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the product table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ProductQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Product or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Product object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Product object
+ }
+
+ if ($criteria->containsKey(ProductTableMap::ID) && $criteria->keyContainsValue(ProductTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProductTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = ProductQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ProductTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ProductTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ProductVersionTableMap.php b/core/lib/Thelia/Model/Map/ProductVersionTableMap.php
new file mode 100644
index 000000000..fb285a6db
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ProductVersionTableMap.php
@@ -0,0 +1,585 @@
+ array('Id', 'TaxRuleId', 'Ref', 'Price', 'Price2', 'Ecotax', 'Newness', 'Promo', 'Quantity', 'Visible', 'Weight', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'taxRuleId', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'quantity', 'visible', 'weight', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
+ self::TYPE_COLNAME => array(ProductVersionTableMap::ID, ProductVersionTableMap::TAX_RULE_ID, ProductVersionTableMap::REF, ProductVersionTableMap::PRICE, ProductVersionTableMap::PRICE2, ProductVersionTableMap::ECOTAX, ProductVersionTableMap::NEWNESS, ProductVersionTableMap::PROMO, ProductVersionTableMap::QUANTITY, ProductVersionTableMap::VISIBLE, ProductVersionTableMap::WEIGHT, ProductVersionTableMap::POSITION, ProductVersionTableMap::CREATED_AT, ProductVersionTableMap::UPDATED_AT, ProductVersionTableMap::VERSION, ProductVersionTableMap::VERSION_CREATED_AT, ProductVersionTableMap::VERSION_CREATED_BY, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'TAX_RULE_ID', 'REF', 'PRICE', 'PRICE2', 'ECOTAX', 'NEWNESS', 'PROMO', 'QUANTITY', 'VISIBLE', 'WEIGHT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
+ self::TYPE_FIELDNAME => array('id', 'tax_rule_id', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'quantity', 'visible', 'weight', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'TaxRuleId' => 1, 'Ref' => 2, 'Price' => 3, 'Price2' => 4, 'Ecotax' => 5, 'Newness' => 6, 'Promo' => 7, 'Quantity' => 8, 'Visible' => 9, 'Weight' => 10, 'Position' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, 'Version' => 14, 'VersionCreatedAt' => 15, 'VersionCreatedBy' => 16, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'taxRuleId' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'quantity' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'createdAt' => 12, 'updatedAt' => 13, 'version' => 14, 'versionCreatedAt' => 15, 'versionCreatedBy' => 16, ),
+ self::TYPE_COLNAME => array(ProductVersionTableMap::ID => 0, ProductVersionTableMap::TAX_RULE_ID => 1, ProductVersionTableMap::REF => 2, ProductVersionTableMap::PRICE => 3, ProductVersionTableMap::PRICE2 => 4, ProductVersionTableMap::ECOTAX => 5, ProductVersionTableMap::NEWNESS => 6, ProductVersionTableMap::PROMO => 7, ProductVersionTableMap::QUANTITY => 8, ProductVersionTableMap::VISIBLE => 9, ProductVersionTableMap::WEIGHT => 10, ProductVersionTableMap::POSITION => 11, ProductVersionTableMap::CREATED_AT => 12, ProductVersionTableMap::UPDATED_AT => 13, ProductVersionTableMap::VERSION => 14, ProductVersionTableMap::VERSION_CREATED_AT => 15, ProductVersionTableMap::VERSION_CREATED_BY => 16, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'TAX_RULE_ID' => 1, 'REF' => 2, 'PRICE' => 3, 'PRICE2' => 4, 'ECOTAX' => 5, 'NEWNESS' => 6, 'PROMO' => 7, 'QUANTITY' => 8, 'VISIBLE' => 9, 'WEIGHT' => 10, 'POSITION' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, 'VERSION' => 14, 'VERSION_CREATED_AT' => 15, 'VERSION_CREATED_BY' => 16, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'tax_rule_id' => 1, 'ref' => 2, 'price' => 3, 'price2' => 4, 'ecotax' => 5, 'newness' => 6, 'promo' => 7, 'quantity' => 8, 'visible' => 9, 'weight' => 10, 'position' => 11, 'created_at' => 12, 'updated_at' => 13, 'version' => 14, 'version_created_at' => 15, 'version_created_by' => 16, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('product_version');
+ $this->setPhpName('ProductVersion');
+ $this->setClassName('\\Thelia\\Model\\ProductVersion');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product', 'ID', true, null, null);
+ $this->addColumn('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', false, null, null);
+ $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null);
+ $this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null);
+ $this->addColumn('PRICE2', 'Price2', 'FLOAT', false, null, null);
+ $this->addColumn('ECOTAX', 'Ecotax', 'FLOAT', false, null, null);
+ $this->addColumn('NEWNESS', 'Newness', 'TINYINT', false, null, 0);
+ $this->addColumn('PROMO', 'Promo', 'TINYINT', false, null, 0);
+ $this->addColumn('QUANTITY', 'Quantity', 'INTEGER', false, null, 0);
+ $this->addColumn('VISIBLE', 'Visible', 'TINYINT', true, null, 0);
+ $this->addColumn('WEIGHT', 'Weight', 'FLOAT', false, null, null);
+ $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ $this->addPrimaryKey('VERSION', 'Version', 'INTEGER', true, null, 0);
+ $this->addColumn('VERSION_CREATED_AT', 'VersionCreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('VERSION_CREATED_BY', 'VersionCreatedBy', 'VARCHAR', false, 100, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\ProductVersion $obj A \Thelia\Model\ProductVersion object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getVersion()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\ProductVersion object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\ProductVersion) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getVersion()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ProductVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 14 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 14 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ProductVersionTableMap::CLASS_DEFAULT : ProductVersionTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ProductVersion object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ProductVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ProductVersionTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ProductVersionTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ProductVersionTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ProductVersionTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ProductVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ProductVersionTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ProductVersionTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ProductVersionTableMap::ID);
+ $criteria->addSelectColumn(ProductVersionTableMap::TAX_RULE_ID);
+ $criteria->addSelectColumn(ProductVersionTableMap::REF);
+ $criteria->addSelectColumn(ProductVersionTableMap::PRICE);
+ $criteria->addSelectColumn(ProductVersionTableMap::PRICE2);
+ $criteria->addSelectColumn(ProductVersionTableMap::ECOTAX);
+ $criteria->addSelectColumn(ProductVersionTableMap::NEWNESS);
+ $criteria->addSelectColumn(ProductVersionTableMap::PROMO);
+ $criteria->addSelectColumn(ProductVersionTableMap::QUANTITY);
+ $criteria->addSelectColumn(ProductVersionTableMap::VISIBLE);
+ $criteria->addSelectColumn(ProductVersionTableMap::WEIGHT);
+ $criteria->addSelectColumn(ProductVersionTableMap::POSITION);
+ $criteria->addSelectColumn(ProductVersionTableMap::CREATED_AT);
+ $criteria->addSelectColumn(ProductVersionTableMap::UPDATED_AT);
+ $criteria->addSelectColumn(ProductVersionTableMap::VERSION);
+ $criteria->addSelectColumn(ProductVersionTableMap::VERSION_CREATED_AT);
+ $criteria->addSelectColumn(ProductVersionTableMap::VERSION_CREATED_BY);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.TAX_RULE_ID');
+ $criteria->addSelectColumn($alias . '.REF');
+ $criteria->addSelectColumn($alias . '.PRICE');
+ $criteria->addSelectColumn($alias . '.PRICE2');
+ $criteria->addSelectColumn($alias . '.ECOTAX');
+ $criteria->addSelectColumn($alias . '.NEWNESS');
+ $criteria->addSelectColumn($alias . '.PROMO');
+ $criteria->addSelectColumn($alias . '.QUANTITY');
+ $criteria->addSelectColumn($alias . '.VISIBLE');
+ $criteria->addSelectColumn($alias . '.WEIGHT');
+ $criteria->addSelectColumn($alias . '.POSITION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_AT');
+ $criteria->addSelectColumn($alias . '.VERSION_CREATED_BY');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ProductVersionTableMap::DATABASE_NAME)->getTable(ProductVersionTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProductVersionTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ProductVersionTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ProductVersionTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ProductVersion or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ProductVersion object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductVersionTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\ProductVersion) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ProductVersionTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(ProductVersionTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(ProductVersionTableMap::VERSION, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = ProductVersionQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ProductVersionTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ProductVersionTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the product_version table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ProductVersionQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ProductVersion or Criteria object.
+ *
+ * @param mixed $criteria Criteria or ProductVersion object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ProductVersionTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from ProductVersion object
+ }
+
+
+ // Set the correct dbName
+ $query = ProductVersionQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ProductVersionTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ProductVersionTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php b/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php
new file mode 100644
index 000000000..8a8ce501a
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php
@@ -0,0 +1,497 @@
+ array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_COLNAME => array(ResourceI18nTableMap::ID, ResourceI18nTableMap::LOCALE, ResourceI18nTableMap::TITLE, ResourceI18nTableMap::DESCRIPTION, ResourceI18nTableMap::CHAPO, ResourceI18nTableMap::POSTSCRIPTUM, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_COLNAME => array(ResourceI18nTableMap::ID => 0, ResourceI18nTableMap::LOCALE => 1, ResourceI18nTableMap::TITLE => 2, ResourceI18nTableMap::DESCRIPTION => 3, ResourceI18nTableMap::CHAPO => 4, ResourceI18nTableMap::POSTSCRIPTUM => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('resource_i18n');
+ $this->setPhpName('ResourceI18n');
+ $this->setClassName('\\Thelia\\Model\\ResourceI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'resource', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
+ $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Resource', '\\Thelia\\Model\\Resource', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\ResourceI18n $obj A \Thelia\Model\ResourceI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\ResourceI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\ResourceI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ResourceI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ResourceI18nTableMap::CLASS_DEFAULT : ResourceI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (ResourceI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ResourceI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ResourceI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ResourceI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ResourceI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ResourceI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ResourceI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ResourceI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ResourceI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ResourceI18nTableMap::ID);
+ $criteria->addSelectColumn(ResourceI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(ResourceI18nTableMap::TITLE);
+ $criteria->addSelectColumn(ResourceI18nTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(ResourceI18nTableMap::CHAPO);
+ $criteria->addSelectColumn(ResourceI18nTableMap::POSTSCRIPTUM);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CHAPO');
+ $criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ResourceI18nTableMap::DATABASE_NAME)->getTable(ResourceI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ResourceI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ResourceI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ResourceI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a ResourceI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or ResourceI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ResourceI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\ResourceI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ResourceI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(ResourceI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(ResourceI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = ResourceI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ResourceI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ResourceI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the resource_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ResourceI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a ResourceI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or ResourceI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ResourceI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from ResourceI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = ResourceI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ResourceI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ResourceI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/ResourceTableMap.php b/core/lib/Thelia/Model/Map/ResourceTableMap.php
new file mode 100644
index 000000000..e56960892
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/ResourceTableMap.php
@@ -0,0 +1,461 @@
+ array('Id', 'Code', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'code', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(ResourceTableMap::ID, ResourceTableMap::CODE, ResourceTableMap::CREATED_AT, ResourceTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'code', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ self::TYPE_COLNAME => array(ResourceTableMap::ID => 0, ResourceTableMap::CODE => 1, ResourceTableMap::CREATED_AT => 2, ResourceTableMap::UPDATED_AT => 3, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('resource');
+ $this->setPhpName('Resource');
+ $this->setClassName('\\Thelia\\Model\\Resource');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', true, 30, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('GroupResource', '\\Thelia\\Model\\GroupResource', RelationMap::ONE_TO_MANY, array('id' => 'resource_id', ), 'CASCADE', 'RESTRICT', 'GroupResources');
+ $this->addRelation('ResourceI18n', '\\Thelia\\Model\\ResourceI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ResourceI18ns');
+ $this->addRelation('Group', '\\Thelia\\Model\\Group', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Groups');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to resource * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ GroupResourceTableMap::clearInstancePool();
+ ResourceI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? ResourceTableMap::CLASS_DEFAULT : ResourceTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Resource object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = ResourceTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = ResourceTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + ResourceTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = ResourceTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ ResourceTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = ResourceTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = ResourceTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ ResourceTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(ResourceTableMap::ID);
+ $criteria->addSelectColumn(ResourceTableMap::CODE);
+ $criteria->addSelectColumn(ResourceTableMap::CREATED_AT);
+ $criteria->addSelectColumn(ResourceTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(ResourceTableMap::DATABASE_NAME)->getTable(ResourceTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(ResourceTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(ResourceTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new ResourceTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Resource or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Resource object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ResourceTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Resource) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(ResourceTableMap::DATABASE_NAME);
+ $criteria->add(ResourceTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = ResourceQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { ResourceTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { ResourceTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the resource table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return ResourceQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Resource or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Resource object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(ResourceTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Resource object
+ }
+
+ if ($criteria->containsKey(ResourceTableMap::ID) && $criteria->keyContainsValue(ResourceTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.ResourceTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = ResourceQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // ResourceTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+ResourceTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/RewritingTableMap.php b/core/lib/Thelia/Model/Map/RewritingTableMap.php
new file mode 100644
index 000000000..afce3e3c7
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/RewritingTableMap.php
@@ -0,0 +1,470 @@
+ array('Id', 'Url', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'url', 'productId', 'categoryId', 'folderId', 'contentId', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(RewritingTableMap::ID, RewritingTableMap::URL, RewritingTableMap::PRODUCT_ID, RewritingTableMap::CATEGORY_ID, RewritingTableMap::FOLDER_ID, RewritingTableMap::CONTENT_ID, RewritingTableMap::CREATED_AT, RewritingTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'URL', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'url', 'product_id', 'category_id', 'folder_id', 'content_id', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Url' => 1, 'ProductId' => 2, 'CategoryId' => 3, 'FolderId' => 4, 'ContentId' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'url' => 1, 'productId' => 2, 'categoryId' => 3, 'folderId' => 4, 'contentId' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
+ self::TYPE_COLNAME => array(RewritingTableMap::ID => 0, RewritingTableMap::URL => 1, RewritingTableMap::PRODUCT_ID => 2, RewritingTableMap::CATEGORY_ID => 3, RewritingTableMap::FOLDER_ID => 4, RewritingTableMap::CONTENT_ID => 5, RewritingTableMap::CREATED_AT => 6, RewritingTableMap::UPDATED_AT => 7, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'URL' => 1, 'PRODUCT_ID' => 2, 'CATEGORY_ID' => 3, 'FOLDER_ID' => 4, 'CONTENT_ID' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'url' => 1, 'product_id' => 2, 'category_id' => 3, 'folder_id' => 4, 'content_id' => 5, 'created_at' => 6, 'updated_at' => 7, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('rewriting');
+ $this->setPhpName('Rewriting');
+ $this->setClassName('\\Thelia\\Model\\Rewriting');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('URL', 'Url', 'VARCHAR', true, 255, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', false, null, null);
+ $this->addForeignKey('CATEGORY_ID', 'CategoryId', 'INTEGER', 'category', 'ID', false, null, null);
+ $this->addForeignKey('FOLDER_ID', 'FolderId', 'INTEGER', 'folder', 'ID', false, null, null);
+ $this->addForeignKey('CONTENT_ID', 'ContentId', 'INTEGER', 'content', 'ID', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Category', '\\Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Folder', '\\Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Content', '\\Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? RewritingTableMap::CLASS_DEFAULT : RewritingTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Rewriting object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = RewritingTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = RewritingTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + RewritingTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = RewritingTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ RewritingTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = RewritingTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = RewritingTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ RewritingTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(RewritingTableMap::ID);
+ $criteria->addSelectColumn(RewritingTableMap::URL);
+ $criteria->addSelectColumn(RewritingTableMap::PRODUCT_ID);
+ $criteria->addSelectColumn(RewritingTableMap::CATEGORY_ID);
+ $criteria->addSelectColumn(RewritingTableMap::FOLDER_ID);
+ $criteria->addSelectColumn(RewritingTableMap::CONTENT_ID);
+ $criteria->addSelectColumn(RewritingTableMap::CREATED_AT);
+ $criteria->addSelectColumn(RewritingTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.URL');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.CATEGORY_ID');
+ $criteria->addSelectColumn($alias . '.FOLDER_ID');
+ $criteria->addSelectColumn($alias . '.CONTENT_ID');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(RewritingTableMap::DATABASE_NAME)->getTable(RewritingTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(RewritingTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(RewritingTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new RewritingTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Rewriting or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Rewriting object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Rewriting) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(RewritingTableMap::DATABASE_NAME);
+ $criteria->add(RewritingTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = RewritingQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { RewritingTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { RewritingTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the rewriting table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return RewritingQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Rewriting or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Rewriting object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Rewriting object
+ }
+
+
+ // Set the correct dbName
+ $query = RewritingQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // RewritingTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+RewritingTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/StockTableMap.php b/core/lib/Thelia/Model/Map/StockTableMap.php
new file mode 100644
index 000000000..470f7a0a8
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/StockTableMap.php
@@ -0,0 +1,464 @@
+ array('Id', 'CombinationId', 'ProductId', 'Increase', 'Value', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'combinationId', 'productId', 'increase', 'value', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(StockTableMap::ID, StockTableMap::COMBINATION_ID, StockTableMap::PRODUCT_ID, StockTableMap::INCREASE, StockTableMap::VALUE, StockTableMap::CREATED_AT, StockTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'COMBINATION_ID', 'PRODUCT_ID', 'INCREASE', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'combination_id', 'product_id', 'increase', 'value', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'CombinationId' => 1, 'ProductId' => 2, 'Increase' => 3, 'Value' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'combinationId' => 1, 'productId' => 2, 'increase' => 3, 'value' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ self::TYPE_COLNAME => array(StockTableMap::ID => 0, StockTableMap::COMBINATION_ID => 1, StockTableMap::PRODUCT_ID => 2, StockTableMap::INCREASE => 3, StockTableMap::VALUE => 4, StockTableMap::CREATED_AT => 5, StockTableMap::UPDATED_AT => 6, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'COMBINATION_ID' => 1, 'PRODUCT_ID' => 2, 'INCREASE' => 3, 'VALUE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'combination_id' => 1, 'product_id' => 2, 'increase' => 3, 'value' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('stock');
+ $this->setPhpName('Stock');
+ $this->setClassName('\\Thelia\\Model\\Stock');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('COMBINATION_ID', 'CombinationId', 'INTEGER', 'combination', 'ID', false, null, null);
+ $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
+ $this->addColumn('INCREASE', 'Increase', 'FLOAT', false, null, null);
+ $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Combination', '\\Thelia\\Model\\Combination', RelationMap::MANY_TO_ONE, array('combination_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? StockTableMap::CLASS_DEFAULT : StockTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Stock object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = StockTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = StockTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + StockTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = StockTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ StockTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = StockTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = StockTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ StockTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(StockTableMap::ID);
+ $criteria->addSelectColumn(StockTableMap::COMBINATION_ID);
+ $criteria->addSelectColumn(StockTableMap::PRODUCT_ID);
+ $criteria->addSelectColumn(StockTableMap::INCREASE);
+ $criteria->addSelectColumn(StockTableMap::VALUE);
+ $criteria->addSelectColumn(StockTableMap::CREATED_AT);
+ $criteria->addSelectColumn(StockTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.COMBINATION_ID');
+ $criteria->addSelectColumn($alias . '.PRODUCT_ID');
+ $criteria->addSelectColumn($alias . '.INCREASE');
+ $criteria->addSelectColumn($alias . '.VALUE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(StockTableMap::DATABASE_NAME)->getTable(StockTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(StockTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(StockTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new StockTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Stock or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Stock object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Stock) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(StockTableMap::DATABASE_NAME);
+ $criteria->add(StockTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = StockQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { StockTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { StockTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the stock table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return StockQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Stock or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Stock object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Stock object
+ }
+
+ if ($criteria->containsKey(StockTableMap::ID) && $criteria->keyContainsValue(StockTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.StockTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = StockQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // StockTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+StockTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php
new file mode 100644
index 000000000..2c4c92f4f
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php
@@ -0,0 +1,481 @@
+ array('Id', 'Locale', 'Title', 'Description', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', ),
+ self::TYPE_COLNAME => array(TaxI18nTableMap::ID, TaxI18nTableMap::LOCALE, TaxI18nTableMap::TITLE, TaxI18nTableMap::DESCRIPTION, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, ),
+ self::TYPE_COLNAME => array(TaxI18nTableMap::ID => 0, TaxI18nTableMap::LOCALE => 1, TaxI18nTableMap::TITLE => 2, TaxI18nTableMap::DESCRIPTION => 3, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('tax_i18n');
+ $this->setPhpName('TaxI18n');
+ $this->setClassName('\\Thelia\\Model\\TaxI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Tax', '\\Thelia\\Model\\Tax', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\TaxI18n $obj A \Thelia\Model\TaxI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\TaxI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\TaxI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\TaxI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? TaxI18nTableMap::CLASS_DEFAULT : TaxI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (TaxI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = TaxI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = TaxI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + TaxI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = TaxI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ TaxI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = TaxI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = TaxI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ TaxI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(TaxI18nTableMap::ID);
+ $criteria->addSelectColumn(TaxI18nTableMap::LOCALE);
+ $criteria->addSelectColumn(TaxI18nTableMap::TITLE);
+ $criteria->addSelectColumn(TaxI18nTableMap::DESCRIPTION);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(TaxI18nTableMap::DATABASE_NAME)->getTable(TaxI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(TaxI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(TaxI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new TaxI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a TaxI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or TaxI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\TaxI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(TaxI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(TaxI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(TaxI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = TaxI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { TaxI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { TaxI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the tax_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return TaxI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a TaxI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or TaxI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from TaxI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = TaxI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // TaxI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+TaxI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/TaxRuleCountryTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleCountryTableMap.php
new file mode 100644
index 000000000..42b4e6f59
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/TaxRuleCountryTableMap.php
@@ -0,0 +1,461 @@
+ array('Id', 'TaxRuleId', 'CountryId', 'TaxId', 'None', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'taxRuleId', 'countryId', 'taxId', 'none', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(TaxRuleCountryTableMap::ID, TaxRuleCountryTableMap::TAX_RULE_ID, TaxRuleCountryTableMap::COUNTRY_ID, TaxRuleCountryTableMap::TAX_ID, TaxRuleCountryTableMap::NONE, TaxRuleCountryTableMap::CREATED_AT, TaxRuleCountryTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'TAX_RULE_ID', 'COUNTRY_ID', 'TAX_ID', 'NONE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'tax_rule_id', 'country_id', 'tax_id', 'none', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'TaxRuleId' => 1, 'CountryId' => 2, 'TaxId' => 3, 'None' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'taxRuleId' => 1, 'countryId' => 2, 'taxId' => 3, 'none' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
+ self::TYPE_COLNAME => array(TaxRuleCountryTableMap::ID => 0, TaxRuleCountryTableMap::TAX_RULE_ID => 1, TaxRuleCountryTableMap::COUNTRY_ID => 2, TaxRuleCountryTableMap::TAX_ID => 3, TaxRuleCountryTableMap::NONE => 4, TaxRuleCountryTableMap::CREATED_AT => 5, TaxRuleCountryTableMap::UPDATED_AT => 6, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'TAX_RULE_ID' => 1, 'COUNTRY_ID' => 2, 'TAX_ID' => 3, 'NONE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'tax_rule_id' => 1, 'country_id' => 2, 'tax_id' => 3, 'none' => 4, 'created_at' => 5, 'updated_at' => 6, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('tax_rule_country');
+ $this->setPhpName('TaxRuleCountry');
+ $this->setClassName('\\Thelia\\Model\\TaxRuleCountry');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addForeignKey('TAX_RULE_ID', 'TaxRuleId', 'INTEGER', 'tax_rule', 'ID', false, null, null);
+ $this->addForeignKey('COUNTRY_ID', 'CountryId', 'INTEGER', 'country', 'ID', false, null, null);
+ $this->addForeignKey('TAX_ID', 'TaxId', 'INTEGER', 'tax', 'ID', false, null, null);
+ $this->addColumn('NONE', 'None', 'TINYINT', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Tax', '\\Thelia\\Model\\Tax', RelationMap::MANY_TO_ONE, array('tax_id' => 'id', ), 'SET NULL', 'RESTRICT');
+ $this->addRelation('TaxRule', '\\Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ $this->addRelation('Country', '\\Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'CASCADE', 'RESTRICT');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ );
+ } // getBehaviors()
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? TaxRuleCountryTableMap::CLASS_DEFAULT : TaxRuleCountryTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (TaxRuleCountry object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = TaxRuleCountryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = TaxRuleCountryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + TaxRuleCountryTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = TaxRuleCountryTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ TaxRuleCountryTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = TaxRuleCountryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = TaxRuleCountryTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ TaxRuleCountryTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(TaxRuleCountryTableMap::ID);
+ $criteria->addSelectColumn(TaxRuleCountryTableMap::TAX_RULE_ID);
+ $criteria->addSelectColumn(TaxRuleCountryTableMap::COUNTRY_ID);
+ $criteria->addSelectColumn(TaxRuleCountryTableMap::TAX_ID);
+ $criteria->addSelectColumn(TaxRuleCountryTableMap::NONE);
+ $criteria->addSelectColumn(TaxRuleCountryTableMap::CREATED_AT);
+ $criteria->addSelectColumn(TaxRuleCountryTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.TAX_RULE_ID');
+ $criteria->addSelectColumn($alias . '.COUNTRY_ID');
+ $criteria->addSelectColumn($alias . '.TAX_ID');
+ $criteria->addSelectColumn($alias . '.NONE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(TaxRuleCountryTableMap::DATABASE_NAME)->getTable(TaxRuleCountryTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(TaxRuleCountryTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(TaxRuleCountryTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new TaxRuleCountryTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a TaxRuleCountry or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or TaxRuleCountry object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleCountryTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\TaxRuleCountry) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(TaxRuleCountryTableMap::DATABASE_NAME);
+ $criteria->add(TaxRuleCountryTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = TaxRuleCountryQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { TaxRuleCountryTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { TaxRuleCountryTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the tax_rule_country table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return TaxRuleCountryQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a TaxRuleCountry or Criteria object.
+ *
+ * @param mixed $criteria Criteria or TaxRuleCountry object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleCountryTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from TaxRuleCountry object
+ }
+
+
+ // Set the correct dbName
+ $query = TaxRuleCountryQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // TaxRuleCountryTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+TaxRuleCountryTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php
new file mode 100644
index 000000000..689f30728
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php
@@ -0,0 +1,465 @@
+ array('Id', 'Locale', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'locale', ),
+ self::TYPE_COLNAME => array(TaxRuleI18nTableMap::ID, TaxRuleI18nTableMap::LOCALE, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', ),
+ self::TYPE_FIELDNAME => array('id', 'locale', ),
+ self::TYPE_NUM => array(0, 1, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, ),
+ self::TYPE_COLNAME => array(TaxRuleI18nTableMap::ID => 0, TaxRuleI18nTableMap::LOCALE => 1, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, ),
+ self::TYPE_NUM => array(0, 1, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('tax_rule_i18n');
+ $this->setPhpName('TaxRuleI18n');
+ $this->setClassName('\\Thelia\\Model\\TaxRuleI18n');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(false);
+ // columns
+ $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule', 'ID', true, null, null);
+ $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN');
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('TaxRule', '\\Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null);
+ } // buildRelations()
+
+ /**
+ * Adds an object to the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases you may need to explicitly add objects
+ * to the cache in order to ensure that the same objects are always returned by find*()
+ * and findPk*() calls.
+ *
+ * @param \Thelia\Model\TaxRuleI18n $obj A \Thelia\Model\TaxRuleI18n object.
+ * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
+ */
+ public static function addInstanceToPool($obj, $key = null)
+ {
+ if (Propel::isInstancePoolingEnabled()) {
+ if (null === $key) {
+ $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale()));
+ } // if key === null
+ self::$instances[$key] = $obj;
+ }
+ }
+
+ /**
+ * Removes an object from the instance pool.
+ *
+ * Propel keeps cached copies of objects in an instance pool when they are retrieved
+ * from the database. In some cases -- especially when you override doDelete
+ * methods in your stub classes -- you may need to explicitly remove objects
+ * from the cache in order to prevent returning objects that no longer exist.
+ *
+ * @param mixed $value A \Thelia\Model\TaxRuleI18n object or a primary key value.
+ */
+ public static function removeInstanceFromPool($value)
+ {
+ if (Propel::isInstancePoolingEnabled() && null !== $value) {
+ if (is_object($value) && $value instanceof \Thelia\Model\TaxRuleI18n) {
+ $key = serialize(array((string) $value->getId(), (string) $value->getLocale()));
+
+ } elseif (is_array($value) && count($value) === 2) {
+ // assume we've been passed a primary key";
+ $key = serialize(array((string) $value[0], (string) $value[1]));
+ } elseif ($value instanceof Criteria) {
+ self::$instances = [];
+
+ return;
+ } else {
+ $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\TaxRuleI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true)));
+ throw $e;
+ }
+
+ unset(self::$instances[$key]);
+ }
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]));
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return $pks;
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? TaxRuleI18nTableMap::CLASS_DEFAULT : TaxRuleI18nTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (TaxRuleI18n object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = TaxRuleI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = TaxRuleI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + TaxRuleI18nTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = TaxRuleI18nTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ TaxRuleI18nTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = TaxRuleI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = TaxRuleI18nTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ TaxRuleI18nTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(TaxRuleI18nTableMap::ID);
+ $criteria->addSelectColumn(TaxRuleI18nTableMap::LOCALE);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.LOCALE');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(TaxRuleI18nTableMap::DATABASE_NAME)->getTable(TaxRuleI18nTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(TaxRuleI18nTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(TaxRuleI18nTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new TaxRuleI18nTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a TaxRuleI18n or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or TaxRuleI18n object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\TaxRuleI18n) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(TaxRuleI18nTableMap::DATABASE_NAME);
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey values
+ if (count($values) == count($values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ $values = array($values);
+ }
+ foreach ($values as $value) {
+ $criterion = $criteria->getNewCriterion(TaxRuleI18nTableMap::ID, $value[0]);
+ $criterion->addAnd($criteria->getNewCriterion(TaxRuleI18nTableMap::LOCALE, $value[1]));
+ $criteria->addOr($criterion);
+ }
+ }
+
+ $query = TaxRuleI18nQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { TaxRuleI18nTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { TaxRuleI18nTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the tax_rule_i18n table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return TaxRuleI18nQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a TaxRuleI18n or Criteria object.
+ *
+ * @param mixed $criteria Criteria or TaxRuleI18n object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleI18nTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from TaxRuleI18n object
+ }
+
+
+ // Set the correct dbName
+ $query = TaxRuleI18nQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // TaxRuleI18nTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+TaxRuleI18nTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php
new file mode 100644
index 000000000..9b862de99
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php
@@ -0,0 +1,478 @@
+ array('Id', 'Code', 'Title', 'Description', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'code', 'title', 'description', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(TaxRuleTableMap::ID, TaxRuleTableMap::CODE, TaxRuleTableMap::TITLE, TaxRuleTableMap::DESCRIPTION, TaxRuleTableMap::CREATED_AT, TaxRuleTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TITLE', 'DESCRIPTION', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'code', 'title', 'description', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Title' => 2, 'Description' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'title' => 2, 'description' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
+ self::TYPE_COLNAME => array(TaxRuleTableMap::ID => 0, TaxRuleTableMap::CODE => 1, TaxRuleTableMap::TITLE => 2, TaxRuleTableMap::DESCRIPTION => 3, TaxRuleTableMap::CREATED_AT => 4, TaxRuleTableMap::UPDATED_AT => 5, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'title' => 2, 'description' => 3, 'created_at' => 4, 'updated_at' => 5, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('tax_rule');
+ $this->setPhpName('TaxRule');
+ $this->setClassName('\\Thelia\\Model\\TaxRule');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('CODE', 'Code', 'VARCHAR', false, 45, null);
+ $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
+ $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::ONE_TO_MANY, array('id' => 'tax_rule_id', ), 'SET NULL', 'RESTRICT', 'Products');
+ $this->addRelation('TaxRuleCountry', '\\Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'tax_rule_id', ), 'CASCADE', 'RESTRICT', 'TaxRuleCountries');
+ $this->addRelation('TaxRuleI18n', '\\Thelia\\Model\\TaxRuleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'TaxRuleI18ns');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => '', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to tax_rule * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ProductTableMap::clearInstancePool();
+ TaxRuleCountryTableMap::clearInstancePool();
+ TaxRuleI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? TaxRuleTableMap::CLASS_DEFAULT : TaxRuleTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (TaxRule object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = TaxRuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = TaxRuleTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + TaxRuleTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = TaxRuleTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ TaxRuleTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = TaxRuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = TaxRuleTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ TaxRuleTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(TaxRuleTableMap::ID);
+ $criteria->addSelectColumn(TaxRuleTableMap::CODE);
+ $criteria->addSelectColumn(TaxRuleTableMap::TITLE);
+ $criteria->addSelectColumn(TaxRuleTableMap::DESCRIPTION);
+ $criteria->addSelectColumn(TaxRuleTableMap::CREATED_AT);
+ $criteria->addSelectColumn(TaxRuleTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.CODE');
+ $criteria->addSelectColumn($alias . '.TITLE');
+ $criteria->addSelectColumn($alias . '.DESCRIPTION');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(TaxRuleTableMap::DATABASE_NAME)->getTable(TaxRuleTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(TaxRuleTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(TaxRuleTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new TaxRuleTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a TaxRule or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or TaxRule object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\TaxRule) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(TaxRuleTableMap::DATABASE_NAME);
+ $criteria->add(TaxRuleTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = TaxRuleQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { TaxRuleTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { TaxRuleTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the tax_rule table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return TaxRuleQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a TaxRule or Criteria object.
+ *
+ * @param mixed $criteria Criteria or TaxRule object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from TaxRule object
+ }
+
+ if ($criteria->containsKey(TaxRuleTableMap::ID) && $criteria->keyContainsValue(TaxRuleTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.TaxRuleTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = TaxRuleQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // TaxRuleTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+TaxRuleTableMap::buildTableMap();
diff --git a/core/lib/Thelia/Model/Map/TaxTableMap.php b/core/lib/Thelia/Model/Map/TaxTableMap.php
new file mode 100644
index 000000000..b941e7b52
--- /dev/null
+++ b/core/lib/Thelia/Model/Map/TaxTableMap.php
@@ -0,0 +1,460 @@
+ array('Id', 'Rate', 'CreatedAt', 'UpdatedAt', ),
+ self::TYPE_STUDLYPHPNAME => array('id', 'rate', 'createdAt', 'updatedAt', ),
+ self::TYPE_COLNAME => array(TaxTableMap::ID, TaxTableMap::RATE, TaxTableMap::CREATED_AT, TaxTableMap::UPDATED_AT, ),
+ self::TYPE_RAW_COLNAME => array('ID', 'RATE', 'CREATED_AT', 'UPDATED_AT', ),
+ self::TYPE_FIELDNAME => array('id', 'rate', 'created_at', 'updated_at', ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
+ */
+ protected static $fieldKeys = array (
+ self::TYPE_PHPNAME => array('Id' => 0, 'Rate' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
+ self::TYPE_STUDLYPHPNAME => array('id' => 0, 'rate' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
+ self::TYPE_COLNAME => array(TaxTableMap::ID => 0, TaxTableMap::RATE => 1, TaxTableMap::CREATED_AT => 2, TaxTableMap::UPDATED_AT => 3, ),
+ self::TYPE_RAW_COLNAME => array('ID' => 0, 'RATE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
+ self::TYPE_FIELDNAME => array('id' => 0, 'rate' => 1, 'created_at' => 2, 'updated_at' => 3, ),
+ self::TYPE_NUM => array(0, 1, 2, 3, )
+ );
+
+ /**
+ * Initialize the table attributes and columns
+ * Relations are not initialized by this method since they are lazy loaded
+ *
+ * @return void
+ * @throws PropelException
+ */
+ public function initialize()
+ {
+ // attributes
+ $this->setName('tax');
+ $this->setPhpName('Tax');
+ $this->setClassName('\\Thelia\\Model\\Tax');
+ $this->setPackage('Thelia.Model');
+ $this->setUseIdGenerator(true);
+ // columns
+ $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
+ $this->addColumn('RATE', 'Rate', 'FLOAT', true, null, null);
+ $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
+ $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
+ } // initialize()
+
+ /**
+ * Build the RelationMap objects for this table relationships
+ */
+ public function buildRelations()
+ {
+ $this->addRelation('TaxRuleCountry', '\\Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'tax_id', ), 'SET NULL', 'RESTRICT', 'TaxRuleCountries');
+ $this->addRelation('TaxI18n', '\\Thelia\\Model\\TaxI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'TaxI18ns');
+ } // buildRelations()
+
+ /**
+ *
+ * Gets the list of behaviors registered for this table
+ *
+ * @return array Associative array (name => parameters) of behaviors
+ */
+ public function getBehaviors()
+ {
+ return array(
+ 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
+ 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
+ );
+ } // getBehaviors()
+ /**
+ * Method to invalidate the instance pool of all tables related to tax * by a foreign key with ON DELETE CASCADE
+ */
+ public static function clearRelatedInstancePool()
+ {
+ // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
+ // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ TaxRuleCountryTableMap::clearInstancePool();
+ TaxI18nTableMap::clearInstancePool();
+ }
+
+ /**
+ * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
+ *
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, a serialize()d version of the primary key will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ */
+ public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ // If the PK cannot be derived from the row, return NULL.
+ if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) {
+ return null;
+ }
+
+ return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
+ }
+
+ /**
+ * Retrieves the primary key from the DB resultset row
+ * For tables with a single-column primary key, that simple pkey value will be returned. For tables with
+ * a multi-column primary key, an array of the primary key columns will be returned.
+ *
+ * @param array $row resultset row.
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM
+ *
+ * @return mixed The primary key of the row
+ */
+ public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+
+ return (int) $row[
+ $indexType == TableMap::TYPE_NUM
+ ? 0 + $offset
+ : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)
+ ];
+ }
+
+ /**
+ * The class that the tableMap will make instances of.
+ *
+ * If $withPrefix is true, the returned path
+ * uses a dot-path notation which is translated into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @param boolean $withPrefix Whether or not to return the path with the class name
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass($withPrefix = true)
+ {
+ return $withPrefix ? TaxTableMap::CLASS_DEFAULT : TaxTableMap::OM_CLASS;
+ }
+
+ /**
+ * Populates an object of the default type or an object that inherit from the default.
+ *
+ * @param array $row row returned by DataFetcher->fetch().
+ * @param int $offset The 0-based offset for reading from the resultset row.
+ * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
+ One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
+ * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return array (Tax object, last column rank)
+ */
+ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
+ {
+ $key = TaxTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
+ if (null !== ($obj = TaxTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, $offset, true); // rehydrate
+ $col = $offset + TaxTableMap::NUM_HYDRATE_COLUMNS;
+ } else {
+ $cls = TaxTableMap::OM_CLASS;
+ $obj = new $cls();
+ $col = $obj->hydrate($row, $offset, false, $indexType);
+ TaxTableMap::addInstanceToPool($obj, $key);
+ }
+
+ return array($obj, $col);
+ }
+
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param DataFetcherInterface $dataFetcher
+ * @return array
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(DataFetcherInterface $dataFetcher)
+ {
+ $results = array();
+
+ // set the class once to avoid overhead in the loop
+ $cls = static::getOMClass(false);
+ // populate the object(s)
+ while ($row = $dataFetcher->fetch()) {
+ $key = TaxTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
+ if (null !== ($obj = TaxTableMap::getInstanceFromPool($key))) {
+ // We no longer rehydrate the object, since this can cause data loss.
+ // See http://www.propelorm.org/ticket/509
+ // $obj->hydrate($row, 0, true); // rehydrate
+ $results[] = $obj;
+ } else {
+ $obj = new $cls();
+ $obj->hydrate($row);
+ $results[] = $obj;
+ TaxTableMap::addInstanceToPool($obj, $key);
+ } // if key exists
+ }
+
+ return $results;
+ }
+ /**
+ * 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 $criteria object containing the columns to add.
+ * @param string $alias optional table alias
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria $criteria, $alias = null)
+ {
+ if (null === $alias) {
+ $criteria->addSelectColumn(TaxTableMap::ID);
+ $criteria->addSelectColumn(TaxTableMap::RATE);
+ $criteria->addSelectColumn(TaxTableMap::CREATED_AT);
+ $criteria->addSelectColumn(TaxTableMap::UPDATED_AT);
+ } else {
+ $criteria->addSelectColumn($alias . '.ID');
+ $criteria->addSelectColumn($alias . '.RATE');
+ $criteria->addSelectColumn($alias . '.CREATED_AT');
+ $criteria->addSelectColumn($alias . '.UPDATED_AT');
+ }
+ }
+
+ /**
+ * Returns the TableMap related to this object.
+ * 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::getServiceContainer()->getDatabaseMap(TaxTableMap::DATABASE_NAME)->getTable(TaxTableMap::TABLE_NAME);
+ }
+
+ /**
+ * Add a TableMap instance to the database for this tableMap class.
+ */
+ public static function buildTableMap()
+ {
+ $dbMap = Propel::getServiceContainer()->getDatabaseMap(TaxTableMap::DATABASE_NAME);
+ if (!$dbMap->hasTable(TaxTableMap::TABLE_NAME)) {
+ $dbMap->addTableObject(new TaxTableMap());
+ }
+ }
+
+ /**
+ * Performs a DELETE on the database, given a Tax or Criteria object OR a primary key value.
+ *
+ * @param mixed $values Criteria or Tax object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param ConnectionInterface $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, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxTableMap::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ // rename for clarity
+ $criteria = $values;
+ } elseif ($values instanceof \Thelia\Model\Tax) { // it's a model object
+ // create criteria based on pk values
+ $criteria = $values->buildPkeyCriteria();
+ } else { // it's a primary key, or an array of pks
+ $criteria = new Criteria(TaxTableMap::DATABASE_NAME);
+ $criteria->add(TaxTableMap::ID, (array) $values, Criteria::IN);
+ }
+
+ $query = TaxQuery::create()->mergeWith($criteria);
+
+ if ($values instanceof Criteria) { TaxTableMap::clearInstancePool();
+ } elseif (!is_object($values)) { // it's a primary key, or an array of pks
+ foreach ((array) $values as $singleval) { TaxTableMap::removeInstanceFromPool($singleval);
+ }
+ }
+
+ return $query->delete($con);
+ }
+
+ /**
+ * Deletes all rows from the tax table.
+ *
+ * @param ConnectionInterface $con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(ConnectionInterface $con = null)
+ {
+ return TaxQuery::create()->doDeleteAll($con);
+ }
+
+ /**
+ * Performs an INSERT on the database, given a Tax or Criteria object.
+ *
+ * @param mixed $criteria Criteria or Tax object containing data that is used to create the INSERT statement.
+ * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null)
+ {
+ if (null === $con) {
+ $con = Propel::getServiceContainer()->getWriteConnection(TaxTableMap::DATABASE_NAME);
+ }
+
+ if ($criteria instanceof Criteria) {
+ $criteria = clone $criteria; // rename for clarity
+ } else {
+ $criteria = $criteria->buildCriteria(); // build Criteria from Tax object
+ }
+
+ if ($criteria->containsKey(TaxTableMap::ID) && $criteria->keyContainsValue(TaxTableMap::ID) ) {
+ throw new PropelException('Cannot insert a value for auto-increment primary key ('.TaxTableMap::ID.')');
+ }
+
+
+ // Set the correct dbName
+ $query = TaxQuery::create()->mergeWith($criteria);
+
+ try {
+ // use transaction because $criteria could contain info
+ // for more than one table (I guess, conceivably)
+ $con->beginTransaction();
+ $pk = $query->doInsert($con);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollBack();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+} // TaxTableMap
+// This is the static code needed to register the TableMap for this table with the main Propel class.
+//
+TaxTableMap::buildTableMap();
diff --git a/install/thelia.sql b/install/thelia.sql
index 46a934a3b..94d933587 100755
--- a/install/thelia.sql
+++ b/install/thelia.sql
@@ -477,8 +477,8 @@ CREATE TABLE `customer`
`updated_at` DATETIME,
PRIMARY KEY (`id`),
UNIQUE INDEX `ref_UNIQUE` (`ref`),
- INDEX `idx_ customer_customer_title_id` (`customer_title_id`),
- CONSTRAINT `fk_ customer_customer_title_id`
+ INDEX `idx_customer_customer_title_id` (`customer_title_id`),
+ CONSTRAINT `fk_customer_customer_title_id`
FOREIGN KEY (`customer_title_id`)
REFERENCES `customer_title` (`id`)
ON UPDATE RESTRICT
diff --git a/local/config/schema.xml b/local/config/schema.xml
index f9063c614..8b97f4e8c 100755
--- a/local/config/schema.xml
+++ b/local/config/schema.xml
@@ -349,7 +349,7 @@
Conditional example #1