fix model
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
@@ -17,7 +17,7 @@
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
@@ -35,6 +35,13 @@ class TemplateDefinition
|
||||
const PDF_SUBDIR = 'pdf/';
|
||||
const EMAIL_SUBDIR = 'email/';
|
||||
|
||||
protected static $standardTemplatesSubdirs = array(
|
||||
self::FRONT_OFFICE => self::FRONT_OFFICE_SUBDIR,
|
||||
self::BACK_OFFICE => self::BACK_OFFICE_SUBDIR,
|
||||
self::PDF => self::PDF_SUBDIR,
|
||||
self::EMAIL => self::EMAIL_SUBDIR,
|
||||
);
|
||||
|
||||
/**
|
||||
* @var the template directory name (e.g. 'default')
|
||||
*/
|
||||
@@ -50,12 +57,13 @@ class TemplateDefinition
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
|
||||
public function __construct($name, $type)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->type = $type;
|
||||
|
||||
switch ($type) {
|
||||
switch($type) {
|
||||
case TemplateDefinition::FRONT_OFFICE:
|
||||
$this->path = self::FRONT_OFFICE_SUBDIR . $name;
|
||||
break;
|
||||
@@ -82,17 +90,14 @@ class TemplateDefinition
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getI18nPath()
|
||||
{
|
||||
public function getI18nPath() {
|
||||
return $this->getPath() . DS . 'I18n';
|
||||
}
|
||||
|
||||
public function getAbsoluteI18nPath()
|
||||
{
|
||||
public function getAbsoluteI18nPath() {
|
||||
return THELIA_TEMPLATE_DIR . $this->getI18nPath();
|
||||
}
|
||||
|
||||
@@ -101,8 +106,7 @@ class TemplateDefinition
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function getAbsolutePath()
|
||||
{
|
||||
public function getAbsolutePath() {
|
||||
return THELIA_TEMPLATE_DIR . $this->getPath();
|
||||
}
|
||||
|
||||
@@ -111,15 +115,13 @@ class TemplateDefinition
|
||||
return $this->getPath() . DS . 'configs';
|
||||
}
|
||||
|
||||
public function getAbsoluteConfigPath()
|
||||
{
|
||||
public function getAbsoluteConfigPath() {
|
||||
return THELIA_TEMPLATE_DIR . $this->getConfigPath();
|
||||
}
|
||||
|
||||
public function setPath($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -131,7 +133,13 @@ class TemplateDefinition
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator on the standard templates subdir names
|
||||
*/
|
||||
public static function getStandardTemplatesSubdirsIterator() {
|
||||
return new \ArrayIterator(self::$standardTemplatesSubdirs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1393,53 +1393,53 @@ abstract class Coupon implements ActiveRecordInterface
|
||||
|
||||
// check the columns in natural order for more readable SQL queries
|
||||
if ($this->isColumnModified(CouponTableMap::ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'ID';
|
||||
$modifiedColumns[':p' . $index++] = '`ID`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponTableMap::CODE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CODE';
|
||||
$modifiedColumns[':p' . $index++] = '`CODE`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponTableMap::TYPE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'TYPE';
|
||||
$modifiedColumns[':p' . $index++] = '`TYPE`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponTableMap::SERIALIZED_EFFECTS)) {
|
||||
$modifiedColumns[':p' . $index++] = 'SERIALIZED_EFFECTS';
|
||||
$modifiedColumns[':p' . $index++] = '`SERIALIZED_EFFECTS`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponTableMap::IS_ENABLED)) {
|
||||
$modifiedColumns[':p' . $index++] = 'IS_ENABLED';
|
||||
$modifiedColumns[':p' . $index++] = '`IS_ENABLED`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponTableMap::EXPIRATION_DATE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'EXPIRATION_DATE';
|
||||
$modifiedColumns[':p' . $index++] = '`EXPIRATION_DATE`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponTableMap::MAX_USAGE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'MAX_USAGE';
|
||||
$modifiedColumns[':p' . $index++] = '`MAX_USAGE`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponTableMap::IS_CUMULATIVE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'IS_CUMULATIVE';
|
||||
$modifiedColumns[':p' . $index++] = '`IS_CUMULATIVE`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponTableMap::IS_REMOVING_POSTAGE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'IS_REMOVING_POSTAGE';
|
||||
$modifiedColumns[':p' . $index++] = '`IS_REMOVING_POSTAGE`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) {
|
||||
$modifiedColumns[':p' . $index++] = 'IS_AVAILABLE_ON_SPECIAL_OFFERS';
|
||||
$modifiedColumns[':p' . $index++] = '`IS_AVAILABLE_ON_SPECIAL_OFFERS`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponTableMap::IS_USED)) {
|
||||
$modifiedColumns[':p' . $index++] = 'IS_USED';
|
||||
$modifiedColumns[':p' . $index++] = '`IS_USED`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponTableMap::SERIALIZED_CONDITIONS)) {
|
||||
$modifiedColumns[':p' . $index++] = 'SERIALIZED_CONDITIONS';
|
||||
$modifiedColumns[':p' . $index++] = '`SERIALIZED_CONDITIONS`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||
$modifiedColumns[':p' . $index++] = '`CREATED_AT`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponTableMap::UPDATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'UPDATED_AT';
|
||||
$modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponTableMap::VERSION)) {
|
||||
$modifiedColumns[':p' . $index++] = 'VERSION';
|
||||
$modifiedColumns[':p' . $index++] = '`VERSION`';
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'INSERT INTO coupon (%s) VALUES (%s)',
|
||||
'INSERT INTO `coupon` (%s) VALUES (%s)',
|
||||
implode(', ', $modifiedColumns),
|
||||
implode(', ', array_keys($modifiedColumns))
|
||||
);
|
||||
@@ -1448,49 +1448,49 @@ abstract class Coupon implements ActiveRecordInterface
|
||||
$stmt = $con->prepare($sql);
|
||||
foreach ($modifiedColumns as $identifier => $columnName) {
|
||||
switch ($columnName) {
|
||||
case 'ID':
|
||||
case '`ID`':
|
||||
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'CODE':
|
||||
case '`CODE`':
|
||||
$stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'TYPE':
|
||||
case '`TYPE`':
|
||||
$stmt->bindValue($identifier, $this->type, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'SERIALIZED_EFFECTS':
|
||||
case '`SERIALIZED_EFFECTS`':
|
||||
$stmt->bindValue($identifier, $this->serialized_effects, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'IS_ENABLED':
|
||||
case '`IS_ENABLED`':
|
||||
$stmt->bindValue($identifier, (int) $this->is_enabled, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'EXPIRATION_DATE':
|
||||
case '`EXPIRATION_DATE`':
|
||||
$stmt->bindValue($identifier, $this->expiration_date ? $this->expiration_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'MAX_USAGE':
|
||||
case '`MAX_USAGE`':
|
||||
$stmt->bindValue($identifier, $this->max_usage, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'IS_CUMULATIVE':
|
||||
case '`IS_CUMULATIVE`':
|
||||
$stmt->bindValue($identifier, (int) $this->is_cumulative, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'IS_REMOVING_POSTAGE':
|
||||
case '`IS_REMOVING_POSTAGE`':
|
||||
$stmt->bindValue($identifier, (int) $this->is_removing_postage, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'IS_AVAILABLE_ON_SPECIAL_OFFERS':
|
||||
case '`IS_AVAILABLE_ON_SPECIAL_OFFERS`':
|
||||
$stmt->bindValue($identifier, (int) $this->is_available_on_special_offers, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'IS_USED':
|
||||
case '`IS_USED`':
|
||||
$stmt->bindValue($identifier, (int) $this->is_used, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'SERIALIZED_CONDITIONS':
|
||||
case '`SERIALIZED_CONDITIONS`':
|
||||
$stmt->bindValue($identifier, $this->serialized_conditions, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'CREATED_AT':
|
||||
case '`CREATED_AT`':
|
||||
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'UPDATED_AT':
|
||||
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':
|
||||
case '`VERSION`':
|
||||
$stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ abstract class CouponQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, CODE, TYPE, SERIALIZED_EFFECTS, IS_ENABLED, EXPIRATION_DATE, MAX_USAGE, IS_CUMULATIVE, IS_REMOVING_POSTAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, IS_USED, SERIALIZED_CONDITIONS, CREATED_AT, UPDATED_AT, VERSION FROM coupon WHERE ID = :p0';
|
||||
$sql = 'SELECT `ID`, `CODE`, `TYPE`, `SERIALIZED_EFFECTS`, `IS_ENABLED`, `EXPIRATION_DATE`, `MAX_USAGE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `IS_USED`, `SERIALIZED_CONDITIONS`, `CREATED_AT`, `UPDATED_AT`, `VERSION` FROM `coupon` WHERE `ID` = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
|
||||
@@ -1305,53 +1305,53 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
|
||||
// check the columns in natural order for more readable SQL queries
|
||||
if ($this->isColumnModified(CouponVersionTableMap::ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'ID';
|
||||
$modifiedColumns[':p' . $index++] = '`ID`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::CODE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CODE';
|
||||
$modifiedColumns[':p' . $index++] = '`CODE`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::TYPE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'TYPE';
|
||||
$modifiedColumns[':p' . $index++] = '`TYPE`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_EFFECTS)) {
|
||||
$modifiedColumns[':p' . $index++] = 'SERIALIZED_EFFECTS';
|
||||
$modifiedColumns[':p' . $index++] = '`SERIALIZED_EFFECTS`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::IS_ENABLED)) {
|
||||
$modifiedColumns[':p' . $index++] = 'IS_ENABLED';
|
||||
$modifiedColumns[':p' . $index++] = '`IS_ENABLED`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::EXPIRATION_DATE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'EXPIRATION_DATE';
|
||||
$modifiedColumns[':p' . $index++] = '`EXPIRATION_DATE`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::MAX_USAGE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'MAX_USAGE';
|
||||
$modifiedColumns[':p' . $index++] = '`MAX_USAGE`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::IS_CUMULATIVE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'IS_CUMULATIVE';
|
||||
$modifiedColumns[':p' . $index++] = '`IS_CUMULATIVE`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::IS_REMOVING_POSTAGE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'IS_REMOVING_POSTAGE';
|
||||
$modifiedColumns[':p' . $index++] = '`IS_REMOVING_POSTAGE`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) {
|
||||
$modifiedColumns[':p' . $index++] = 'IS_AVAILABLE_ON_SPECIAL_OFFERS';
|
||||
$modifiedColumns[':p' . $index++] = '`IS_AVAILABLE_ON_SPECIAL_OFFERS`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::IS_USED)) {
|
||||
$modifiedColumns[':p' . $index++] = 'IS_USED';
|
||||
$modifiedColumns[':p' . $index++] = '`IS_USED`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::SERIALIZED_CONDITIONS)) {
|
||||
$modifiedColumns[':p' . $index++] = 'SERIALIZED_CONDITIONS';
|
||||
$modifiedColumns[':p' . $index++] = '`SERIALIZED_CONDITIONS`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||
$modifiedColumns[':p' . $index++] = '`CREATED_AT`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::UPDATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'UPDATED_AT';
|
||||
$modifiedColumns[':p' . $index++] = '`UPDATED_AT`';
|
||||
}
|
||||
if ($this->isColumnModified(CouponVersionTableMap::VERSION)) {
|
||||
$modifiedColumns[':p' . $index++] = 'VERSION';
|
||||
$modifiedColumns[':p' . $index++] = '`VERSION`';
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'INSERT INTO coupon_version (%s) VALUES (%s)',
|
||||
'INSERT INTO `coupon_version` (%s) VALUES (%s)',
|
||||
implode(', ', $modifiedColumns),
|
||||
implode(', ', array_keys($modifiedColumns))
|
||||
);
|
||||
@@ -1360,49 +1360,49 @@ abstract class CouponVersion implements ActiveRecordInterface
|
||||
$stmt = $con->prepare($sql);
|
||||
foreach ($modifiedColumns as $identifier => $columnName) {
|
||||
switch ($columnName) {
|
||||
case 'ID':
|
||||
case '`ID`':
|
||||
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'CODE':
|
||||
case '`CODE`':
|
||||
$stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'TYPE':
|
||||
case '`TYPE`':
|
||||
$stmt->bindValue($identifier, $this->type, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'SERIALIZED_EFFECTS':
|
||||
case '`SERIALIZED_EFFECTS`':
|
||||
$stmt->bindValue($identifier, $this->serialized_effects, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'IS_ENABLED':
|
||||
case '`IS_ENABLED`':
|
||||
$stmt->bindValue($identifier, (int) $this->is_enabled, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'EXPIRATION_DATE':
|
||||
case '`EXPIRATION_DATE`':
|
||||
$stmt->bindValue($identifier, $this->expiration_date ? $this->expiration_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'MAX_USAGE':
|
||||
case '`MAX_USAGE`':
|
||||
$stmt->bindValue($identifier, $this->max_usage, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'IS_CUMULATIVE':
|
||||
case '`IS_CUMULATIVE`':
|
||||
$stmt->bindValue($identifier, (int) $this->is_cumulative, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'IS_REMOVING_POSTAGE':
|
||||
case '`IS_REMOVING_POSTAGE`':
|
||||
$stmt->bindValue($identifier, (int) $this->is_removing_postage, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'IS_AVAILABLE_ON_SPECIAL_OFFERS':
|
||||
case '`IS_AVAILABLE_ON_SPECIAL_OFFERS`':
|
||||
$stmt->bindValue($identifier, (int) $this->is_available_on_special_offers, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'IS_USED':
|
||||
case '`IS_USED`':
|
||||
$stmt->bindValue($identifier, (int) $this->is_used, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'SERIALIZED_CONDITIONS':
|
||||
case '`SERIALIZED_CONDITIONS`':
|
||||
$stmt->bindValue($identifier, $this->serialized_conditions, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'CREATED_AT':
|
||||
case '`CREATED_AT`':
|
||||
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'UPDATED_AT':
|
||||
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':
|
||||
case '`VERSION`':
|
||||
$stmt->bindValue($identifier, $this->version, PDO::PARAM_INT);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ abstract class CouponVersionQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, CODE, TYPE, SERIALIZED_EFFECTS, IS_ENABLED, EXPIRATION_DATE, MAX_USAGE, IS_CUMULATIVE, IS_REMOVING_POSTAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, IS_USED, SERIALIZED_CONDITIONS, CREATED_AT, UPDATED_AT, VERSION FROM coupon_version WHERE ID = :p0 AND VERSION = :p1';
|
||||
$sql = 'SELECT `ID`, `CODE`, `TYPE`, `SERIALIZED_EFFECTS`, `IS_ENABLED`, `EXPIRATION_DATE`, `MAX_USAGE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `IS_USED`, `SERIALIZED_CONDITIONS`, `CREATED_AT`, `UPDATED_AT`, `VERSION` FROM `coupon_version` WHERE `ID` = :p0 AND `VERSION` = :p1';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
|
||||
|
||||
@@ -183,7 +183,7 @@ abstract class OrderCouponQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, ORDER_ID, CODE, TYPE, AMOUNT, TITLE, SHORT_DESCRIPTION, DESCRIPTION, EXPIRATION_DATE, IS_CUMULATIVE, IS_REMOVING_POSTAGE, IS_AVAILABLE_ON_SPECIAL_OFFERS, SERIALIZED_CONDITIONS, CREATED_AT, UPDATED_AT FROM order_coupon WHERE ID = :p0';
|
||||
$sql = 'SELECT `ID`, `ORDER_ID`, `CODE`, `TYPE`, `AMOUNT`, `TITLE`, `SHORT_DESCRIPTION`, `DESCRIPTION`, `EXPIRATION_DATE`, `IS_CUMULATIVE`, `IS_REMOVING_POSTAGE`, `IS_AVAILABLE_ON_SPECIAL_OFFERS`, `SERIALIZED_CONDITIONS`, `CREATED_AT`, `UPDATED_AT` FROM `order_coupon` WHERE `ID` = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
|
||||
@@ -140,6 +140,9 @@ abstract class ProductQuery extends ModelCriteria
|
||||
*/
|
||||
static $isVersioningEnabled = true;
|
||||
|
||||
// query_cache behavior
|
||||
protected $queryKey = '';
|
||||
|
||||
/**
|
||||
* Initializes internal state of \Thelia\Model\Base\ProductQuery object.
|
||||
*
|
||||
@@ -1995,4 +1998,126 @@ abstract class ProductQuery extends ModelCriteria
|
||||
self::$isVersioningEnabled = false;
|
||||
}
|
||||
|
||||
// query_cache behavior
|
||||
|
||||
public function setQueryKey($key)
|
||||
{
|
||||
$this->queryKey = $key;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getQueryKey()
|
||||
{
|
||||
return $this->queryKey;
|
||||
}
|
||||
|
||||
public function cacheContains($key)
|
||||
{
|
||||
|
||||
return apc_fetch($key);
|
||||
}
|
||||
|
||||
public function cacheFetch($key)
|
||||
{
|
||||
|
||||
return apc_fetch($key);
|
||||
}
|
||||
|
||||
public function cacheStore($key, $value, $lifetime = 3600)
|
||||
{
|
||||
apc_store($key, $value, $lifetime);
|
||||
}
|
||||
|
||||
protected function doSelect($con)
|
||||
{
|
||||
// check that the columns of the main class are already added (if this is the primary ModelCriteria)
|
||||
if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) {
|
||||
$this->addSelfSelectColumns();
|
||||
}
|
||||
$this->configureSelectColumns();
|
||||
|
||||
$dbMap = Propel::getServiceContainer()->getDatabaseMap(ProductTableMap::DATABASE_NAME);
|
||||
$db = Propel::getServiceContainer()->getAdapter(ProductTableMap::DATABASE_NAME);
|
||||
|
||||
$key = $this->getQueryKey();
|
||||
if ($key && $this->cacheContains($key)) {
|
||||
$params = $this->getParams();
|
||||
$sql = $this->cacheFetch($key);
|
||||
} else {
|
||||
$params = array();
|
||||
$sql = $this->createSelectSql($params);
|
||||
if ($key) {
|
||||
$this->cacheStore($key, $sql);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$db->bindValues($stmt, $params, $dbMap);
|
||||
$stmt->execute();
|
||||
} catch (Exception $e) {
|
||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
|
||||
}
|
||||
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
protected function doCount($con)
|
||||
{
|
||||
$dbMap = Propel::getServiceContainer()->getDatabaseMap($this->getDbName());
|
||||
$db = Propel::getServiceContainer()->getAdapter($this->getDbName());
|
||||
|
||||
$key = $this->getQueryKey();
|
||||
if ($key && $this->cacheContains($key)) {
|
||||
$params = $this->getParams();
|
||||
$sql = $this->cacheFetch($key);
|
||||
} else {
|
||||
// check that the columns of the main class are already added (if this is the primary ModelCriteria)
|
||||
if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) {
|
||||
$this->addSelfSelectColumns();
|
||||
}
|
||||
|
||||
$this->configureSelectColumns();
|
||||
|
||||
$needsComplexCount = $this->getGroupByColumns()
|
||||
|| $this->getOffset()
|
||||
|| $this->getLimit()
|
||||
|| $this->getHaving()
|
||||
|| in_array(Criteria::DISTINCT, $this->getSelectModifiers());
|
||||
|
||||
$params = array();
|
||||
if ($needsComplexCount) {
|
||||
if ($this->needsSelectAliases()) {
|
||||
if ($this->getHaving()) {
|
||||
throw new PropelException('Propel cannot create a COUNT query when using HAVING and duplicate column names in the SELECT part');
|
||||
}
|
||||
$db->turnSelectColumnsToAliases($this);
|
||||
}
|
||||
$selectSql = $this->createSelectSql($params);
|
||||
$sql = 'SELECT COUNT(*) FROM (' . $selectSql . ') propelmatch4cnt';
|
||||
} else {
|
||||
// Replace SELECT columns with COUNT(*)
|
||||
$this->clearSelectColumns()->addSelectColumn('COUNT(*)');
|
||||
$sql = $this->createSelectSql($params);
|
||||
}
|
||||
|
||||
if ($key) {
|
||||
$this->cacheStore($key, $sql);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$db->bindValues($stmt, $params, $dbMap);
|
||||
$stmt->execute();
|
||||
} catch (Exception $e) {
|
||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||
throw new PropelException(sprintf('Unable to execute COUNT statement [%s]', $sql), 0, $e);
|
||||
}
|
||||
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
} // ProductQuery
|
||||
|
||||
@@ -232,6 +232,7 @@ class ProductTableMap extends TableMap
|
||||
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
|
||||
'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum, meta_title, meta_description, meta_keywords', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ),
|
||||
'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ),
|
||||
'query_cache' => array('backend' => 'apc', 'lifetime' => '3600', ),
|
||||
);
|
||||
} // getBehaviors()
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<database defaultIdMethod="native" name="thelia">
|
||||
<table name="category" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
@@ -854,7 +854,7 @@
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="code" required="true" size="45" type="VARCHAR" />
|
||||
<column name="type" required="true" size="255" type="VARCHAR" />
|
||||
<column name="serialized_effects" required="true" type="LONG VARCHAR" />
|
||||
<column name="serialized_effects" required="true" type="LONGVARCHAR" />
|
||||
<column name="title" required="true" size="255" type="VARCHAR" />
|
||||
<column name="is_enabled" required="true" type="BOOLEAN" />
|
||||
<column name="short_description" required="true" type="LONGVARCHAR" />
|
||||
|
||||
Reference in New Issue
Block a user