default country

This commit is contained in:
Etienne Roudeix
2013-09-16 15:30:46 +02:00
parent 2021ddfc9e
commit 5ca7136e6d
6 changed files with 498 additions and 389 deletions

View File

@@ -93,6 +93,12 @@ abstract class Country implements ActiveRecordInterface
*/
protected $isoalpha3;
/**
* The value for the by_default field.
* @var int
*/
protected $by_default;
/**
* The value for the created_at field.
* @var string
@@ -477,6 +483,17 @@ abstract class Country implements ActiveRecordInterface
return $this->isoalpha3;
}
/**
* Get the [by_default] column value.
*
* @return int
*/
public function getByDefault()
{
return $this->by_default;
}
/**
* Get the [optionally formatted] temporal [created_at] column value.
*
@@ -626,6 +643,27 @@ abstract class Country implements ActiveRecordInterface
return $this;
} // setIsoalpha3()
/**
* Set the value of [by_default] column.
*
* @param int $v new value
* @return \Thelia\Model\Country The current object (for fluent API support)
*/
public function setByDefault($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->by_default !== $v) {
$this->by_default = $v;
$this->modifiedColumns[] = CountryTableMap::BY_DEFAULT;
}
return $this;
} // setByDefault()
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
*
@@ -720,13 +758,16 @@ abstract class Country implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CountryTableMap::translateFieldName('Isoalpha3', TableMap::TYPE_PHPNAME, $indexType)];
$this->isoalpha3 = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CountryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CountryTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)];
$this->by_default = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CountryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CountryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CountryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -739,7 +780,7 @@ abstract class Country implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 7; // 7 = CountryTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 8; // 8 = CountryTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\Country object", 0, $e);
@@ -1043,6 +1084,9 @@ abstract class Country implements ActiveRecordInterface
if ($this->isColumnModified(CountryTableMap::ISOALPHA3)) {
$modifiedColumns[':p' . $index++] = 'ISOALPHA3';
}
if ($this->isColumnModified(CountryTableMap::BY_DEFAULT)) {
$modifiedColumns[':p' . $index++] = 'BY_DEFAULT';
}
if ($this->isColumnModified(CountryTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
}
@@ -1075,6 +1119,9 @@ abstract class Country implements ActiveRecordInterface
case 'ISOALPHA3':
$stmt->bindValue($identifier, $this->isoalpha3, PDO::PARAM_STR);
break;
case 'BY_DEFAULT':
$stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT);
break;
case 'CREATED_AT':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
@@ -1152,9 +1199,12 @@ abstract class Country implements ActiveRecordInterface
return $this->getIsoalpha3();
break;
case 5:
return $this->getCreatedAt();
return $this->getByDefault();
break;
case 6:
return $this->getCreatedAt();
break;
case 7:
return $this->getUpdatedAt();
break;
default:
@@ -1191,8 +1241,9 @@ abstract class Country implements ActiveRecordInterface
$keys[2] => $this->getIsocode(),
$keys[3] => $this->getIsoalpha2(),
$keys[4] => $this->getIsoalpha3(),
$keys[5] => $this->getCreatedAt(),
$keys[6] => $this->getUpdatedAt(),
$keys[5] => $this->getByDefault(),
$keys[6] => $this->getCreatedAt(),
$keys[7] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn)
@@ -1263,9 +1314,12 @@ abstract class Country implements ActiveRecordInterface
$this->setIsoalpha3($value);
break;
case 5:
$this->setCreatedAt($value);
$this->setByDefault($value);
break;
case 6:
$this->setCreatedAt($value);
break;
case 7:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1297,8 +1351,9 @@ abstract class Country implements ActiveRecordInterface
if (array_key_exists($keys[2], $arr)) $this->setIsocode($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setIsoalpha2($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setIsoalpha3($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
if (array_key_exists($keys[5], $arr)) $this->setByDefault($arr[$keys[5]]);
if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
}
/**
@@ -1315,6 +1370,7 @@ abstract class Country implements ActiveRecordInterface
if ($this->isColumnModified(CountryTableMap::ISOCODE)) $criteria->add(CountryTableMap::ISOCODE, $this->isocode);
if ($this->isColumnModified(CountryTableMap::ISOALPHA2)) $criteria->add(CountryTableMap::ISOALPHA2, $this->isoalpha2);
if ($this->isColumnModified(CountryTableMap::ISOALPHA3)) $criteria->add(CountryTableMap::ISOALPHA3, $this->isoalpha3);
if ($this->isColumnModified(CountryTableMap::BY_DEFAULT)) $criteria->add(CountryTableMap::BY_DEFAULT, $this->by_default);
if ($this->isColumnModified(CountryTableMap::CREATED_AT)) $criteria->add(CountryTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(CountryTableMap::UPDATED_AT)) $criteria->add(CountryTableMap::UPDATED_AT, $this->updated_at);
@@ -1385,6 +1441,7 @@ abstract class Country implements ActiveRecordInterface
$copyObj->setIsocode($this->getIsocode());
$copyObj->setIsoalpha2($this->getIsoalpha2());
$copyObj->setIsoalpha3($this->getIsoalpha3());
$copyObj->setByDefault($this->getByDefault());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
@@ -2287,6 +2344,7 @@ abstract class Country implements ActiveRecordInterface
$this->isocode = null;
$this->isoalpha2 = null;
$this->isoalpha3 = null;
$this->by_default = null;
$this->created_at = null;
$this->updated_at = null;
$this->alreadyInSave = false;

View File

@@ -27,6 +27,7 @@ use Thelia\Model\Map\CountryTableMap;
* @method ChildCountryQuery orderByIsocode($order = Criteria::ASC) Order by the isocode column
* @method ChildCountryQuery orderByIsoalpha2($order = Criteria::ASC) Order by the isoalpha2 column
* @method ChildCountryQuery orderByIsoalpha3($order = Criteria::ASC) Order by the isoalpha3 column
* @method ChildCountryQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column
* @method ChildCountryQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildCountryQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
@@ -35,6 +36,7 @@ use Thelia\Model\Map\CountryTableMap;
* @method ChildCountryQuery groupByIsocode() Group by the isocode column
* @method ChildCountryQuery groupByIsoalpha2() Group by the isoalpha2 column
* @method ChildCountryQuery groupByIsoalpha3() Group by the isoalpha3 column
* @method ChildCountryQuery groupByByDefault() Group by the by_default column
* @method ChildCountryQuery groupByCreatedAt() Group by the created_at column
* @method ChildCountryQuery groupByUpdatedAt() Group by the updated_at column
*
@@ -66,6 +68,7 @@ use Thelia\Model\Map\CountryTableMap;
* @method ChildCountry findOneByIsocode(string $isocode) Return the first ChildCountry filtered by the isocode column
* @method ChildCountry findOneByIsoalpha2(string $isoalpha2) Return the first ChildCountry filtered by the isoalpha2 column
* @method ChildCountry findOneByIsoalpha3(string $isoalpha3) Return the first ChildCountry filtered by the isoalpha3 column
* @method ChildCountry findOneByByDefault(int $by_default) Return the first ChildCountry filtered by the by_default column
* @method ChildCountry findOneByCreatedAt(string $created_at) Return the first ChildCountry filtered by the created_at column
* @method ChildCountry findOneByUpdatedAt(string $updated_at) Return the first ChildCountry filtered by the updated_at column
*
@@ -74,6 +77,7 @@ use Thelia\Model\Map\CountryTableMap;
* @method array findByIsocode(string $isocode) Return ChildCountry objects filtered by the isocode column
* @method array findByIsoalpha2(string $isoalpha2) Return ChildCountry objects filtered by the isoalpha2 column
* @method array findByIsoalpha3(string $isoalpha3) Return ChildCountry objects filtered by the isoalpha3 column
* @method array findByByDefault(int $by_default) Return ChildCountry objects filtered by the by_default column
* @method array findByCreatedAt(string $created_at) Return ChildCountry objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildCountry objects filtered by the updated_at column
*
@@ -164,7 +168,7 @@ abstract class CountryQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, AREA_ID, ISOCODE, ISOALPHA2, ISOALPHA3, CREATED_AT, UPDATED_AT FROM country WHERE ID = :p0';
$sql = 'SELECT ID, AREA_ID, ISOCODE, ISOALPHA2, ISOALPHA3, BY_DEFAULT, CREATED_AT, UPDATED_AT FROM country WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -424,6 +428,47 @@ abstract class CountryQuery extends ModelCriteria
return $this->addUsingAlias(CountryTableMap::ISOALPHA3, $isoalpha3, $comparison);
}
/**
* Filter the query on the by_default column
*
* Example usage:
* <code>
* $query->filterByByDefault(1234); // WHERE by_default = 1234
* $query->filterByByDefault(array(12, 34)); // WHERE by_default IN (12, 34)
* $query->filterByByDefault(array('min' => 12)); // WHERE by_default > 12
* </code>
*
* @param mixed $byDefault The value to use as filter.
* Use scalar values for equality.
* Use array values for in_array() equivalent.
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildCountryQuery The current query, for fluid interface
*/
public function filterByByDefault($byDefault = null, $comparison = null)
{
if (is_array($byDefault)) {
$useMinMax = false;
if (isset($byDefault['min'])) {
$this->addUsingAlias(CountryTableMap::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($byDefault['max'])) {
$this->addUsingAlias(CountryTableMap::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CountryTableMap::BY_DEFAULT, $byDefault, $comparison);
}
/**
* Filter the query on the created_at column
*

View File

@@ -57,7 +57,7 @@ class CountryTableMap extends TableMap
/**
* The total number of columns
*/
const NUM_COLUMNS = 7;
const NUM_COLUMNS = 8;
/**
* The number of lazy-loaded columns
@@ -67,7 +67,7 @@ class CountryTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 7;
const NUM_HYDRATE_COLUMNS = 8;
/**
* the column name for the ID field
@@ -94,6 +94,11 @@ class CountryTableMap extends TableMap
*/
const ISOALPHA3 = 'country.ISOALPHA3';
/**
* the column name for the BY_DEFAULT field
*/
const BY_DEFAULT = 'country.BY_DEFAULT';
/**
* the column name for the CREATED_AT field
*/
@@ -125,12 +130,12 @@ class CountryTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'AreaId', 'Isocode', 'Isoalpha2', 'Isoalpha3', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'isocode', 'isoalpha2', 'isoalpha3', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(CountryTableMap::ID, CountryTableMap::AREA_ID, CountryTableMap::ISOCODE, CountryTableMap::ISOALPHA2, CountryTableMap::ISOALPHA3, CountryTableMap::CREATED_AT, CountryTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'ISOCODE', 'ISOALPHA2', 'ISOALPHA3', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'area_id', 'isocode', 'isoalpha2', 'isoalpha3', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
self::TYPE_PHPNAME => array('Id', 'AreaId', 'Isocode', 'Isoalpha2', 'Isoalpha3', 'ByDefault', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'isocode', 'isoalpha2', 'isoalpha3', 'byDefault', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(CountryTableMap::ID, CountryTableMap::AREA_ID, CountryTableMap::ISOCODE, CountryTableMap::ISOALPHA2, CountryTableMap::ISOALPHA3, CountryTableMap::BY_DEFAULT, CountryTableMap::CREATED_AT, CountryTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'ISOCODE', 'ISOALPHA2', 'ISOALPHA3', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'area_id', 'isocode', 'isoalpha2', 'isoalpha3', 'by_default', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
@@ -140,12 +145,12 @@ class CountryTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Isocode' => 2, 'Isoalpha2' => 3, 'Isoalpha3' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
self::TYPE_COLNAME => array(CountryTableMap::ID => 0, CountryTableMap::AREA_ID => 1, CountryTableMap::ISOCODE => 2, CountryTableMap::ISOALPHA2 => 3, CountryTableMap::ISOALPHA3 => 4, CountryTableMap::CREATED_AT => 5, CountryTableMap::UPDATED_AT => 6, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'ISOCODE' => 2, 'ISOALPHA2' => 3, 'ISOALPHA3' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'created_at' => 5, 'updated_at' => 6, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Isocode' => 2, 'Isoalpha2' => 3, 'Isoalpha3' => 4, 'ByDefault' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'byDefault' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
self::TYPE_COLNAME => array(CountryTableMap::ID => 0, CountryTableMap::AREA_ID => 1, CountryTableMap::ISOCODE => 2, CountryTableMap::ISOALPHA2 => 3, CountryTableMap::ISOALPHA3 => 4, CountryTableMap::BY_DEFAULT => 5, CountryTableMap::CREATED_AT => 6, CountryTableMap::UPDATED_AT => 7, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'ISOCODE' => 2, 'ISOALPHA2' => 3, 'ISOALPHA3' => 4, 'BY_DEFAULT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'by_default' => 5, 'created_at' => 6, 'updated_at' => 7, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
);
/**
@@ -169,6 +174,7 @@ class CountryTableMap extends TableMap
$this->addColumn('ISOCODE', 'Isocode', 'VARCHAR', true, 4, null);
$this->addColumn('ISOALPHA2', 'Isoalpha2', 'VARCHAR', false, 2, null);
$this->addColumn('ISOALPHA3', 'Isoalpha3', 'VARCHAR', false, 4, null);
$this->addColumn('BY_DEFAULT', 'ByDefault', 'TINYINT', false, null, null);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
@@ -351,6 +357,7 @@ class CountryTableMap extends TableMap
$criteria->addSelectColumn(CountryTableMap::ISOCODE);
$criteria->addSelectColumn(CountryTableMap::ISOALPHA2);
$criteria->addSelectColumn(CountryTableMap::ISOALPHA3);
$criteria->addSelectColumn(CountryTableMap::BY_DEFAULT);
$criteria->addSelectColumn(CountryTableMap::CREATED_AT);
$criteria->addSelectColumn(CountryTableMap::UPDATED_AT);
} else {
@@ -359,6 +366,7 @@ class CountryTableMap extends TableMap
$criteria->addSelectColumn($alias . '.ISOCODE');
$criteria->addSelectColumn($alias . '.ISOALPHA2');
$criteria->addSelectColumn($alias . '.ISOALPHA3');
$criteria->addSelectColumn($alias . '.BY_DEFAULT');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}