Merge pull request #483 from Yochima/yochima-branch

Add the table order_version to Thelia
This commit is contained in:
Manuel Raynaud
2014-06-19 14:26:57 +02:00
12 changed files with 5620 additions and 17 deletions

View File

@@ -35,7 +35,10 @@ use Thelia\Model\OrderProductQuery as ChildOrderProductQuery;
use Thelia\Model\OrderQuery as ChildOrderQuery;
use Thelia\Model\OrderStatus as ChildOrderStatus;
use Thelia\Model\OrderStatusQuery as ChildOrderStatusQuery;
use Thelia\Model\OrderVersion as ChildOrderVersion;
use Thelia\Model\OrderVersionQuery as ChildOrderVersionQuery;
use Thelia\Model\Map\OrderTableMap;
use Thelia\Model\Map\OrderVersionTableMap;
abstract class Order implements ActiveRecordInterface
{
@@ -185,6 +188,25 @@ abstract class Order implements ActiveRecordInterface
*/
protected $updated_at;
/**
* The value for the version field.
* Note: this column has a database default value of: 0
* @var int
*/
protected $version;
/**
* The value for the version_created_at field.
* @var string
*/
protected $version_created_at;
/**
* The value for the version_created_by field.
* @var string
*/
protected $version_created_by;
/**
* @var Currency
*/
@@ -237,6 +259,12 @@ abstract class Order implements ActiveRecordInterface
protected $collOrderCoupons;
protected $collOrderCouponsPartial;
/**
* @var ObjectCollection|ChildOrderVersion[] Collection to store aggregation of ChildOrderVersion objects.
*/
protected $collOrderVersions;
protected $collOrderVersionsPartial;
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -245,6 +273,14 @@ abstract class Order implements ActiveRecordInterface
*/
protected $alreadyInSave = false;
// versionable behavior
/**
* @var bool
*/
protected $enforceVersion = false;
/**
* An array of objects scheduled for deletion.
* @var ObjectCollection
@@ -257,11 +293,30 @@ abstract class Order implements ActiveRecordInterface
*/
protected $orderCouponsScheduledForDeletion = null;
/**
* An array of objects scheduled for deletion.
* @var ObjectCollection
*/
protected $orderVersionsScheduledForDeletion = null;
/**
* Applies default values to this object.
* This method should be called from the object's constructor (or
* equivalent initialization method).
* @see __construct()
*/
public function applyDefaultValues()
{
$this->version = 0;
}
/**
* Initializes internal state of Thelia\Model\Base\Order object.
* @see applyDefaults()
*/
public function __construct()
{
$this->applyDefaultValues();
}
/**
@@ -751,6 +806,48 @@ abstract class Order implements ActiveRecordInterface
}
}
/**
* 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 instanceof \DateTime ? $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.
*
@@ -1182,6 +1279,69 @@ abstract class Order implements ActiveRecordInterface
return $this;
} // setUpdatedAt()
/**
* Set the value of [version] column.
*
* @param int $v new value
* @return \Thelia\Model\Order 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[OrderTableMap::VERSION] = true;
}
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\Order 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[OrderTableMap::VERSION_CREATED_AT] = true;
}
} // if either are not null
return $this;
} // setVersionCreatedAt()
/**
* Set the value of [version_created_by] column.
*
* @param string $v new value
* @return \Thelia\Model\Order 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[OrderTableMap::VERSION_CREATED_BY] = true;
}
return $this;
} // setVersionCreatedBy()
/**
* Indicates whether the columns in this object are only set to default values.
*
@@ -1192,6 +1352,10 @@ abstract class Order implements ActiveRecordInterface
*/
public function hasOnlyDefaultValues()
{
if ($this->version !== 0) {
return false;
}
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
@@ -1284,6 +1448,18 @@ abstract class Order implements ActiveRecordInterface
$col = null;
}
$this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 19 + $startcol : OrderTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)];
$this->version = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 20 + $startcol : OrderTableMap::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 ? 21 + $startcol : OrderTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)];
$this->version_created_by = (null !== $col) ? (string) $col : null;
$this->resetModified();
$this->setNew(false);
@@ -1292,7 +1468,7 @@ abstract class Order implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 19; // 19 = OrderTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 22; // 22 = OrderTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\Order object", 0, $e);
@@ -1389,6 +1565,8 @@ abstract class Order implements ActiveRecordInterface
$this->collOrderCoupons = null;
$this->collOrderVersions = null;
} // if (deep)
}
@@ -1457,6 +1635,14 @@ abstract class Order implements ActiveRecordInterface
$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(OrderTableMap::VERSION_CREATED_AT)) {
$this->setVersionCreatedAt(time());
}
$createVersion = true; // for postSave hook
}
if ($isInsert) {
$ret = $ret && $this->preInsert($con);
// timestampable behavior
@@ -1481,6 +1667,10 @@ abstract class Order implements ActiveRecordInterface
$this->postUpdate($con);
}
$this->postSave($con);
// versionable behavior
if (isset($createVersion)) {
$this->addVersion($con);
}
OrderTableMap::addInstanceToPool($this);
} else {
$affectedRows = 0;
@@ -1617,6 +1807,23 @@ abstract class Order implements ActiveRecordInterface
}
}
if ($this->orderVersionsScheduledForDeletion !== null) {
if (!$this->orderVersionsScheduledForDeletion->isEmpty()) {
\Thelia\Model\OrderVersionQuery::create()
->filterByPrimaryKeys($this->orderVersionsScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
$this->orderVersionsScheduledForDeletion = null;
}
}
if ($this->collOrderVersions !== null) {
foreach ($this->collOrderVersions as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
@@ -1700,6 +1907,15 @@ abstract class Order implements ActiveRecordInterface
if ($this->isColumnModified(OrderTableMap::UPDATED_AT)) {
$modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
}
if ($this->isColumnModified(OrderTableMap::VERSION)) {
$modifiedColumns[':p' . $index++] = '`VERSION`';
}
if ($this->isColumnModified(OrderTableMap::VERSION_CREATED_AT)) {
$modifiedColumns[':p' . $index++] = '`VERSION_CREATED_AT`';
}
if ($this->isColumnModified(OrderTableMap::VERSION_CREATED_BY)) {
$modifiedColumns[':p' . $index++] = '`VERSION_CREATED_BY`';
}
$sql = sprintf(
'INSERT INTO `order` (%s) VALUES (%s)',
@@ -1768,6 +1984,15 @@ abstract class Order implements ActiveRecordInterface
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();
@@ -1887,6 +2112,15 @@ abstract class Order implements ActiveRecordInterface
case 18:
return $this->getUpdatedAt();
break;
case 19:
return $this->getVersion();
break;
case 20:
return $this->getVersionCreatedAt();
break;
case 21:
return $this->getVersionCreatedBy();
break;
default:
return null;
break;
@@ -1935,6 +2169,9 @@ abstract class Order implements ActiveRecordInterface
$keys[16] => $this->getLangId(),
$keys[17] => $this->getCreatedAt(),
$keys[18] => $this->getUpdatedAt(),
$keys[19] => $this->getVersion(),
$keys[20] => $this->getVersionCreatedAt(),
$keys[21] => $this->getVersionCreatedBy(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
@@ -1972,6 +2209,9 @@ abstract class Order implements ActiveRecordInterface
if (null !== $this->collOrderCoupons) {
$result['OrderCoupons'] = $this->collOrderCoupons->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
if (null !== $this->collOrderVersions) {
$result['OrderVersions'] = $this->collOrderVersions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
return $result;
@@ -2063,6 +2303,15 @@ abstract class Order implements ActiveRecordInterface
case 18:
$this->setUpdatedAt($value);
break;
case 19:
$this->setVersion($value);
break;
case 20:
$this->setVersionCreatedAt($value);
break;
case 21:
$this->setVersionCreatedBy($value);
break;
} // switch()
}
@@ -2106,6 +2355,9 @@ abstract class Order implements ActiveRecordInterface
if (array_key_exists($keys[16], $arr)) $this->setLangId($arr[$keys[16]]);
if (array_key_exists($keys[17], $arr)) $this->setCreatedAt($arr[$keys[17]]);
if (array_key_exists($keys[18], $arr)) $this->setUpdatedAt($arr[$keys[18]]);
if (array_key_exists($keys[19], $arr)) $this->setVersion($arr[$keys[19]]);
if (array_key_exists($keys[20], $arr)) $this->setVersionCreatedAt($arr[$keys[20]]);
if (array_key_exists($keys[21], $arr)) $this->setVersionCreatedBy($arr[$keys[21]]);
}
/**
@@ -2136,6 +2388,9 @@ abstract class Order implements ActiveRecordInterface
if ($this->isColumnModified(OrderTableMap::LANG_ID)) $criteria->add(OrderTableMap::LANG_ID, $this->lang_id);
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);
if ($this->isColumnModified(OrderTableMap::VERSION)) $criteria->add(OrderTableMap::VERSION, $this->version);
if ($this->isColumnModified(OrderTableMap::VERSION_CREATED_AT)) $criteria->add(OrderTableMap::VERSION_CREATED_AT, $this->version_created_at);
if ($this->isColumnModified(OrderTableMap::VERSION_CREATED_BY)) $criteria->add(OrderTableMap::VERSION_CREATED_BY, $this->version_created_by);
return $criteria;
}
@@ -2217,6 +2472,9 @@ abstract class Order implements ActiveRecordInterface
$copyObj->setLangId($this->getLangId());
$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
@@ -2235,6 +2493,12 @@ abstract class Order implements ActiveRecordInterface
}
}
foreach ($this->getOrderVersions() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addOrderVersion($relObj->copy($deepCopy));
}
}
} // if ($deepCopy)
if ($makeNew) {
@@ -2690,6 +2954,9 @@ abstract class Order implements ActiveRecordInterface
if ('OrderCoupon' == $relationName) {
return $this->initOrderCoupons();
}
if ('OrderVersion' == $relationName) {
return $this->initOrderVersions();
}
}
/**
@@ -3128,6 +3395,227 @@ abstract class Order implements ActiveRecordInterface
return $this;
}
/**
* Clears out the collOrderVersions 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 addOrderVersions()
*/
public function clearOrderVersions()
{
$this->collOrderVersions = null; // important to set this to NULL since that means it is uninitialized
}
/**
* Reset is the collOrderVersions collection loaded partially.
*/
public function resetPartialOrderVersions($v = true)
{
$this->collOrderVersionsPartial = $v;
}
/**
* Initializes the collOrderVersions collection.
*
* By default this just sets the collOrderVersions collection to an empty array (like clearcollOrderVersions());
* 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 initOrderVersions($overrideExisting = true)
{
if (null !== $this->collOrderVersions && !$overrideExisting) {
return;
}
$this->collOrderVersions = new ObjectCollection();
$this->collOrderVersions->setModel('\Thelia\Model\OrderVersion');
}
/**
* Gets an array of ChildOrderVersion 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|ChildOrderVersion[] List of ChildOrderVersion objects
* @throws PropelException
*/
public function getOrderVersions($criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collOrderVersionsPartial && !$this->isNew();
if (null === $this->collOrderVersions || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collOrderVersions) {
// return empty collection
$this->initOrderVersions();
} else {
$collOrderVersions = ChildOrderVersionQuery::create(null, $criteria)
->filterByOrder($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collOrderVersionsPartial && count($collOrderVersions)) {
$this->initOrderVersions(false);
foreach ($collOrderVersions as $obj) {
if (false == $this->collOrderVersions->contains($obj)) {
$this->collOrderVersions->append($obj);
}
}
$this->collOrderVersionsPartial = true;
}
reset($collOrderVersions);
return $collOrderVersions;
}
if ($partial && $this->collOrderVersions) {
foreach ($this->collOrderVersions as $obj) {
if ($obj->isNew()) {
$collOrderVersions[] = $obj;
}
}
}
$this->collOrderVersions = $collOrderVersions;
$this->collOrderVersionsPartial = false;
}
}
return $this->collOrderVersions;
}
/**
* Sets a collection of OrderVersion 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 $orderVersions A Propel collection.
* @param ConnectionInterface $con Optional connection object
* @return ChildOrder The current object (for fluent API support)
*/
public function setOrderVersions(Collection $orderVersions, ConnectionInterface $con = null)
{
$orderVersionsToDelete = $this->getOrderVersions(new Criteria(), $con)->diff($orderVersions);
//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->orderVersionsScheduledForDeletion = clone $orderVersionsToDelete;
foreach ($orderVersionsToDelete as $orderVersionRemoved) {
$orderVersionRemoved->setOrder(null);
}
$this->collOrderVersions = null;
foreach ($orderVersions as $orderVersion) {
$this->addOrderVersion($orderVersion);
}
$this->collOrderVersions = $orderVersions;
$this->collOrderVersionsPartial = false;
return $this;
}
/**
* Returns the number of related OrderVersion objects.
*
* @param Criteria $criteria
* @param boolean $distinct
* @param ConnectionInterface $con
* @return int Count of related OrderVersion objects.
* @throws PropelException
*/
public function countOrderVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collOrderVersionsPartial && !$this->isNew();
if (null === $this->collOrderVersions || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collOrderVersions) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getOrderVersions());
}
$query = ChildOrderVersionQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByOrder($this)
->count($con);
}
return count($this->collOrderVersions);
}
/**
* Method called to associate a ChildOrderVersion object to this object
* through the ChildOrderVersion foreign key attribute.
*
* @param ChildOrderVersion $l ChildOrderVersion
* @return \Thelia\Model\Order The current object (for fluent API support)
*/
public function addOrderVersion(ChildOrderVersion $l)
{
if ($this->collOrderVersions === null) {
$this->initOrderVersions();
$this->collOrderVersionsPartial = true;
}
if (!in_array($l, $this->collOrderVersions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddOrderVersion($l);
}
return $this;
}
/**
* @param OrderVersion $orderVersion The orderVersion object to add.
*/
protected function doAddOrderVersion($orderVersion)
{
$this->collOrderVersions[]= $orderVersion;
$orderVersion->setOrder($this);
}
/**
* @param OrderVersion $orderVersion The orderVersion object to remove.
* @return ChildOrder The current object (for fluent API support)
*/
public function removeOrderVersion($orderVersion)
{
if ($this->getOrderVersions()->contains($orderVersion)) {
$this->collOrderVersions->remove($this->collOrderVersions->search($orderVersion));
if (null === $this->orderVersionsScheduledForDeletion) {
$this->orderVersionsScheduledForDeletion = clone $this->collOrderVersions;
$this->orderVersionsScheduledForDeletion->clear();
}
$this->orderVersionsScheduledForDeletion[]= clone $orderVersion;
$orderVersion->setOrder(null);
}
return $this;
}
/**
* Clears the current object and sets all attributes to their default values
*/
@@ -3152,8 +3640,12 @@ abstract class Order implements ActiveRecordInterface
$this->lang_id = 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);
@@ -3181,10 +3673,16 @@ abstract class Order implements ActiveRecordInterface
$o->clearAllReferences($deep);
}
}
if ($this->collOrderVersions) {
foreach ($this->collOrderVersions as $o) {
$o->clearAllReferences($deep);
}
}
} // if ($deep)
$this->collOrderProducts = null;
$this->collOrderCoupons = null;
$this->collOrderVersions = null;
$this->aCurrency = null;
$this->aCustomer = null;
$this->aOrderAddressRelatedByInvoiceOrderAddressId = null;
@@ -3219,6 +3717,316 @@ abstract class Order implements ActiveRecordInterface
return $this;
}
// versionable behavior
/**
* Enforce a new Version of this object upon next save.
*
* @return \Thelia\Model\Order
*/
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 (ChildOrderQuery::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 ChildOrderVersion A version object
*/
public function addVersion($con = null)
{
$this->enforceVersion = false;
$version = new ChildOrderVersion();
$version->setId($this->getId());
$version->setRef($this->getRef());
$version->setCustomerId($this->getCustomerId());
$version->setInvoiceOrderAddressId($this->getInvoiceOrderAddressId());
$version->setDeliveryOrderAddressId($this->getDeliveryOrderAddressId());
$version->setInvoiceDate($this->getInvoiceDate());
$version->setCurrencyId($this->getCurrencyId());
$version->setCurrencyRate($this->getCurrencyRate());
$version->setTransactionRef($this->getTransactionRef());
$version->setDeliveryRef($this->getDeliveryRef());
$version->setInvoiceRef($this->getInvoiceRef());
$version->setDiscount($this->getDiscount());
$version->setPostage($this->getPostage());
$version->setPaymentModuleId($this->getPaymentModuleId());
$version->setDeliveryModuleId($this->getDeliveryModuleId());
$version->setStatusId($this->getStatusId());
$version->setLangId($this->getLangId());
$version->setCreatedAt($this->getCreatedAt());
$version->setUpdatedAt($this->getUpdatedAt());
$version->setVersion($this->getVersion());
$version->setVersionCreatedAt($this->getVersionCreatedAt());
$version->setVersionCreatedBy($this->getVersionCreatedBy());
$version->setOrder($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 ChildOrder 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 ChildOrder 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 ChildOrderVersion $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 ChildOrder The current object (for fluent API support)
*/
public function populateFromVersion($version, $con = null, &$loadedObjects = array())
{
$loadedObjects['ChildOrder'][$version->getId()][$version->getVersion()] = $this;
$this->setId($version->getId());
$this->setRef($version->getRef());
$this->setCustomerId($version->getCustomerId());
$this->setInvoiceOrderAddressId($version->getInvoiceOrderAddressId());
$this->setDeliveryOrderAddressId($version->getDeliveryOrderAddressId());
$this->setInvoiceDate($version->getInvoiceDate());
$this->setCurrencyId($version->getCurrencyId());
$this->setCurrencyRate($version->getCurrencyRate());
$this->setTransactionRef($version->getTransactionRef());
$this->setDeliveryRef($version->getDeliveryRef());
$this->setInvoiceRef($version->getInvoiceRef());
$this->setDiscount($version->getDiscount());
$this->setPostage($version->getPostage());
$this->setPaymentModuleId($version->getPaymentModuleId());
$this->setDeliveryModuleId($version->getDeliveryModuleId());
$this->setStatusId($version->getStatusId());
$this->setLangId($version->getLangId());
$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 = ChildOrderVersionQuery::create()
->filterByOrder($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 ChildOrderVersion A version object
*/
public function getOneVersion($versionNumber, $con = null)
{
return ChildOrderVersionQuery::create()
->filterByOrder($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 ChildOrderVersion objects
*/
public function getAllVersions($con = null)
{
$criteria = new Criteria();
$criteria->addAscendingOrderByColumn(OrderVersionTableMap::VERSION);
return $this->getOrderVersions($criteria, $con);
}
/**
* Compares the current object with another of its version.
* <code>
* print_r($book->compareVersion(1));
* => array(
* '1' => array('Title' => 'Book title at version 1'),
* '2' => array('Title' => 'Book title at version 2')
* );
* </code>
*
* @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.
* <code>
* print_r($book->compareVersions(1, 2));
* => array(
* '1' => array('Title' => 'Book title at version 1'),
* '2' => array('Title' => 'Book title at version 2')
* );
* </code>
*
* @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.
* <code>
* print_r($book->computeDiff(1, 2));
* => array(
* '1' => array('Title' => 'Book title at version 1'),
* '2' => array('Title' => 'Book title at version 2')
* );
* </code>
*
* @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\OrderVersion[] List of \Thelia\Model\OrderVersion objects
*/
public function getLastVersions($number = 10, $criteria = null, $con = null)
{
$criteria = ChildOrderVersionQuery::create(null, $criteria);
$criteria->addDescendingOrderByColumn(OrderVersionTableMap::VERSION);
$criteria->limit($number);
return $this->getOrderVersions($criteria, $con);
}
/**
* Code to be run before persisting the object
* @param ConnectionInterface $con

View File

@@ -40,6 +40,9 @@ use Thelia\Model\Map\OrderTableMap;
* @method ChildOrderQuery orderByLangId($order = Criteria::ASC) Order by the lang_id column
* @method ChildOrderQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildOrderQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
* @method ChildOrderQuery orderByVersion($order = Criteria::ASC) Order by the version column
* @method ChildOrderQuery orderByVersionCreatedAt($order = Criteria::ASC) Order by the version_created_at column
* @method ChildOrderQuery orderByVersionCreatedBy($order = Criteria::ASC) Order by the version_created_by column
*
* @method ChildOrderQuery groupById() Group by the id column
* @method ChildOrderQuery groupByRef() Group by the ref column
@@ -60,6 +63,9 @@ use Thelia\Model\Map\OrderTableMap;
* @method ChildOrderQuery groupByLangId() Group by the lang_id column
* @method ChildOrderQuery groupByCreatedAt() Group by the created_at column
* @method ChildOrderQuery groupByUpdatedAt() Group by the updated_at column
* @method ChildOrderQuery groupByVersion() Group by the version column
* @method ChildOrderQuery groupByVersionCreatedAt() Group by the version_created_at column
* @method ChildOrderQuery groupByVersionCreatedBy() Group by the version_created_by column
*
* @method ChildOrderQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ChildOrderQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@@ -105,6 +111,10 @@ use Thelia\Model\Map\OrderTableMap;
* @method ChildOrderQuery rightJoinOrderCoupon($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderCoupon relation
* @method ChildOrderQuery innerJoinOrderCoupon($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderCoupon relation
*
* @method ChildOrderQuery leftJoinOrderVersion($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderVersion relation
* @method ChildOrderQuery rightJoinOrderVersion($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderVersion relation
* @method ChildOrderQuery innerJoinOrderVersion($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderVersion relation
*
* @method ChildOrder findOne(ConnectionInterface $con = null) Return the first ChildOrder matching the query
* @method ChildOrder findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrder matching the query, or a new ChildOrder object populated from the query conditions when no match is found
*
@@ -127,6 +137,9 @@ use Thelia\Model\Map\OrderTableMap;
* @method ChildOrder findOneByLangId(int $lang_id) Return the first ChildOrder filtered by the lang_id column
* @method ChildOrder findOneByCreatedAt(string $created_at) Return the first ChildOrder filtered by the created_at column
* @method ChildOrder findOneByUpdatedAt(string $updated_at) Return the first ChildOrder filtered by the updated_at column
* @method ChildOrder findOneByVersion(int $version) Return the first ChildOrder filtered by the version column
* @method ChildOrder findOneByVersionCreatedAt(string $version_created_at) Return the first ChildOrder filtered by the version_created_at column
* @method ChildOrder findOneByVersionCreatedBy(string $version_created_by) Return the first ChildOrder filtered by the version_created_by column
*
* @method array findById(int $id) Return ChildOrder objects filtered by the id column
* @method array findByRef(string $ref) Return ChildOrder objects filtered by the ref column
@@ -147,11 +160,21 @@ use Thelia\Model\Map\OrderTableMap;
* @method array findByLangId(int $lang_id) Return ChildOrder objects filtered by the lang_id column
* @method array findByCreatedAt(string $created_at) Return ChildOrder objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildOrder objects filtered by the updated_at column
* @method array findByVersion(int $version) Return ChildOrder objects filtered by the version column
* @method array findByVersionCreatedAt(string $version_created_at) Return ChildOrder objects filtered by the version_created_at column
* @method array findByVersionCreatedBy(string $version_created_by) Return ChildOrder objects filtered by the version_created_by column
*
*/
abstract class OrderQuery extends ModelCriteria
{
// versionable behavior
/**
* Whether the versioning is enabled
*/
static $isVersioningEnabled = true;
/**
* Initializes internal state of \Thelia\Model\Base\OrderQuery object.
*
@@ -235,7 +258,7 @@ abstract class OrderQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT `ID`, `REF`, `CUSTOMER_ID`, `INVOICE_ORDER_ADDRESS_ID`, `DELIVERY_ORDER_ADDRESS_ID`, `INVOICE_DATE`, `CURRENCY_ID`, `CURRENCY_RATE`, `TRANSACTION_REF`, `DELIVERY_REF`, `INVOICE_REF`, `DISCOUNT`, `POSTAGE`, `PAYMENT_MODULE_ID`, `DELIVERY_MODULE_ID`, `STATUS_ID`, `LANG_ID`, `CREATED_AT`, `UPDATED_AT` FROM `order` WHERE `ID` = :p0';
$sql = 'SELECT `ID`, `REF`, `CUSTOMER_ID`, `INVOICE_ORDER_ADDRESS_ID`, `DELIVERY_ORDER_ADDRESS_ID`, `INVOICE_DATE`, `CURRENCY_ID`, `CURRENCY_RATE`, `TRANSACTION_REF`, `DELIVERY_REF`, `INVOICE_REF`, `DISCOUNT`, `POSTAGE`, `PAYMENT_MODULE_ID`, `DELIVERY_MODULE_ID`, `STATUS_ID`, `LANG_ID`, `CREATED_AT`, `UPDATED_AT`, `VERSION`, `VERSION_CREATED_AT`, `VERSION_CREATED_BY` FROM `order` WHERE `ID` = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -1077,6 +1100,119 @@ abstract class OrderQuery extends ModelCriteria
return $this->addUsingAlias(OrderTableMap::UPDATED_AT, $updatedAt, $comparison);
}
/**
* Filter the query on the version column
*
* Example usage:
* <code>
* $query->filterByVersion(1234); // WHERE version = 1234
* $query->filterByVersion(array(12, 34)); // WHERE version IN (12, 34)
* $query->filterByVersion(array('min' => 12)); // WHERE version > 12
* </code>
*
* @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 ChildOrderQuery 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(OrderTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($version['max'])) {
$this->addUsingAlias(OrderTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(OrderTableMap::VERSION, $version, $comparison);
}
/**
* Filter the query on the version_created_at column
*
* Example usage:
* <code>
* $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'
* </code>
*
* @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 ChildOrderQuery 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(OrderTableMap::VERSION_CREATED_AT, $versionCreatedAt['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($versionCreatedAt['max'])) {
$this->addUsingAlias(OrderTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(OrderTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison);
}
/**
* Filter the query on the version_created_by column
*
* Example usage:
* <code>
* $query->filterByVersionCreatedBy('fooValue'); // WHERE version_created_by = 'fooValue'
* $query->filterByVersionCreatedBy('%fooValue%'); // WHERE version_created_by LIKE '%fooValue%'
* </code>
*
* @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 ChildOrderQuery 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(OrderTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison);
}
/**
* Filter the query by a related \Thelia\Model\Currency object
*
@@ -1823,6 +1959,79 @@ abstract class OrderQuery extends ModelCriteria
->useQuery($relationAlias ? $relationAlias : 'OrderCoupon', '\Thelia\Model\OrderCouponQuery');
}
/**
* Filter the query by a related \Thelia\Model\OrderVersion object
*
* @param \Thelia\Model\OrderVersion|ObjectCollection $orderVersion 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 filterByOrderVersion($orderVersion, $comparison = null)
{
if ($orderVersion instanceof \Thelia\Model\OrderVersion) {
return $this
->addUsingAlias(OrderTableMap::ID, $orderVersion->getId(), $comparison);
} elseif ($orderVersion instanceof ObjectCollection) {
return $this
->useOrderVersionQuery()
->filterByPrimaryKeys($orderVersion->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByOrderVersion() only accepts arguments of type \Thelia\Model\OrderVersion or Collection');
}
}
/**
* Adds a JOIN clause to the query using the OrderVersion 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 joinOrderVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
$tableMap = $this->getTableMap();
$relationMap = $tableMap->getRelation('OrderVersion');
// 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, 'OrderVersion');
}
return $this;
}
/**
* Use the OrderVersion relation OrderVersion 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\OrderVersionQuery A secondary query class using the current class as primary query
*/
public function useOrderVersionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinOrderVersion($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'OrderVersion', '\Thelia\Model\OrderVersionQuery');
}
/**
* Exclude object from result
*
@@ -1980,4 +2189,32 @@ abstract class OrderQuery extends ModelCriteria
return $this->addAscendingOrderByColumn(OrderTableMap::CREATED_AT);
}
// 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;
}
} // OrderQuery

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -58,7 +58,7 @@ class OrderTableMap extends TableMap
/**
* The total number of columns
*/
const NUM_COLUMNS = 19;
const NUM_COLUMNS = 22;
/**
* The number of lazy-loaded columns
@@ -68,7 +68,7 @@ class OrderTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 19;
const NUM_HYDRATE_COLUMNS = 22;
/**
* the column name for the ID field
@@ -165,6 +165,21 @@ class OrderTableMap extends TableMap
*/
const UPDATED_AT = 'order.UPDATED_AT';
/**
* the column name for the VERSION field
*/
const VERSION = 'order.VERSION';
/**
* the column name for the VERSION_CREATED_AT field
*/
const VERSION_CREATED_AT = 'order.VERSION_CREATED_AT';
/**
* the column name for the VERSION_CREATED_BY field
*/
const VERSION_CREATED_BY = 'order.VERSION_CREATED_BY';
/**
* The default string format for model objects of the related table
*/
@@ -177,12 +192,12 @@ class OrderTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'Ref', 'CustomerId', 'InvoiceOrderAddressId', 'DeliveryOrderAddressId', 'InvoiceDate', 'CurrencyId', 'CurrencyRate', 'TransactionRef', 'DeliveryRef', 'InvoiceRef', 'Discount', 'Postage', 'PaymentModuleId', 'DeliveryModuleId', 'StatusId', 'LangId', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'customerId', 'invoiceOrderAddressId', 'deliveryOrderAddressId', 'invoiceDate', 'currencyId', 'currencyRate', 'transactionRef', 'deliveryRef', 'invoiceRef', 'discount', 'postage', 'paymentModuleId', 'deliveryModuleId', 'statusId', 'langId', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(OrderTableMap::ID, OrderTableMap::REF, OrderTableMap::CUSTOMER_ID, OrderTableMap::INVOICE_ORDER_ADDRESS_ID, OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, OrderTableMap::INVOICE_DATE, OrderTableMap::CURRENCY_ID, OrderTableMap::CURRENCY_RATE, OrderTableMap::TRANSACTION_REF, OrderTableMap::DELIVERY_REF, OrderTableMap::INVOICE_REF, OrderTableMap::DISCOUNT, OrderTableMap::POSTAGE, OrderTableMap::PAYMENT_MODULE_ID, OrderTableMap::DELIVERY_MODULE_ID, OrderTableMap::STATUS_ID, OrderTableMap::LANG_ID, OrderTableMap::CREATED_AT, OrderTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CUSTOMER_ID', 'INVOICE_ORDER_ADDRESS_ID', 'DELIVERY_ORDER_ADDRESS_ID', 'INVOICE_DATE', 'CURRENCY_ID', 'CURRENCY_RATE', 'TRANSACTION_REF', 'DELIVERY_REF', 'INVOICE_REF', 'DISCOUNT', 'POSTAGE', 'PAYMENT_MODULE_ID', 'DELIVERY_MODULE_ID', 'STATUS_ID', 'LANG_ID', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'ref', 'customer_id', 'invoice_order_address_id', 'delivery_order_address_id', 'invoice_date', 'currency_id', 'currency_rate', 'transaction_ref', 'delivery_ref', 'invoice_ref', 'discount', 'postage', 'payment_module_id', 'delivery_module_id', 'status_id', 'lang_id', '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, )
self::TYPE_PHPNAME => array('Id', 'Ref', 'CustomerId', 'InvoiceOrderAddressId', 'DeliveryOrderAddressId', 'InvoiceDate', 'CurrencyId', 'CurrencyRate', 'TransactionRef', 'DeliveryRef', 'InvoiceRef', 'Discount', 'Postage', 'PaymentModuleId', 'DeliveryModuleId', 'StatusId', 'LangId', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'customerId', 'invoiceOrderAddressId', 'deliveryOrderAddressId', 'invoiceDate', 'currencyId', 'currencyRate', 'transactionRef', 'deliveryRef', 'invoiceRef', 'discount', 'postage', 'paymentModuleId', 'deliveryModuleId', 'statusId', 'langId', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
self::TYPE_COLNAME => array(OrderTableMap::ID, OrderTableMap::REF, OrderTableMap::CUSTOMER_ID, OrderTableMap::INVOICE_ORDER_ADDRESS_ID, OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, OrderTableMap::INVOICE_DATE, OrderTableMap::CURRENCY_ID, OrderTableMap::CURRENCY_RATE, OrderTableMap::TRANSACTION_REF, OrderTableMap::DELIVERY_REF, OrderTableMap::INVOICE_REF, OrderTableMap::DISCOUNT, OrderTableMap::POSTAGE, OrderTableMap::PAYMENT_MODULE_ID, OrderTableMap::DELIVERY_MODULE_ID, OrderTableMap::STATUS_ID, OrderTableMap::LANG_ID, OrderTableMap::CREATED_AT, OrderTableMap::UPDATED_AT, OrderTableMap::VERSION, OrderTableMap::VERSION_CREATED_AT, OrderTableMap::VERSION_CREATED_BY, ),
self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CUSTOMER_ID', 'INVOICE_ORDER_ADDRESS_ID', 'DELIVERY_ORDER_ADDRESS_ID', 'INVOICE_DATE', 'CURRENCY_ID', 'CURRENCY_RATE', 'TRANSACTION_REF', 'DELIVERY_REF', 'INVOICE_REF', 'DISCOUNT', 'POSTAGE', 'PAYMENT_MODULE_ID', 'DELIVERY_MODULE_ID', 'STATUS_ID', 'LANG_ID', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
self::TYPE_FIELDNAME => array('id', 'ref', 'customer_id', 'invoice_order_address_id', 'delivery_order_address_id', 'invoice_date', 'currency_id', 'currency_rate', 'transaction_ref', 'delivery_ref', 'invoice_ref', 'discount', 'postage', 'payment_module_id', 'delivery_module_id', 'status_id', 'lang_id', '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, 17, 18, 19, 20, 21, )
);
/**
@@ -192,12 +207,12 @@ class OrderTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'CustomerId' => 2, 'InvoiceOrderAddressId' => 3, 'DeliveryOrderAddressId' => 4, 'InvoiceDate' => 5, 'CurrencyId' => 6, 'CurrencyRate' => 7, 'TransactionRef' => 8, 'DeliveryRef' => 9, 'InvoiceRef' => 10, 'Discount' => 11, 'Postage' => 12, 'PaymentModuleId' => 13, 'DeliveryModuleId' => 14, 'StatusId' => 15, 'LangId' => 16, 'CreatedAt' => 17, 'UpdatedAt' => 18, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'customerId' => 2, 'invoiceOrderAddressId' => 3, 'deliveryOrderAddressId' => 4, 'invoiceDate' => 5, 'currencyId' => 6, 'currencyRate' => 7, 'transactionRef' => 8, 'deliveryRef' => 9, 'invoiceRef' => 10, 'discount' => 11, 'postage' => 12, 'paymentModuleId' => 13, 'deliveryModuleId' => 14, 'statusId' => 15, 'langId' => 16, 'createdAt' => 17, 'updatedAt' => 18, ),
self::TYPE_COLNAME => array(OrderTableMap::ID => 0, OrderTableMap::REF => 1, OrderTableMap::CUSTOMER_ID => 2, OrderTableMap::INVOICE_ORDER_ADDRESS_ID => 3, OrderTableMap::DELIVERY_ORDER_ADDRESS_ID => 4, OrderTableMap::INVOICE_DATE => 5, OrderTableMap::CURRENCY_ID => 6, OrderTableMap::CURRENCY_RATE => 7, OrderTableMap::TRANSACTION_REF => 8, OrderTableMap::DELIVERY_REF => 9, OrderTableMap::INVOICE_REF => 10, OrderTableMap::DISCOUNT => 11, OrderTableMap::POSTAGE => 12, OrderTableMap::PAYMENT_MODULE_ID => 13, OrderTableMap::DELIVERY_MODULE_ID => 14, OrderTableMap::STATUS_ID => 15, OrderTableMap::LANG_ID => 16, OrderTableMap::CREATED_AT => 17, OrderTableMap::UPDATED_AT => 18, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CUSTOMER_ID' => 2, 'INVOICE_ORDER_ADDRESS_ID' => 3, 'DELIVERY_ORDER_ADDRESS_ID' => 4, 'INVOICE_DATE' => 5, 'CURRENCY_ID' => 6, 'CURRENCY_RATE' => 7, 'TRANSACTION_REF' => 8, 'DELIVERY_REF' => 9, 'INVOICE_REF' => 10, 'DISCOUNT' => 11, 'POSTAGE' => 12, 'PAYMENT_MODULE_ID' => 13, 'DELIVERY_MODULE_ID' => 14, 'STATUS_ID' => 15, 'LANG_ID' => 16, 'CREATED_AT' => 17, 'UPDATED_AT' => 18, ),
self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'customer_id' => 2, 'invoice_order_address_id' => 3, 'delivery_order_address_id' => 4, 'invoice_date' => 5, 'currency_id' => 6, 'currency_rate' => 7, 'transaction_ref' => 8, 'delivery_ref' => 9, 'invoice_ref' => 10, 'discount' => 11, 'postage' => 12, 'payment_module_id' => 13, 'delivery_module_id' => 14, 'status_id' => 15, 'lang_id' => 16, 'created_at' => 17, 'updated_at' => 18, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, )
self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'CustomerId' => 2, 'InvoiceOrderAddressId' => 3, 'DeliveryOrderAddressId' => 4, 'InvoiceDate' => 5, 'CurrencyId' => 6, 'CurrencyRate' => 7, 'TransactionRef' => 8, 'DeliveryRef' => 9, 'InvoiceRef' => 10, 'Discount' => 11, 'Postage' => 12, 'PaymentModuleId' => 13, 'DeliveryModuleId' => 14, 'StatusId' => 15, 'LangId' => 16, 'CreatedAt' => 17, 'UpdatedAt' => 18, 'Version' => 19, 'VersionCreatedAt' => 20, 'VersionCreatedBy' => 21, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'customerId' => 2, 'invoiceOrderAddressId' => 3, 'deliveryOrderAddressId' => 4, 'invoiceDate' => 5, 'currencyId' => 6, 'currencyRate' => 7, 'transactionRef' => 8, 'deliveryRef' => 9, 'invoiceRef' => 10, 'discount' => 11, 'postage' => 12, 'paymentModuleId' => 13, 'deliveryModuleId' => 14, 'statusId' => 15, 'langId' => 16, 'createdAt' => 17, 'updatedAt' => 18, 'version' => 19, 'versionCreatedAt' => 20, 'versionCreatedBy' => 21, ),
self::TYPE_COLNAME => array(OrderTableMap::ID => 0, OrderTableMap::REF => 1, OrderTableMap::CUSTOMER_ID => 2, OrderTableMap::INVOICE_ORDER_ADDRESS_ID => 3, OrderTableMap::DELIVERY_ORDER_ADDRESS_ID => 4, OrderTableMap::INVOICE_DATE => 5, OrderTableMap::CURRENCY_ID => 6, OrderTableMap::CURRENCY_RATE => 7, OrderTableMap::TRANSACTION_REF => 8, OrderTableMap::DELIVERY_REF => 9, OrderTableMap::INVOICE_REF => 10, OrderTableMap::DISCOUNT => 11, OrderTableMap::POSTAGE => 12, OrderTableMap::PAYMENT_MODULE_ID => 13, OrderTableMap::DELIVERY_MODULE_ID => 14, OrderTableMap::STATUS_ID => 15, OrderTableMap::LANG_ID => 16, OrderTableMap::CREATED_AT => 17, OrderTableMap::UPDATED_AT => 18, OrderTableMap::VERSION => 19, OrderTableMap::VERSION_CREATED_AT => 20, OrderTableMap::VERSION_CREATED_BY => 21, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CUSTOMER_ID' => 2, 'INVOICE_ORDER_ADDRESS_ID' => 3, 'DELIVERY_ORDER_ADDRESS_ID' => 4, 'INVOICE_DATE' => 5, 'CURRENCY_ID' => 6, 'CURRENCY_RATE' => 7, 'TRANSACTION_REF' => 8, 'DELIVERY_REF' => 9, 'INVOICE_REF' => 10, 'DISCOUNT' => 11, 'POSTAGE' => 12, 'PAYMENT_MODULE_ID' => 13, 'DELIVERY_MODULE_ID' => 14, 'STATUS_ID' => 15, 'LANG_ID' => 16, 'CREATED_AT' => 17, 'UPDATED_AT' => 18, 'VERSION' => 19, 'VERSION_CREATED_AT' => 20, 'VERSION_CREATED_BY' => 21, ),
self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'customer_id' => 2, 'invoice_order_address_id' => 3, 'delivery_order_address_id' => 4, 'invoice_date' => 5, 'currency_id' => 6, 'currency_rate' => 7, 'transaction_ref' => 8, 'delivery_ref' => 9, 'invoice_ref' => 10, 'discount' => 11, 'postage' => 12, 'payment_module_id' => 13, 'delivery_module_id' => 14, 'status_id' => 15, 'lang_id' => 16, 'created_at' => 17, 'updated_at' => 18, 'version' => 19, 'version_created_at' => 20, 'version_created_by' => 21, ),
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, )
);
/**
@@ -235,6 +250,9 @@ class OrderTableMap extends TableMap
$this->addForeignKey('LANG_ID', 'LangId', 'INTEGER', 'lang', 'ID', 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()
/**
@@ -252,6 +270,7 @@ class OrderTableMap extends TableMap
$this->addRelation('Lang', '\\Thelia\\Model\\Lang', RelationMap::MANY_TO_ONE, array('lang_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('OrderProduct', '\\Thelia\\Model\\OrderProduct', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'OrderProducts');
$this->addRelation('OrderCoupon', '\\Thelia\\Model\\OrderCoupon', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'OrderCoupons');
$this->addRelation('OrderVersion', '\\Thelia\\Model\\OrderVersion', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'OrderVersions');
} // buildRelations()
/**
@@ -264,6 +283,7 @@ class OrderTableMap extends TableMap
{
return array(
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
'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()
/**
@@ -275,6 +295,7 @@ class OrderTableMap extends TableMap
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
OrderProductTableMap::clearInstancePool();
OrderCouponTableMap::clearInstancePool();
OrderVersionTableMap::clearInstancePool();
}
/**
@@ -434,6 +455,9 @@ class OrderTableMap extends TableMap
$criteria->addSelectColumn(OrderTableMap::LANG_ID);
$criteria->addSelectColumn(OrderTableMap::CREATED_AT);
$criteria->addSelectColumn(OrderTableMap::UPDATED_AT);
$criteria->addSelectColumn(OrderTableMap::VERSION);
$criteria->addSelectColumn(OrderTableMap::VERSION_CREATED_AT);
$criteria->addSelectColumn(OrderTableMap::VERSION_CREATED_BY);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.REF');
@@ -454,6 +478,9 @@ class OrderTableMap extends TableMap
$criteria->addSelectColumn($alias . '.LANG_ID');
$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');
}
}

View File

@@ -0,0 +1,626 @@
<?php
namespace Thelia\Model\Map;
use Propel\Runtime\Propel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\InstancePoolTrait;
use Propel\Runtime\Connection\ConnectionInterface;
use Propel\Runtime\DataFetcher\DataFetcherInterface;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Map\RelationMap;
use Propel\Runtime\Map\TableMap;
use Propel\Runtime\Map\TableMapTrait;
use Thelia\Model\OrderVersion;
use Thelia\Model\OrderVersionQuery;
/**
* This class defines the structure of the 'order_version' table.
*
*
*
* This map class is used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
*/
class OrderVersionTableMap extends TableMap
{
use InstancePoolTrait;
use TableMapTrait;
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'Thelia.Model.Map.OrderVersionTableMap';
/**
* The default database name for this class
*/
const DATABASE_NAME = 'thelia';
/**
* The table name for this class
*/
const TABLE_NAME = 'order_version';
/**
* The related Propel class for this table
*/
const OM_CLASS = '\\Thelia\\Model\\OrderVersion';
/**
* A class that can be returned by this tableMap
*/
const CLASS_DEFAULT = 'Thelia.Model.OrderVersion';
/**
* The total number of columns
*/
const NUM_COLUMNS = 22;
/**
* The number of lazy-loaded columns
*/
const NUM_LAZY_LOAD_COLUMNS = 0;
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 22;
/**
* the column name for the ID field
*/
const ID = 'order_version.ID';
/**
* the column name for the REF field
*/
const REF = 'order_version.REF';
/**
* the column name for the CUSTOMER_ID field
*/
const CUSTOMER_ID = 'order_version.CUSTOMER_ID';
/**
* the column name for the INVOICE_ORDER_ADDRESS_ID field
*/
const INVOICE_ORDER_ADDRESS_ID = 'order_version.INVOICE_ORDER_ADDRESS_ID';
/**
* the column name for the DELIVERY_ORDER_ADDRESS_ID field
*/
const DELIVERY_ORDER_ADDRESS_ID = 'order_version.DELIVERY_ORDER_ADDRESS_ID';
/**
* the column name for the INVOICE_DATE field
*/
const INVOICE_DATE = 'order_version.INVOICE_DATE';
/**
* the column name for the CURRENCY_ID field
*/
const CURRENCY_ID = 'order_version.CURRENCY_ID';
/**
* the column name for the CURRENCY_RATE field
*/
const CURRENCY_RATE = 'order_version.CURRENCY_RATE';
/**
* the column name for the TRANSACTION_REF field
*/
const TRANSACTION_REF = 'order_version.TRANSACTION_REF';
/**
* the column name for the DELIVERY_REF field
*/
const DELIVERY_REF = 'order_version.DELIVERY_REF';
/**
* the column name for the INVOICE_REF field
*/
const INVOICE_REF = 'order_version.INVOICE_REF';
/**
* the column name for the DISCOUNT field
*/
const DISCOUNT = 'order_version.DISCOUNT';
/**
* the column name for the POSTAGE field
*/
const POSTAGE = 'order_version.POSTAGE';
/**
* the column name for the PAYMENT_MODULE_ID field
*/
const PAYMENT_MODULE_ID = 'order_version.PAYMENT_MODULE_ID';
/**
* the column name for the DELIVERY_MODULE_ID field
*/
const DELIVERY_MODULE_ID = 'order_version.DELIVERY_MODULE_ID';
/**
* the column name for the STATUS_ID field
*/
const STATUS_ID = 'order_version.STATUS_ID';
/**
* the column name for the LANG_ID field
*/
const LANG_ID = 'order_version.LANG_ID';
/**
* the column name for the CREATED_AT field
*/
const CREATED_AT = 'order_version.CREATED_AT';
/**
* the column name for the UPDATED_AT field
*/
const UPDATED_AT = 'order_version.UPDATED_AT';
/**
* the column name for the VERSION field
*/
const VERSION = 'order_version.VERSION';
/**
* the column name for the VERSION_CREATED_AT field
*/
const VERSION_CREATED_AT = 'order_version.VERSION_CREATED_AT';
/**
* the column name for the VERSION_CREATED_BY field
*/
const VERSION_CREATED_BY = 'order_version.VERSION_CREATED_BY';
/**
* The default string format for model objects of the related table
*/
const DEFAULT_STRING_FORMAT = 'YAML';
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'Ref', 'CustomerId', 'InvoiceOrderAddressId', 'DeliveryOrderAddressId', 'InvoiceDate', 'CurrencyId', 'CurrencyRate', 'TransactionRef', 'DeliveryRef', 'InvoiceRef', 'Discount', 'Postage', 'PaymentModuleId', 'DeliveryModuleId', 'StatusId', 'LangId', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ),
self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'customerId', 'invoiceOrderAddressId', 'deliveryOrderAddressId', 'invoiceDate', 'currencyId', 'currencyRate', 'transactionRef', 'deliveryRef', 'invoiceRef', 'discount', 'postage', 'paymentModuleId', 'deliveryModuleId', 'statusId', 'langId', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ),
self::TYPE_COLNAME => array(OrderVersionTableMap::ID, OrderVersionTableMap::REF, OrderVersionTableMap::CUSTOMER_ID, OrderVersionTableMap::INVOICE_ORDER_ADDRESS_ID, OrderVersionTableMap::DELIVERY_ORDER_ADDRESS_ID, OrderVersionTableMap::INVOICE_DATE, OrderVersionTableMap::CURRENCY_ID, OrderVersionTableMap::CURRENCY_RATE, OrderVersionTableMap::TRANSACTION_REF, OrderVersionTableMap::DELIVERY_REF, OrderVersionTableMap::INVOICE_REF, OrderVersionTableMap::DISCOUNT, OrderVersionTableMap::POSTAGE, OrderVersionTableMap::PAYMENT_MODULE_ID, OrderVersionTableMap::DELIVERY_MODULE_ID, OrderVersionTableMap::STATUS_ID, OrderVersionTableMap::LANG_ID, OrderVersionTableMap::CREATED_AT, OrderVersionTableMap::UPDATED_AT, OrderVersionTableMap::VERSION, OrderVersionTableMap::VERSION_CREATED_AT, OrderVersionTableMap::VERSION_CREATED_BY, ),
self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CUSTOMER_ID', 'INVOICE_ORDER_ADDRESS_ID', 'DELIVERY_ORDER_ADDRESS_ID', 'INVOICE_DATE', 'CURRENCY_ID', 'CURRENCY_RATE', 'TRANSACTION_REF', 'DELIVERY_REF', 'INVOICE_REF', 'DISCOUNT', 'POSTAGE', 'PAYMENT_MODULE_ID', 'DELIVERY_MODULE_ID', 'STATUS_ID', 'LANG_ID', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ),
self::TYPE_FIELDNAME => array('id', 'ref', 'customer_id', 'invoice_order_address_id', 'delivery_order_address_id', 'invoice_date', 'currency_id', 'currency_rate', 'transaction_ref', 'delivery_ref', 'invoice_ref', 'discount', 'postage', 'payment_module_id', 'delivery_module_id', 'status_id', 'lang_id', '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, 17, 18, 19, 20, 21, )
);
/**
* 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, 'InvoiceOrderAddressId' => 3, 'DeliveryOrderAddressId' => 4, 'InvoiceDate' => 5, 'CurrencyId' => 6, 'CurrencyRate' => 7, 'TransactionRef' => 8, 'DeliveryRef' => 9, 'InvoiceRef' => 10, 'Discount' => 11, 'Postage' => 12, 'PaymentModuleId' => 13, 'DeliveryModuleId' => 14, 'StatusId' => 15, 'LangId' => 16, 'CreatedAt' => 17, 'UpdatedAt' => 18, 'Version' => 19, 'VersionCreatedAt' => 20, 'VersionCreatedBy' => 21, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'customerId' => 2, 'invoiceOrderAddressId' => 3, 'deliveryOrderAddressId' => 4, 'invoiceDate' => 5, 'currencyId' => 6, 'currencyRate' => 7, 'transactionRef' => 8, 'deliveryRef' => 9, 'invoiceRef' => 10, 'discount' => 11, 'postage' => 12, 'paymentModuleId' => 13, 'deliveryModuleId' => 14, 'statusId' => 15, 'langId' => 16, 'createdAt' => 17, 'updatedAt' => 18, 'version' => 19, 'versionCreatedAt' => 20, 'versionCreatedBy' => 21, ),
self::TYPE_COLNAME => array(OrderVersionTableMap::ID => 0, OrderVersionTableMap::REF => 1, OrderVersionTableMap::CUSTOMER_ID => 2, OrderVersionTableMap::INVOICE_ORDER_ADDRESS_ID => 3, OrderVersionTableMap::DELIVERY_ORDER_ADDRESS_ID => 4, OrderVersionTableMap::INVOICE_DATE => 5, OrderVersionTableMap::CURRENCY_ID => 6, OrderVersionTableMap::CURRENCY_RATE => 7, OrderVersionTableMap::TRANSACTION_REF => 8, OrderVersionTableMap::DELIVERY_REF => 9, OrderVersionTableMap::INVOICE_REF => 10, OrderVersionTableMap::DISCOUNT => 11, OrderVersionTableMap::POSTAGE => 12, OrderVersionTableMap::PAYMENT_MODULE_ID => 13, OrderVersionTableMap::DELIVERY_MODULE_ID => 14, OrderVersionTableMap::STATUS_ID => 15, OrderVersionTableMap::LANG_ID => 16, OrderVersionTableMap::CREATED_AT => 17, OrderVersionTableMap::UPDATED_AT => 18, OrderVersionTableMap::VERSION => 19, OrderVersionTableMap::VERSION_CREATED_AT => 20, OrderVersionTableMap::VERSION_CREATED_BY => 21, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CUSTOMER_ID' => 2, 'INVOICE_ORDER_ADDRESS_ID' => 3, 'DELIVERY_ORDER_ADDRESS_ID' => 4, 'INVOICE_DATE' => 5, 'CURRENCY_ID' => 6, 'CURRENCY_RATE' => 7, 'TRANSACTION_REF' => 8, 'DELIVERY_REF' => 9, 'INVOICE_REF' => 10, 'DISCOUNT' => 11, 'POSTAGE' => 12, 'PAYMENT_MODULE_ID' => 13, 'DELIVERY_MODULE_ID' => 14, 'STATUS_ID' => 15, 'LANG_ID' => 16, 'CREATED_AT' => 17, 'UPDATED_AT' => 18, 'VERSION' => 19, 'VERSION_CREATED_AT' => 20, 'VERSION_CREATED_BY' => 21, ),
self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'customer_id' => 2, 'invoice_order_address_id' => 3, 'delivery_order_address_id' => 4, 'invoice_date' => 5, 'currency_id' => 6, 'currency_rate' => 7, 'transaction_ref' => 8, 'delivery_ref' => 9, 'invoice_ref' => 10, 'discount' => 11, 'postage' => 12, 'payment_module_id' => 13, 'delivery_module_id' => 14, 'status_id' => 15, 'lang_id' => 16, 'created_at' => 17, 'updated_at' => 18, 'version' => 19, 'version_created_at' => 20, 'version_created_by' => 21, ),
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, )
);
/**
* 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_version');
$this->setPhpName('OrderVersion');
$this->setClassName('\\Thelia\\Model\\OrderVersion');
$this->setPackage('Thelia.Model');
$this->setUseIdGenerator(false);
// columns
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order', 'ID', true, null, null);
$this->addColumn('REF', 'Ref', 'VARCHAR', false, 45, null);
$this->addColumn('CUSTOMER_ID', 'CustomerId', 'INTEGER', true, null, null);
$this->addColumn('INVOICE_ORDER_ADDRESS_ID', 'InvoiceOrderAddressId', 'INTEGER', true, null, null);
$this->addColumn('DELIVERY_ORDER_ADDRESS_ID', 'DeliveryOrderAddressId', 'INTEGER', true, null, null);
$this->addColumn('INVOICE_DATE', 'InvoiceDate', 'DATE', false, null, null);
$this->addColumn('CURRENCY_ID', 'CurrencyId', 'INTEGER', true, null, null);
$this->addColumn('CURRENCY_RATE', 'CurrencyRate', 'FLOAT', true, null, null);
$this->addColumn('TRANSACTION_REF', 'TransactionRef', 'VARCHAR', false, 100, null);
$this->addColumn('DELIVERY_REF', 'DeliveryRef', 'VARCHAR', false, 100, null);
$this->addColumn('INVOICE_REF', 'InvoiceRef', 'VARCHAR', false, 100, null);
$this->addColumn('DISCOUNT', 'Discount', 'FLOAT', false, null, null);
$this->addColumn('POSTAGE', 'Postage', 'FLOAT', true, null, null);
$this->addColumn('PAYMENT_MODULE_ID', 'PaymentModuleId', 'INTEGER', true, null, null);
$this->addColumn('DELIVERY_MODULE_ID', 'DeliveryModuleId', 'INTEGER', true, null, null);
$this->addColumn('STATUS_ID', 'StatusId', 'INTEGER', true, null, null);
$this->addColumn('LANG_ID', 'LangId', '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('Order', '\\Thelia\\Model\\Order', 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\OrderVersion $obj A \Thelia\Model\OrderVersion 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\OrderVersion object or a primary key value.
*/
public static function removeInstanceFromPool($value)
{
if (Propel::isInstancePoolingEnabled() && null !== $value) {
if (is_object($value) && $value instanceof \Thelia\Model\OrderVersion) {
$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\OrderVersion 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 ? 19 + $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 ? 19 + $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 ? OrderVersionTableMap::CLASS_DEFAULT : OrderVersionTableMap::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 (OrderVersion object, last column rank)
*/
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM)
{
$key = OrderVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType);
if (null !== ($obj = OrderVersionTableMap::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 + OrderVersionTableMap::NUM_HYDRATE_COLUMNS;
} else {
$cls = OrderVersionTableMap::OM_CLASS;
$obj = new $cls();
$col = $obj->hydrate($row, $offset, false, $indexType);
OrderVersionTableMap::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 = OrderVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType());
if (null !== ($obj = OrderVersionTableMap::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;
OrderVersionTableMap::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(OrderVersionTableMap::ID);
$criteria->addSelectColumn(OrderVersionTableMap::REF);
$criteria->addSelectColumn(OrderVersionTableMap::CUSTOMER_ID);
$criteria->addSelectColumn(OrderVersionTableMap::INVOICE_ORDER_ADDRESS_ID);
$criteria->addSelectColumn(OrderVersionTableMap::DELIVERY_ORDER_ADDRESS_ID);
$criteria->addSelectColumn(OrderVersionTableMap::INVOICE_DATE);
$criteria->addSelectColumn(OrderVersionTableMap::CURRENCY_ID);
$criteria->addSelectColumn(OrderVersionTableMap::CURRENCY_RATE);
$criteria->addSelectColumn(OrderVersionTableMap::TRANSACTION_REF);
$criteria->addSelectColumn(OrderVersionTableMap::DELIVERY_REF);
$criteria->addSelectColumn(OrderVersionTableMap::INVOICE_REF);
$criteria->addSelectColumn(OrderVersionTableMap::DISCOUNT);
$criteria->addSelectColumn(OrderVersionTableMap::POSTAGE);
$criteria->addSelectColumn(OrderVersionTableMap::PAYMENT_MODULE_ID);
$criteria->addSelectColumn(OrderVersionTableMap::DELIVERY_MODULE_ID);
$criteria->addSelectColumn(OrderVersionTableMap::STATUS_ID);
$criteria->addSelectColumn(OrderVersionTableMap::LANG_ID);
$criteria->addSelectColumn(OrderVersionTableMap::CREATED_AT);
$criteria->addSelectColumn(OrderVersionTableMap::UPDATED_AT);
$criteria->addSelectColumn(OrderVersionTableMap::VERSION);
$criteria->addSelectColumn(OrderVersionTableMap::VERSION_CREATED_AT);
$criteria->addSelectColumn(OrderVersionTableMap::VERSION_CREATED_BY);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.REF');
$criteria->addSelectColumn($alias . '.CUSTOMER_ID');
$criteria->addSelectColumn($alias . '.INVOICE_ORDER_ADDRESS_ID');
$criteria->addSelectColumn($alias . '.DELIVERY_ORDER_ADDRESS_ID');
$criteria->addSelectColumn($alias . '.INVOICE_DATE');
$criteria->addSelectColumn($alias . '.CURRENCY_ID');
$criteria->addSelectColumn($alias . '.CURRENCY_RATE');
$criteria->addSelectColumn($alias . '.TRANSACTION_REF');
$criteria->addSelectColumn($alias . '.DELIVERY_REF');
$criteria->addSelectColumn($alias . '.INVOICE_REF');
$criteria->addSelectColumn($alias . '.DISCOUNT');
$criteria->addSelectColumn($alias . '.POSTAGE');
$criteria->addSelectColumn($alias . '.PAYMENT_MODULE_ID');
$criteria->addSelectColumn($alias . '.DELIVERY_MODULE_ID');
$criteria->addSelectColumn($alias . '.STATUS_ID');
$criteria->addSelectColumn($alias . '.LANG_ID');
$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(OrderVersionTableMap::DATABASE_NAME)->getTable(OrderVersionTableMap::TABLE_NAME);
}
/**
* Add a TableMap instance to the database for this tableMap class.
*/
public static function buildTableMap()
{
$dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderVersionTableMap::DATABASE_NAME);
if (!$dbMap->hasTable(OrderVersionTableMap::TABLE_NAME)) {
$dbMap->addTableObject(new OrderVersionTableMap());
}
}
/**
* Performs a DELETE on the database, given a OrderVersion or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or OrderVersion 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(OrderVersionTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \Thelia\Model\OrderVersion) { // 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(OrderVersionTableMap::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(OrderVersionTableMap::ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(OrderVersionTableMap::VERSION, $value[1]));
$criteria->addOr($criterion);
}
}
$query = OrderVersionQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { OrderVersionTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { OrderVersionTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
/**
* Deletes all rows from the order_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 OrderVersionQuery::create()->doDeleteAll($con);
}
/**
* Performs an INSERT on the database, given a OrderVersion or Criteria object.
*
* @param mixed $criteria Criteria or OrderVersion 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(OrderVersionTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from OrderVersion object
}
// Set the correct dbName
$query = OrderVersionQuery::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;
}
} // OrderVersionTableMap
// This is the static code needed to register the TableMap for this table with the main Propel class.
//
OrderVersionTableMap::buildTableMap();

View File

@@ -17,6 +17,8 @@ class Order extends BaseOrder
protected $choosenDeliveryAddress = null;
protected $choosenInvoiceAddress = null;
protected $disableVersioning = false;
/**
* @param null $choosenDeliveryAddress
*/
@@ -27,6 +29,30 @@ class Order extends BaseOrder
return $this;
}
/**
* @param boolean $disableVersionning
*/
public function setDisableVersioning($disableVersioning)
{
$this->disableVersioning = (bool) $disableVersioning;
return $this;
}
public function isVersioningDisable()
{
return $this->disableVersioning;
}
public function isVersioningNecessary($con = null)
{
if ($this->isVersioningDisable()) {
return false;
} else {
return parent::isVersioningNecessary($con);
}
}
/**
* @return null
*/
@@ -69,6 +95,7 @@ class Order extends BaseOrder
public function postInsert(ConnectionInterface $con = null)
{
$this->setRef($this->generateRef())
->setDisableVersioning(true)
->save($con);
$this->dispatchEvent(TheliaEvents::ORDER_AFTER_CREATE, new OrderEvent($this));
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\OrderVersion as BaseOrderVersion;
class OrderVersion extends BaseOrderVersion
{
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Thelia\Model;
use Thelia\Model\Base\OrderVersionQuery as BaseOrderVersionQuery;
/**
* Skeleton subclass for performing query and update operations on the 'order_version' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class OrderVersionQuery extends BaseOrderVersionQuery
{
} // OrderVersionQuery

View File

@@ -622,6 +622,10 @@
<index-column name="lang_id" />
</index>
<behavior name="timestampable" />
<behavior name="versionable">
<parameter name="log_created_at" value="true" />
<parameter name="log_created_by" value="true" />
</behavior>
</table>
<table name="currency" namespace="Thelia\Model">
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />

View File

@@ -669,6 +669,9 @@ CREATE TABLE `order`
`lang_id` INTEGER NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
PRIMARY KEY (`id`),
UNIQUE INDEX `ref_UNIQUE` (`ref`),
INDEX `idx_order_currency_id` (`currency_id`),
@@ -2484,6 +2487,43 @@ CREATE TABLE `content_version`
ON DELETE CASCADE
) ENGINE=InnoDB CHARACTER SET='utf8';
-- ---------------------------------------------------------------------
-- order_version
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `order_version`;
CREATE TABLE `order_version`
(
`id` INTEGER NOT NULL,
`ref` VARCHAR(45),
`customer_id` INTEGER NOT NULL,
`invoice_order_address_id` INTEGER NOT NULL,
`delivery_order_address_id` INTEGER NOT NULL,
`invoice_date` DATE,
`currency_id` INTEGER NOT NULL,
`currency_rate` FLOAT NOT NULL,
`transaction_ref` VARCHAR(100) COMMENT 'transaction reference - usually use to identify a transaction with banking modules',
`delivery_ref` VARCHAR(100) COMMENT 'delivery reference - usually use to identify a delivery progress on a distant delivery tracker website',
`invoice_ref` VARCHAR(100) COMMENT 'the invoice reference',
`discount` FLOAT,
`postage` FLOAT NOT NULL,
`payment_module_id` INTEGER NOT NULL,
`delivery_module_id` INTEGER NOT NULL,
`status_id` INTEGER NOT NULL,
`lang_id` INTEGER NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0 NOT NULL,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
PRIMARY KEY (`id`,`version`),
CONSTRAINT `order_version_FK_1`
FOREIGN KEY (`id`)
REFERENCES `order` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB CHARACTER SET='utf8';
-- ---------------------------------------------------------------------
-- message_version
-- ---------------------------------------------------------------------

48
setup/update/2.0.3.sql Normal file
View File

@@ -0,0 +1,48 @@
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
UPDATE `config` SET `value`='2.0.3' WHERE `name`='thelia_version';
UPDATE `config` SET `value`='3' WHERE `name`='thelia_release_version';
UPDATE `config` SET `value`='' WHERE `name`='thelia_extra_version';
# Add new column to order (version, version_created_at, version_created_by)
ALTER TABLE `order` ADD `version` INT DEFAULT 0 AFTER `updated_at`;
ALTER TABLE `order` ADD `version_created_at` DATE AFTER `version`;
ALTER TABLE `order` ADD `version_created_by` VARCHAR(100) AFTER `version_created_at`;
DROP TABLE IF EXISTS `order_version`;
CREATE TABLE `order_version`
(
`id` INTEGER NOT NULL,
`ref` VARCHAR(45),
`customer_id` INTEGER NOT NULL,
`invoice_order_address_id` INTEGER NOT NULL,
`delivery_order_address_id` INTEGER NOT NULL,
`invoice_date` DATE,
`currency_id` INTEGER NOT NULL,
`currency_rate` FLOAT NOT NULL,
`transaction_ref` VARCHAR(100) COMMENT 'transaction reference - usually use to identify a transaction with banking modules',
`delivery_ref` VARCHAR(100) COMMENT 'delivery reference - usually use to identify a delivery progress on a distant delivery tracker website',
`invoice_ref` VARCHAR(100) COMMENT 'the invoice reference',
`discount` FLOAT,
`postage` FLOAT NOT NULL,
`payment_module_id` INTEGER NOT NULL,
`delivery_module_id` INTEGER NOT NULL,
`status_id` INTEGER NOT NULL,
`lang_id` INTEGER NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0 NOT NULL,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
PRIMARY KEY (`id`,`version`),
CONSTRAINT `order_version_FK_1`
FOREIGN KEY (`id`)
REFERENCES `order` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB CHARACTER SET='utf8';
SET FOREIGN_KEY_CHECKS = 1;