From 2c52df1034a514440a644cf568ef0adf17b487f5 Mon Sep 17 00:00:00 2001 From: franck Date: Thu, 18 Jul 2013 09:40:21 +0200 Subject: [PATCH] Added title_id column in customer table --- .../Thelia/Core/Template/ParserContext.php | 9 +- core/lib/Thelia/Model/Base/Customer.php | 248 ++++++++++++---- core/lib/Thelia/Model/Base/CustomerQuery.php | 128 +++++++- core/lib/Thelia/Model/Base/CustomerTitle.php | 273 ++++++++++++++++++ .../Thelia/Model/Base/CustomerTitleQuery.php | 77 +++++ core/lib/Thelia/Model/Customer.php | 1 + .../lib/Thelia/Model/Map/CustomerTableMap.php | 37 ++- .../Model/Map/CustomerTitleTableMap.php | 1 + local/config/schema.xml | 4 + 9 files changed, 706 insertions(+), 72 deletions(-) diff --git a/core/lib/Thelia/Core/Template/ParserContext.php b/core/lib/Thelia/Core/Template/ParserContext.php index e5d635fda..b1574d156 100644 --- a/core/lib/Thelia/Core/Template/ParserContext.php +++ b/core/lib/Thelia/Core/Template/ParserContext.php @@ -46,17 +46,20 @@ class ParserContext implements \IteratorAggregate ; } - public function set($name, $value) { + public function set($name, $value) + { $this->store[$name] = $value; return $this; } - public function get($name) { + public function get($name) + { return $this->store[$name]; } - public function getIterator() { + public function getIterator() + { return new \ArrayIterator( $this->store ); } } diff --git a/core/lib/Thelia/Model/Base/Customer.php b/core/lib/Thelia/Model/Base/Customer.php index b8b3b1f32..71708ab1b 100755 --- a/core/lib/Thelia/Model/Base/Customer.php +++ b/core/lib/Thelia/Model/Base/Customer.php @@ -21,6 +21,8 @@ use Thelia\Model\Address as ChildAddress; use Thelia\Model\AddressQuery as ChildAddressQuery; use Thelia\Model\Customer as ChildCustomer; use Thelia\Model\CustomerQuery as ChildCustomerQuery; +use Thelia\Model\CustomerTitle as ChildCustomerTitle; +use Thelia\Model\CustomerTitleQuery as ChildCustomerTitleQuery; use Thelia\Model\Order as ChildOrder; use Thelia\Model\OrderQuery as ChildOrderQuery; use Thelia\Model\Map\CustomerTableMap; @@ -71,6 +73,12 @@ abstract class Customer implements ActiveRecordInterface */ protected $ref; + /** + * The value for the title_id field. + * @var int + */ + protected $title_id; + /** * The value for the firstname field. * @var string @@ -137,6 +145,11 @@ abstract class Customer implements ActiveRecordInterface */ protected $updated_at; + /** + * @var CustomerTitle + */ + protected $aCustomerTitle; + /** * @var ObjectCollection|ChildAddress[] Collection to store aggregation of ChildAddress objects. */ @@ -445,6 +458,17 @@ abstract class Customer implements ActiveRecordInterface return $this->ref; } + /** + * Get the [title_id] column value. + * + * @return int + */ + public function getTitleId() + { + + return $this->title_id; + } + /** * Get the [firstname] column value. * @@ -626,6 +650,31 @@ abstract class Customer implements ActiveRecordInterface return $this; } // setRef() + /** + * Set the value of [title_id] column. + * + * @param int $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) + */ + public function setTitleId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->title_id !== $v) { + $this->title_id = $v; + $this->modifiedColumns[] = CustomerTableMap::TITLE_ID; + } + + if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) { + $this->aCustomerTitle = null; + } + + + return $this; + } // setTitleId() + /** * Set the value of [firstname] column. * @@ -900,40 +949,43 @@ abstract class Customer implements ActiveRecordInterface $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('Firstname', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerTableMap::translateFieldName('TitleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)]; $this->firstname = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)]; $this->lastname = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CustomerTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)]; $this->email = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CustomerTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CustomerTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)]; $this->password = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CustomerTableMap::translateFieldName('Algo', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CustomerTableMap::translateFieldName('Algo', TableMap::TYPE_PHPNAME, $indexType)]; $this->algo = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CustomerTableMap::translateFieldName('Reseller', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CustomerTableMap::translateFieldName('Reseller', TableMap::TYPE_PHPNAME, $indexType)]; $this->reseller = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CustomerTableMap::translateFieldName('Lang', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CustomerTableMap::translateFieldName('Lang', TableMap::TYPE_PHPNAME, $indexType)]; $this->lang = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CustomerTableMap::translateFieldName('Sponsor', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CustomerTableMap::translateFieldName('Sponsor', TableMap::TYPE_PHPNAME, $indexType)]; $this->sponsor = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CustomerTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CustomerTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)]; $this->discount = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CustomerTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $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 ? 12 + $startcol : CustomerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CustomerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -946,7 +998,7 @@ abstract class Customer implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 13; // 13 = CustomerTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 14; // 14 = CustomerTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Customer object", 0, $e); @@ -968,6 +1020,9 @@ abstract class Customer implements ActiveRecordInterface */ public function ensureConsistency() { + if ($this->aCustomerTitle !== null && $this->title_id !== $this->aCustomerTitle->getId()) { + $this->aCustomerTitle = null; + } } // ensureConsistency /** @@ -1007,6 +1062,7 @@ abstract class Customer implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? + $this->aCustomerTitle = null; $this->collAddresses = null; $this->collOrders = null; @@ -1133,6 +1189,18 @@ abstract class Customer implements ActiveRecordInterface 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()) { @@ -1210,6 +1278,9 @@ abstract class Customer implements ActiveRecordInterface if ($this->isColumnModified(CustomerTableMap::REF)) { $modifiedColumns[':p' . $index++] = 'REF'; } + if ($this->isColumnModified(CustomerTableMap::TITLE_ID)) { + $modifiedColumns[':p' . $index++] = 'TITLE_ID'; + } if ($this->isColumnModified(CustomerTableMap::FIRSTNAME)) { $modifiedColumns[':p' . $index++] = 'FIRSTNAME'; } @@ -1260,6 +1331,9 @@ abstract class Customer implements ActiveRecordInterface case 'REF': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; + case 'TITLE_ID': + $stmt->bindValue($identifier, $this->title_id, PDO::PARAM_INT); + break; case 'FIRSTNAME': $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); break; @@ -1362,36 +1436,39 @@ abstract class Customer implements ActiveRecordInterface return $this->getRef(); break; case 2: - return $this->getFirstname(); + return $this->getTitleId(); break; case 3: - return $this->getLastname(); + return $this->getFirstname(); break; case 4: - return $this->getEmail(); + return $this->getLastname(); break; case 5: - return $this->getPassword(); + return $this->getEmail(); break; case 6: - return $this->getAlgo(); + return $this->getPassword(); break; case 7: - return $this->getReseller(); + return $this->getAlgo(); break; case 8: - return $this->getLang(); + return $this->getReseller(); break; case 9: - return $this->getSponsor(); + return $this->getLang(); break; case 10: - return $this->getDiscount(); + return $this->getSponsor(); break; case 11: - return $this->getCreatedAt(); + return $this->getDiscount(); break; case 12: + return $this->getCreatedAt(); + break; + case 13: return $this->getUpdatedAt(); break; default: @@ -1425,17 +1502,18 @@ abstract class Customer implements ActiveRecordInterface $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getRef(), - $keys[2] => $this->getFirstname(), - $keys[3] => $this->getLastname(), - $keys[4] => $this->getEmail(), - $keys[5] => $this->getPassword(), - $keys[6] => $this->getAlgo(), - $keys[7] => $this->getReseller(), - $keys[8] => $this->getLang(), - $keys[9] => $this->getSponsor(), - $keys[10] => $this->getDiscount(), - $keys[11] => $this->getCreatedAt(), - $keys[12] => $this->getUpdatedAt(), + $keys[2] => $this->getTitleId(), + $keys[3] => $this->getFirstname(), + $keys[4] => $this->getLastname(), + $keys[5] => $this->getEmail(), + $keys[6] => $this->getPassword(), + $keys[7] => $this->getAlgo(), + $keys[8] => $this->getReseller(), + $keys[9] => $this->getLang(), + $keys[10] => $this->getSponsor(), + $keys[11] => $this->getDiscount(), + $keys[12] => $this->getCreatedAt(), + $keys[13] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1444,6 +1522,9 @@ abstract class Customer implements ActiveRecordInterface } 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); } @@ -1491,36 +1572,39 @@ abstract class Customer implements ActiveRecordInterface $this->setRef($value); break; case 2: - $this->setFirstname($value); + $this->setTitleId($value); break; case 3: - $this->setLastname($value); + $this->setFirstname($value); break; case 4: - $this->setEmail($value); + $this->setLastname($value); break; case 5: - $this->setPassword($value); + $this->setEmail($value); break; case 6: - $this->setAlgo($value); + $this->setPassword($value); break; case 7: - $this->setReseller($value); + $this->setAlgo($value); break; case 8: - $this->setLang($value); + $this->setReseller($value); break; case 9: - $this->setSponsor($value); + $this->setLang($value); break; case 10: - $this->setDiscount($value); + $this->setSponsor($value); break; case 11: - $this->setCreatedAt($value); + $this->setDiscount($value); break; case 12: + $this->setCreatedAt($value); + break; + case 13: $this->setUpdatedAt($value); break; } // switch() @@ -1549,17 +1633,18 @@ abstract class Customer implements ActiveRecordInterface 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->setFirstname($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setLastname($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setEmail($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPassword($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setAlgo($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setReseller($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setLang($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setSponsor($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setDiscount($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setCreatedAt($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setUpdatedAt($arr[$keys[12]]); + if (array_key_exists($keys[2], $arr)) $this->setTitleId($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->setEmail($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setPassword($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setAlgo($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setReseller($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setLang($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setSponsor($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setDiscount($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]]); } /** @@ -1573,6 +1658,7 @@ abstract class Customer implements ActiveRecordInterface 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::TITLE_ID)) $criteria->add(CustomerTableMap::TITLE_ID, $this->title_id); 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::EMAIL)) $criteria->add(CustomerTableMap::EMAIL, $this->email); @@ -1648,6 +1734,7 @@ abstract class Customer implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setRef($this->getRef()); + $copyObj->setTitleId($this->getTitleId()); $copyObj->setFirstname($this->getFirstname()); $copyObj->setLastname($this->getLastname()); $copyObj->setEmail($this->getEmail()); @@ -1707,6 +1794,57 @@ abstract class Customer implements ActiveRecordInterface 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->setTitleId(NULL); + } else { + $this->setTitleId($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->title_id !== null)) { + $this->aCustomerTitle = ChildCustomerTitleQuery::create()->findPk($this->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. @@ -2294,6 +2432,7 @@ abstract class Customer implements ActiveRecordInterface { $this->id = null; $this->ref = null; + $this->title_id = null; $this->firstname = null; $this->lastname = null; $this->email = null; @@ -2344,6 +2483,7 @@ abstract class Customer implements ActiveRecordInterface $this->collOrders->clearIterator(); } $this->collOrders = null; + $this->aCustomerTitle = null; } /** diff --git a/core/lib/Thelia/Model/Base/CustomerQuery.php b/core/lib/Thelia/Model/Base/CustomerQuery.php index 3997cd0b6..16fa65016 100755 --- a/core/lib/Thelia/Model/Base/CustomerQuery.php +++ b/core/lib/Thelia/Model/Base/CustomerQuery.php @@ -23,6 +23,7 @@ use Thelia\Model\Map\CustomerTableMap; * * @method ChildCustomerQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildCustomerQuery orderByRef($order = Criteria::ASC) Order by the ref column + * @method ChildCustomerQuery orderByTitleId($order = Criteria::ASC) Order by the title_id column * @method ChildCustomerQuery orderByFirstname($order = Criteria::ASC) Order by the firstname column * @method ChildCustomerQuery orderByLastname($order = Criteria::ASC) Order by the lastname column * @method ChildCustomerQuery orderByEmail($order = Criteria::ASC) Order by the email column @@ -37,6 +38,7 @@ use Thelia\Model\Map\CustomerTableMap; * * @method ChildCustomerQuery groupById() Group by the id column * @method ChildCustomerQuery groupByRef() Group by the ref column + * @method ChildCustomerQuery groupByTitleId() Group by the title_id column * @method ChildCustomerQuery groupByFirstname() Group by the firstname column * @method ChildCustomerQuery groupByLastname() Group by the lastname column * @method ChildCustomerQuery groupByEmail() Group by the email column @@ -53,6 +55,10 @@ use Thelia\Model\Map\CustomerTableMap; * @method ChildCustomerQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildCustomerQuery innerJoin($relation) Adds a INNER JOIN clause to the query * + * @method ChildCustomerQuery leftJoinCustomerTitle($relationAlias = null) Adds a LEFT JOIN clause to the query using the CustomerTitle relation + * @method ChildCustomerQuery rightJoinCustomerTitle($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CustomerTitle relation + * @method ChildCustomerQuery innerJoinCustomerTitle($relationAlias = null) Adds a INNER JOIN clause to the query using the CustomerTitle relation + * * @method ChildCustomerQuery leftJoinAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the Address relation * @method ChildCustomerQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation * @method ChildCustomerQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation @@ -66,6 +72,7 @@ use Thelia\Model\Map\CustomerTableMap; * * @method ChildCustomer findOneById(int $id) Return the first ChildCustomer filtered by the id column * @method ChildCustomer findOneByRef(string $ref) Return the first ChildCustomer filtered by the ref column + * @method ChildCustomer findOneByTitleId(int $title_id) Return the first ChildCustomer filtered by the title_id column * @method ChildCustomer findOneByFirstname(string $firstname) Return the first ChildCustomer filtered by the firstname column * @method ChildCustomer findOneByLastname(string $lastname) Return the first ChildCustomer filtered by the lastname column * @method ChildCustomer findOneByEmail(string $email) Return the first ChildCustomer filtered by the email column @@ -80,6 +87,7 @@ use Thelia\Model\Map\CustomerTableMap; * * @method array findById(int $id) Return ChildCustomer objects filtered by the id column * @method array findByRef(string $ref) Return ChildCustomer objects filtered by the ref column + * @method array findByTitleId(int $title_id) Return ChildCustomer objects filtered by the title_id column * @method array findByFirstname(string $firstname) Return ChildCustomer objects filtered by the firstname column * @method array findByLastname(string $lastname) Return ChildCustomer objects filtered by the lastname column * @method array findByEmail(string $email) Return ChildCustomer objects filtered by the email column @@ -179,7 +187,7 @@ abstract class CustomerQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, REF, FIRSTNAME, LASTNAME, EMAIL, PASSWORD, ALGO, RESELLER, LANG, SPONSOR, DISCOUNT, CREATED_AT, UPDATED_AT FROM customer WHERE ID = :p0'; + $sql = 'SELECT ID, REF, TITLE_ID, FIRSTNAME, LASTNAME, EMAIL, PASSWORD, ALGO, 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); @@ -338,6 +346,49 @@ abstract class CustomerQuery extends ModelCriteria return $this->addUsingAlias(CustomerTableMap::REF, $ref, $comparison); } + /** + * Filter the query on the title_id column + * + * Example usage: + * + * $query->filterByTitleId(1234); // WHERE title_id = 1234 + * $query->filterByTitleId(array(12, 34)); // WHERE title_id IN (12, 34) + * $query->filterByTitleId(array('min' => 12)); // WHERE title_id > 12 + * + * + * @see filterByCustomerTitle() + * + * @param mixed $titleId 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 filterByTitleId($titleId = null, $comparison = null) + { + if (is_array($titleId)) { + $useMinMax = false; + if (isset($titleId['min'])) { + $this->addUsingAlias(CustomerTableMap::TITLE_ID, $titleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($titleId['max'])) { + $this->addUsingAlias(CustomerTableMap::TITLE_ID, $titleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CustomerTableMap::TITLE_ID, $titleId, $comparison); + } + /** * Filter the query on the firstname column * @@ -709,6 +760,81 @@ abstract class CustomerQuery extends ModelCriteria 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::TITLE_ID, $customerTitle->getId(), $comparison); + } elseif ($customerTitle instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CustomerTableMap::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 * diff --git a/core/lib/Thelia/Model/Base/CustomerTitle.php b/core/lib/Thelia/Model/Base/CustomerTitle.php index 459940747..d126839d0 100755 --- a/core/lib/Thelia/Model/Base/CustomerTitle.php +++ b/core/lib/Thelia/Model/Base/CustomerTitle.php @@ -19,6 +19,8 @@ use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Address as ChildAddress; use Thelia\Model\AddressQuery as ChildAddressQuery; +use Thelia\Model\Customer as ChildCustomer; +use Thelia\Model\CustomerQuery as ChildCustomerQuery; use Thelia\Model\CustomerTitle as ChildCustomerTitle; use Thelia\Model\CustomerTitleI18n as ChildCustomerTitleI18n; use Thelia\Model\CustomerTitleI18nQuery as ChildCustomerTitleI18nQuery; @@ -90,6 +92,12 @@ abstract class CustomerTitle implements ActiveRecordInterface */ protected $updated_at; + /** + * @var ObjectCollection|ChildCustomer[] Collection to store aggregation of ChildCustomer objects. + */ + protected $collCustomers; + protected $collCustomersPartial; + /** * @var ObjectCollection|ChildAddress[] Collection to store aggregation of ChildAddress objects. */ @@ -124,6 +132,12 @@ abstract class CustomerTitle implements ActiveRecordInterface */ protected $currentTranslations; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $customersScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -711,6 +725,8 @@ abstract class CustomerTitle implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? + $this->collCustomers = null; + $this->collAddresses = null; $this->collCustomerTitleI18ns = null; @@ -848,6 +864,24 @@ abstract class CustomerTitle implements ActiveRecordInterface $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) { @@ -1069,6 +1103,9 @@ abstract class CustomerTitle implements ActiveRecordInterface } 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); } @@ -1242,6 +1279,12 @@ abstract class CustomerTitle implements ActiveRecordInterface // 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)); @@ -1295,6 +1338,9 @@ abstract class CustomerTitle implements ActiveRecordInterface */ public function initRelation($relationName) { + if ('Customer' == $relationName) { + return $this->initCustomers(); + } if ('Address' == $relationName) { return $this->initAddresses(); } @@ -1303,6 +1349,224 @@ abstract class CustomerTitle implements ActiveRecordInterface } } + /** + * 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 * @@ -1801,6 +2065,11 @@ abstract class CustomerTitle implements ActiveRecordInterface 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); @@ -1817,6 +2086,10 @@ abstract class CustomerTitle implements ActiveRecordInterface $this->currentLocale = 'en_US'; $this->currentTranslations = null; + if ($this->collCustomers instanceof Collection) { + $this->collCustomers->clearIterator(); + } + $this->collCustomers = null; if ($this->collAddresses instanceof Collection) { $this->collAddresses->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php index 95b2a8326..42ba4bd98 100755 --- a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php +++ b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php @@ -38,6 +38,10 @@ use Thelia\Model\Map\CustomerTitleTableMap; * @method ChildCustomerTitleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildCustomerTitleQuery innerJoin($relation) Adds a INNER JOIN clause to the query * + * @method ChildCustomerTitleQuery leftJoinCustomer($relationAlias = null) Adds a LEFT JOIN clause to the query using the Customer relation + * @method ChildCustomerTitleQuery rightJoinCustomer($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Customer relation + * @method ChildCustomerTitleQuery innerJoinCustomer($relationAlias = null) Adds a INNER JOIN clause to the query using the Customer relation + * * @method ChildCustomerTitleQuery leftJoinAddress($relationAlias = null) Adds a LEFT JOIN clause to the query using the Address relation * @method ChildCustomerTitleQuery rightJoinAddress($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Address relation * @method ChildCustomerTitleQuery innerJoinAddress($relationAlias = null) Adds a INNER JOIN clause to the query using the Address relation @@ -434,6 +438,79 @@ abstract class CustomerTitleQuery extends ModelCriteria 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->getTitleId(), $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 * diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 38bdc1dab..2b58787e0 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -56,6 +56,7 @@ class Customer extends BaseCustomer implements UserInterface public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0) { $this + ->setTitleId($titleId) ->setFirstname($firstname) ->setLastname($lastname) ->setEmail($email) diff --git a/core/lib/Thelia/Model/Map/CustomerTableMap.php b/core/lib/Thelia/Model/Map/CustomerTableMap.php index a86453adc..fbd2a9b98 100755 --- a/core/lib/Thelia/Model/Map/CustomerTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTableMap.php @@ -57,7 +57,7 @@ class CustomerTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 13; + const NUM_COLUMNS = 14; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class CustomerTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 13; + const NUM_HYDRATE_COLUMNS = 14; /** * the column name for the ID field @@ -79,6 +79,11 @@ class CustomerTableMap extends TableMap */ const REF = 'customer.REF'; + /** + * the column name for the TITLE_ID field + */ + const TITLE_ID = 'customer.TITLE_ID'; + /** * the column name for the FIRSTNAME field */ @@ -146,12 +151,12 @@ class CustomerTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Ref', 'Firstname', 'Lastname', 'Email', 'Password', 'Algo', 'Reseller', 'Lang', 'Sponsor', 'Discount', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'firstname', 'lastname', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CustomerTableMap::ID, CustomerTableMap::REF, CustomerTableMap::FIRSTNAME, CustomerTableMap::LASTNAME, CustomerTableMap::EMAIL, CustomerTableMap::PASSWORD, CustomerTableMap::ALGO, CustomerTableMap::RESELLER, CustomerTableMap::LANG, CustomerTableMap::SPONSOR, CustomerTableMap::DISCOUNT, CustomerTableMap::CREATED_AT, CustomerTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'REF', 'FIRSTNAME', 'LASTNAME', 'EMAIL', 'PASSWORD', 'ALGO', 'RESELLER', 'LANG', 'SPONSOR', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'ref', 'firstname', 'lastname', 'email', 'password', 'algo', '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, ) + self::TYPE_PHPNAME => array('Id', 'Ref', 'TitleId', 'Firstname', 'Lastname', 'Email', 'Password', 'Algo', 'Reseller', 'Lang', 'Sponsor', 'Discount', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'titleId', 'firstname', 'lastname', 'email', 'password', 'algo', 'reseller', 'lang', 'sponsor', 'discount', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CustomerTableMap::ID, CustomerTableMap::REF, CustomerTableMap::TITLE_ID, CustomerTableMap::FIRSTNAME, CustomerTableMap::LASTNAME, CustomerTableMap::EMAIL, CustomerTableMap::PASSWORD, CustomerTableMap::ALGO, CustomerTableMap::RESELLER, CustomerTableMap::LANG, CustomerTableMap::SPONSOR, CustomerTableMap::DISCOUNT, CustomerTableMap::CREATED_AT, CustomerTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'REF', 'TITLE_ID', 'FIRSTNAME', 'LASTNAME', 'EMAIL', 'PASSWORD', 'ALGO', 'RESELLER', 'LANG', 'SPONSOR', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'ref', 'title_id', 'firstname', 'lastname', 'email', 'password', 'algo', '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, ) ); /** @@ -161,12 +166,12 @@ class CustomerTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'Firstname' => 2, 'Lastname' => 3, 'Email' => 4, 'Password' => 5, 'Algo' => 6, 'Reseller' => 7, 'Lang' => 8, 'Sponsor' => 9, 'Discount' => 10, 'CreatedAt' => 11, 'UpdatedAt' => 12, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'firstname' => 2, 'lastname' => 3, 'email' => 4, 'password' => 5, 'algo' => 6, 'reseller' => 7, 'lang' => 8, 'sponsor' => 9, 'discount' => 10, 'createdAt' => 11, 'updatedAt' => 12, ), - self::TYPE_COLNAME => array(CustomerTableMap::ID => 0, CustomerTableMap::REF => 1, CustomerTableMap::FIRSTNAME => 2, CustomerTableMap::LASTNAME => 3, CustomerTableMap::EMAIL => 4, CustomerTableMap::PASSWORD => 5, CustomerTableMap::ALGO => 6, CustomerTableMap::RESELLER => 7, CustomerTableMap::LANG => 8, CustomerTableMap::SPONSOR => 9, CustomerTableMap::DISCOUNT => 10, CustomerTableMap::CREATED_AT => 11, CustomerTableMap::UPDATED_AT => 12, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'FIRSTNAME' => 2, 'LASTNAME' => 3, 'EMAIL' => 4, 'PASSWORD' => 5, 'ALGO' => 6, 'RESELLER' => 7, 'LANG' => 8, 'SPONSOR' => 9, 'DISCOUNT' => 10, 'CREATED_AT' => 11, 'UPDATED_AT' => 12, ), - self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'firstname' => 2, 'lastname' => 3, 'email' => 4, 'password' => 5, 'algo' => 6, 'reseller' => 7, 'lang' => 8, 'sponsor' => 9, 'discount' => 10, 'created_at' => 11, 'updated_at' => 12, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'TitleId' => 2, 'Firstname' => 3, 'Lastname' => 4, 'Email' => 5, 'Password' => 6, 'Algo' => 7, 'Reseller' => 8, 'Lang' => 9, 'Sponsor' => 10, 'Discount' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'titleId' => 2, 'firstname' => 3, 'lastname' => 4, 'email' => 5, 'password' => 6, 'algo' => 7, 'reseller' => 8, 'lang' => 9, 'sponsor' => 10, 'discount' => 11, 'createdAt' => 12, 'updatedAt' => 13, ), + self::TYPE_COLNAME => array(CustomerTableMap::ID => 0, CustomerTableMap::REF => 1, CustomerTableMap::TITLE_ID => 2, CustomerTableMap::FIRSTNAME => 3, CustomerTableMap::LASTNAME => 4, CustomerTableMap::EMAIL => 5, CustomerTableMap::PASSWORD => 6, CustomerTableMap::ALGO => 7, CustomerTableMap::RESELLER => 8, CustomerTableMap::LANG => 9, CustomerTableMap::SPONSOR => 10, CustomerTableMap::DISCOUNT => 11, CustomerTableMap::CREATED_AT => 12, CustomerTableMap::UPDATED_AT => 13, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'TITLE_ID' => 2, 'FIRSTNAME' => 3, 'LASTNAME' => 4, 'EMAIL' => 5, 'PASSWORD' => 6, 'ALGO' => 7, 'RESELLER' => 8, 'LANG' => 9, 'SPONSOR' => 10, 'DISCOUNT' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, ), + self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'title_id' => 2, 'firstname' => 3, 'lastname' => 4, 'email' => 5, 'password' => 6, 'algo' => 7, 'reseller' => 8, 'lang' => 9, 'sponsor' => 10, 'discount' => 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, ) ); /** @@ -187,6 +192,7 @@ class CustomerTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('REF', 'Ref', 'VARCHAR', true, 50, null); + $this->addForeignKey('TITLE_ID', 'TitleId', 'INTEGER', 'customer_title', 'ID', false, null, null); $this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', true, 255, null); $this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', true, 255, null); $this->addColumn('EMAIL', 'Email', 'VARCHAR', false, 50, null); @@ -205,6 +211,7 @@ class CustomerTableMap extends TableMap */ public function buildRelations() { + $this->addRelation('CustomerTitle', '\\Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('title_id' => 'id', ), 'RESTRICT', '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() @@ -372,6 +379,7 @@ class CustomerTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(CustomerTableMap::ID); $criteria->addSelectColumn(CustomerTableMap::REF); + $criteria->addSelectColumn(CustomerTableMap::TITLE_ID); $criteria->addSelectColumn(CustomerTableMap::FIRSTNAME); $criteria->addSelectColumn(CustomerTableMap::LASTNAME); $criteria->addSelectColumn(CustomerTableMap::EMAIL); @@ -386,6 +394,7 @@ class CustomerTableMap extends TableMap } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.REF'); + $criteria->addSelectColumn($alias . '.TITLE_ID'); $criteria->addSelectColumn($alias . '.FIRSTNAME'); $criteria->addSelectColumn($alias . '.LASTNAME'); $criteria->addSelectColumn($alias . '.EMAIL'); diff --git a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php index 341f2a420..44b16fafd 100755 --- a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php @@ -166,6 +166,7 @@ class CustomerTitleTableMap extends TableMap */ public function buildRelations() { + $this->addRelation('Customer', '\\Thelia\\Model\\Customer', RelationMap::ONE_TO_MANY, array('id' => 'title_id', ), 'RESTRICT', '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() diff --git a/local/config/schema.xml b/local/config/schema.xml index 7c005fd56..db538dacf 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -329,6 +329,7 @@ + @@ -338,6 +339,9 @@ + + +