first commit

This commit is contained in:
2025-03-12 17:06:23 +01:00
commit 2241f7131f
13185 changed files with 1692479 additions and 0 deletions

View File

@@ -0,0 +1,172 @@
<?php
/**
* SOTESHOP/stCountriesPlugin
*
* Ten plik należy do aplikacji stCountriesPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stCountriesPlugin
* @subpackage helpers
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: CountriesHelper.php 4 2009-08-24 08:52:56Z marcin $
* @author Marcin Olejniczak <marcin.olejniczak@sote.pl>
*/
/**
* Pobieranie nazwy kraju
*
* @param integer $country numer kraju
* @return string nazwa kraju
*/
function getName($country)
{
$country = CountriesPeer::retrieveByPK($country);
return $country->getName();
}
/**
* Pobieranie strefy kraju
*
* @param integer $country numer kraju
* @return integer strefa kraju
*/
function getArea($country)
{
$c = new Criteria();
$c->add(CountriesAreaHasCountriesPeer::COUNTRIES_ID , $country);
$country_area = CountriesAreaHasCountriesPeer::doSelectOne($c);
return $country_area->getCountriesAreaId();
}
function st_countries_select_tag($name, $value, array $params = array())
{
$iso = false;
$countryName = false;
$optionsParams = array();
if (isset($params['include_custom']))
{
$optionsParams['include_custom'] = $params['include_custom'];
unset($params['include_custom']);
}
if (isset($params['include_custom']))
{
$optionsParams['include_custom'] = $params['include_custom'];
}
if (isset($params['iso']))
{
$iso = $params['iso'];
unset($params['iso']);
}
if (isset($params['country_name']))
{
$countryName = $params['country_name'];
unset($params['country_name']);
}
if (!isset($params['all']))
{
$countries = CountriesPeer::doSelectActiveCached();
$eu = array();
$outsideEu = array();
foreach ($countries as $country)
{
if ($countryName)
{
$id = $country->getOptName();
}
elseif ($iso)
{
$id = $country->getIsoA2();
}
else
{
$id = $country->getId();
}
if ($country->isEU())
{
$eu[$id] = $country->getName();
}
else
{
$outsideEu[$id] = $country->getName();
}
}
$options = array("Unia Europejska" => $eu, "Państwa spoza Unii Europejskiej" => $outsideEu);
}
else
{
unset($params['all']);
CountriesPeer::setHydrateMethod(function(ResultSet $rs) use ($iso, $countryName) {
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$eu = array();
$outsideEu = array();
while($rs->next())
{
$row = $rs->getRow();
$name = $row['NAME'] ? $row['NAME'] : $row['OPT_NAME'];
$code = $row['ISO_A2'];
if ($countryName)
{
$id = $name;
}
elseif ($iso)
{
$id = $code;
}
else
{
$id = $row['ID'];
}
if (CountriesPeer::isEuCountryCode($code))
{
$eu[$id] = $name;
}
else
{
$outsideEu[$id] = $name;
}
}
return array($eu, $outsideEu);
});
$c = new Criteria();
$c->addSelectColumn(CountriesPeer::ID);
$c->addSelectColumn(CountriesPeer::ISO_A2);
$c->addSelectColumn(CountriesPeer::OPT_NAME);
$c->addSelectColumn(CountriesI18nPeer::NAME);
$c->addAscendingOrderByColumn(CountriesI18nPeer::NAME);
list($eu, $outsideEu) = CountriesPeer::doSelectWithI18n($c);
$options = array("Unia Europejska" => $eu, "Państwa spoza Unii Europejskiej" => $outsideEu);
}
return select_tag($name, options_for_select($options, $value, $optionsParams), $params);
}
function object_st_countries_select_tag($object, $method, array $params = array())
{
$value = _get_object_value($object, $method);
return st_countries_select_tag(_convert_method_to_name($method, $params), $value, $params);
}

View File

@@ -0,0 +1,184 @@
<?php
/**
* SOTESHOP/stCountriesPlugin
*
* Ten plik należy do aplikacji stCountriesPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stCountriesPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: Countries.php 10216 2011-01-13 11:34:53Z michal $
* @author Marcin Olejniczak <marcin.olejniczak@sote.pl>
*/
/**
* Klasa Countries
*
* @package stCountriesPlugin
* @subpackage libs
*/
class Countries extends BaseCountries
{
public function __sleep()
{
$data = array_keys($this->toArray(BasePeer::TYPE_FIELDNAME));
$data[] = 'current_i18n';
$data[] = 'culture';
return $data;
}
public function __wakeup()
{
$this->setNew(false);
$this->resetModified();
}
public function __serialize()
{
$data = $this->toArray(BasePeer::TYPE_FIELDNAME);
$i18ns = array();
foreach ($this->current_i18n as $culture => $i18n)
{
$i18ns[$culture] = $i18n->toArray(BasePeer::TYPE_FIELDNAME);
}
$data['current_i18n'] = $i18ns;
$data['culture'] = $this->culture;
return $data;
}
public function __unserialize(array $data)
{
$this->fromArray($data, BasePeer::TYPE_FIELDNAME);
foreach ($data['current_i18n'] as $culture => $i18nData)
{
$i18n = new CountriesI18n();
$i18n->fromArray($i18nData, BasePeer::TYPE_FIELDNAME);
$i18n->resetModified();
$i18n->setNew(false);
$this->setCountriesI18nForCulture($i18n, $culture);
}
$this->setCulture($data['culture']);
$this->setNew(false);
$this->resetModified();
}
/**
* Przekaztwanie nazwy kraju
*
* @return string
*/
public function __toString()
{
return $this->getName();
}
/**
* Przeciążenie hydrate
*
* @param ResultSet $rs
* @param int $startcol
* @return object
*/
public function hydrate(ResultSet $rs, $startcol = 1)
{
$this->setCulture(stLanguage::getHydrateCulture());
return parent::hydrate($rs, $startcol);
}
/**
* Przeciążenie getName
*
* @return string
*/
public function getName()
{
if ($this->getCulture() == stLanguage::getOptLanguage())
{
return stLanguage::getDefaultValue($this, __METHOD__);
}
$v = parent::getName();
if (is_null($v)) $v = stLanguage::getDefaultValue($this, __METHOD__);
return $v;
}
/**
* Przeciążenie setName
*
* @param string $v
*/
public function setName($v)
{
if ($this->getCulture() == stLanguage::getOptLanguage())
{
stLanguage::setDefaultValue($this, __METHOD__, $v);
}
parent::setName($v);
}
/**
*
* Alias dla metody setName dodany na potrzeby admin generatora
*
* @param string $v Nazwa kraju
*/
public function setEditName($v)
{
$this->setName($v);
}
public function save($con = null)
{
if ($this->getIsDefault() && $this->isColumnModified(CountriesPeer::IS_DEFAULT))
{
$country = CountriesPeer::doSelectDefault(new Criteria(), $con);
if ($country)
{
$country->setIsDefault(false);
$country->save($con);
}
}
$ret = parent::save($con);
self::clearCache();
return $ret;
}
public function delete($con = null)
{
$ret = parent::delete($con);
self::clearCache();
return $ret;
}
public function isEU()
{
return CountriesPeer::isEuCountryCode($this->iso_a2);
}
public static function clearCache()
{
stFunctionCache::getInstance('stCountriesPlugin')->removeAll();
}
}

View File

@@ -0,0 +1,119 @@
<?php
/**
* SOTESHOP/stCountriesPlugin
*
* Ten plik należy do aplikacji stCountriesPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stCountriesPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: CountriesArea.php 227 2009-09-02 10:44:09Z marcin $
* @author Marcin Olejniczak <marcin.olejniczak@sote.pl>
*/
/**
* Klasa CountriesArea
*
* @package stCountriesPlugin
* @subpackage libs
*/
class CountriesArea extends BaseCountriesArea
{
/**
* Id przypisanych krajów
*
* @var array
*/
protected $countriesIds = null;
/**
* Pobierania nazwy kraju
*
* @return string
*/
public function __toString()
{
return $this->getName();
}
/**
*
* Metoda dodana na potrzeby admin generator - przypisuje przekazana liste krajow
*
* @param array $countries Lista krajow (format: array('id1', 'id2', ...))
*/
public function setCountriesIds($ids)
{
foreach($ids as $id)
{
$cahc = new CountriesAreaHasCountries();
$cahc->setCountriesId($id);
$this->addCountriesAreaHasCountries($cahc);
}
$this->countriesIds = $ids;
$this->modifiedColumns[] = 'countries_ids';
}
/**
* Metoda dodana na potrzeby admin generator - zwraca id przypisanych krajow
*
* @return array
*/
public function getCountriesIds()
{
if (null === $this->countriesIds)
{
$results = array();
foreach ($this->getCountriesAreaHasCountriess() as $area)
{
$results[] = $area->getCountriesId();
}
$this->countriesIds = $results;
}
return $this->countriesIds;
}
public function getAvailableCountries()
{
$c = new Criteria();
$c->add(CountriesPeer::IS_ACTIVE, true);
$c->addJoin(CountriesPeer::ID, CountriesAreaHasCountriesPeer::COUNTRIES_ID, Criteria::LEFT_JOIN);
$c1 = $c->getNewCriterion(CountriesAreaHasCountriesPeer::ID, null, Criteria::ISNULL);
$c1->addOr($c->getNewCriterion(CountriesAreaHasCountriesPeer::COUNTRIES_AREA_ID, $this->getId()));
$c->add($c1);
return CountriesPeer::doSelect($c);
}
public function save($con = null)
{
if (!$this->isNew() && $this->isColumnModified('countries_ids'))
{
$c = new Criteria();
$c->add(CountriesAreaHasCountriesPeer::COUNTRIES_AREA_ID, $this->getId());
CountriesAreaHasCountriesPeer::doDelete($c);
$this->resetModified('countries_ids');
}
return parent::save($con);
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* SOTESHOP/stCountriesPlugin
*
* Ten plik należy do aplikacji stCountriesPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stCountriesPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: CountriesAreaHasCountries.php 4 2009-08-24 08:52:56Z marcin $
* @author Marcin Olejniczak <marcin.olejniczak@sote.pl>
*/
/**
* Klasa CountriesAreaHasCountries
*
* @package stCountriesPlugin
* @subpackage libs
*/
class CountriesAreaHasCountries extends BaseCountriesAreaHasCountries
{
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* SOTESHOP/stCountriesPlugin
*
* Ten plik należy do aplikacji stCountriesPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stCountriesPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: CountriesAreaHasCountriesPeer.php 4 2009-08-24 08:52:56Z marcin $
* @author Marcin Olejniczak <marcin.olejniczak@sote.pl>
*/
/**
* Klasa CountriesAreaHasCountriesPeer
*
* @package stCountriesPlugin
* @subpackage libs
*/
class CountriesAreaHasCountriesPeer extends BaseCountriesAreaHasCountriesPeer
{
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* SOTESHOP/stCountriesPlugin
*
* Ten plik należy do aplikacji stCountriesPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stCountriesPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: CountriesAreaPeer.php 552 2009-09-16 11:22:06Z marcin $
* @author Marcin Olejniczak <marcin.olejniczak@sote.pl>
*/
/**
* Klasa CountriesAreaPeer
*
* @package stCountriesPlugin
* @subpackage libs
*/
class CountriesAreaPeer extends BaseCountriesAreaPeer
{
public static function doSelectActive(Criteria $c, $con = null)
{
$c = clone $c;
$c->addAscendingOrderByColumn(self::NAME . ' COLLATE utf8_polish_ci');
$c->add(self::IS_ACTIVE, true);
return self::doSelect($c, $con);
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Subclass for representing a row from the 'st_producer_i18n' table.
*
*
*
* @package lib.model
*/
class CountriesI18n extends BaseCountriesI18n
{
public function __sleep()
{
return array_keys($this->toArray(BasePeer::TYPE_FIELDNAME));
}
public function __wakeup()
{
$this->setNew(false);
$this->resetModified();
}
public function __serialize()
{
return $this->toArray(BasePeer::TYPE_FIELDNAME);
}
public function __unserialize(array $data)
{
$this->fromArray($data, BasePeer::TYPE_FIELDNAME);
$this->setNew(false);
$this->resetModified();
}
}

View File

@@ -0,0 +1,12 @@
<?php
/**
* Subclass for performing query and update operations on the 'st_producer_i18n' table.
*
*
*
* @package lib.model
*/
class CountriesI18nPeer extends BaseCountriesI18nPeer
{
}

View File

@@ -0,0 +1,259 @@
<?php
/**
* SOTESHOP/stCountriesPlugin
*
* Ten plik należy do aplikacji stCountriesPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stCountriesPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: CountriesPeer.php 10420 2011-01-21 13:20:27Z michal $
* @author Marcin Olejniczak <marcin.olejniczak@sote.pl>
*/
/**
* Klasa CountriesPeer
*
* @package stCountriesPlugin
* @subpackage libs
*/
class CountriesPeer extends BaseCountriesPeer
{
protected static $countriesCached = array();
/**
* Zwraca listę kodów krajów należących do UE
*
* @return array
*/
public static function getEUCountryCodes()
{
return array('AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL' , 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'MC', 'XI');
}
public static function isEuCountryCode($isoA2Code)
{
return in_array($isoA2Code, self::getEUCountryCodes());
}
/**
* Zwraca tablicę krajów EU
*
* @return Countries[]
*/
public static function doSelectEuCountries()
{
$c = new Criteria();
$c->add(self::ISO_A2, self::getEUCountryCodes(), Criteria::IN);
return self::doSelectWithIsoIndex($c);
}
/**
*
* Zwraca listę aktywnych krajów
*
* @param Criteria $c Kryteria
* @param CreoleConnection $con Połączenie propel
* @return Countries[]
*/
public static function doSelectActive(Criteria $c, $con = null)
{
$criteria = clone $c;
$culture = sfContext::getInstance()->getUser()->getCulture();
$criteria->addAscendingOrderByColumn(sprintf('IFNULL(%s, %s)', CountriesI18nPeer::NAME, CountriesPeer::OPT_NAME));
$criteria->add(CountriesPeer::IS_ACTIVE, true);
return self::doSelectWithI18n($criteria, $culture, $con);
}
public static function doSelectActiveCached($type = 'objects')
{
$culture = sfContext::getInstance()->getUser()->getCulture();
if (!isset(self::$countriesCached[$culture]))
{
$fc = stFunctionCache::getInstance('stCountriesPlugin');
self::$countriesCached[$culture] = $fc->cacheCall(array('CountriesPeer', 'doSelectActiveHelper'), array($culture));
}
return $type ? self::$countriesCached[$culture][$type] : self::$countriesCached[$culture];
}
/**
* Zwraca kraj po kodzie ISO A2
*
* @param string $iso
* @return Countries
* @throws sfCacheException
*/
public static function retrieveByIsoA2($iso)
{
$cache = self::doSelectActiveCached(null);
return isset($cache['iso_a2'][$iso]) ? $cache['objects'][$cache['iso_a2'][$iso]] : null;
}
public static function retrieveByOptName($name)
{
$c = new Criteria();
$c->add(self::OPT_NAME, $name);
return self::doSelectOne($c);
}
/**
* Zwraca kraj po kodzie ISO A3
*
* @param string $iso
* @return Countries
* @throws sfCacheException
*/
public static function retrieveByIsoA3($iso)
{
$cache = self::doSelectActiveCached(null);
return isset($cache['iso_a3'][$iso]) ? $cache['objects'][$cache['iso_a3'][$iso]] : null;
}
/**
* Zwraca domyślny kraj
*
* @return Countries
*/
public static function retrieveDefault()
{
$cache = self::doSelectActiveCached(null);
return self::retrieveById($cache['default']);
}
/**
* Zwraca kraj po ID
*
* @param int $id ID Kraju
* @return Countries
*/
public static function retrieveById($id)
{
$cache = self::doSelectActiveCached(null);
return isset($cache['id'][$id]) ? $cache['objects'][$cache['id'][$id]] : null;
}
public static function doSelectActiveHelper()
{
$result = array('objects' => array(), 'iso_a2' => array(), 'id' => array());
foreach (self::doSelectActive(new Criteria()) as $index => $country)
{
$result['objects'][$index] = $country;
$result['iso_a2'][$country->getIsoA2()] = $index;
$result['iso_a3'][$country->getIsoA3()] = $index;
$result['id'][$country->getId()] = $index;
if ($country->getIsDefault())
{
$result['default'] = $country->getId();
}
}
return $result;
}
public static function doSelectDefault(Criteria $c, $con = null)
{
$criteria = clone $c;
$criteria->add(self::IS_DEFAULT, true);
return self::doSelectOne($criteria, $con);
}
/**
*
* Zwraca listę aktywnych krajów
*
* @param Criteria $c Kryteria
* @param CreoleConnection $con Połączenie propel
* @return Countries[]
*/
public static function doSelectActiveBackend(Criteria $c, $con = null)
{
$criteria = clone $c;
$criteria->add(CountriesPeer::IS_ACTIVE, true);
$criteria->addAscendingOrderByColumn(self::OPT_NAME . ' COLLATE utf8_unicode_ci');
return self::doSelect($criteria, $con);
}
public static function doCountActive(Criteria $c, $con = null)
{
$criteria = clone $c;
$criteria->add(CountriesPeer::IS_ACTIVE, true);
return self::doCount($criteria, false, $con);
}
/**
* Przeciążenie metody pobierającej kraje w odpowiedniej wersji jezykowej
*
* @param Criteria $c Kryteria
* @param mixed $culture Wersja językowa
* @param CreoleConnection $con Połączenie z bazą danych
* @return array Produkty
*/
public static function doSelectWithI18n(Criteria $c, $culture = null, $con = null)
{
if ($culture === null)
{
$culture = stLanguage::getHydrateCulture();
}
return parent::doSelectWithI18n($c, $culture, $con);
}
public static function doCountWithI18n(Criteria $c, $con = null)
{
$c->addJoin(CountriesI18nPeer::ID, CountriesPeer::ID);
$c->add(CountriesI18nPeer::CULTURE, stLanguage::getHydrateCulture());
return self::doCount($c, $con);
}
/**
* Zwraca tablice krajów z indeksem kodu ISO
*
* @param Criteria $c Kryteria
* @return Countries[]
*/
public static function doSelectWithIsoIndex(Criteria $c)
{
$c = clone $c;
$c->addAscendingOrderByColumn(CountriesI18nPeer::NAME);
self::setHydrateMethod(function(ResultSet $rs) {
$results = array();
while($rs->next())
{
$country = new Countries();
$country->hydrate($rs);
$results[$country->getIsoA2()] = $country;
}
});
$results = self::doSelectWithI18n($c);
self::setHydrateMethod(null);
return $results;
}
}

View File

@@ -0,0 +1,27 @@
<?php
/**
* SOTESHOP/stCountriesPlugin
*
* Ten plik należy do aplikacji stCountriesPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stCountriesPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: DeliveryHasCountriesArea.php 4 2009-08-24 08:52:56Z marcin $
* @author Marcin Olejniczak <marcin.olejniczak@sote.pl>
*/
/**
* stCountriesPlugin actions.
* Klasa DeliveryHasCountriesArea
*
* @package stCountriesPlugin
* @subpackage libs
*/
class DeliveryHasCountriesArea extends BaseDeliveryHasCountriesArea
{
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* SOTESHOP/stCountriesPlugin
*
* Ten plik należy do aplikacji stCountriesPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stCountriesPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: DeliveryHasCountriesAreaPeer.php 4 2009-08-24 08:52:56Z marcin $
* @author Marcin Olejniczak <marcin.olejniczak@sote.pl>
*/
/**
* Klasa DeliveryHasCountriesAreaPeer
*
* @package stCountriesPlugin
* @subpackage libs
*/
class DeliveryHasCountriesAreaPeer extends BaseDeliveryHasCountriesAreaPeer
{
}

View File

@@ -0,0 +1,76 @@
<?php
/**
* This class adds structure of 'st_countries_area_has_countries' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.stCountriesPlugin.lib.model.map
*/
class CountriesAreaHasCountriesMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stCountriesPlugin.lib.model.map.CountriesAreaHasCountriesMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_countries_area_has_countries');
$tMap->setPhpName('CountriesAreaHasCountries');
$tMap->setUseIdGenerator(true);
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addForeignKey('COUNTRIES_ID', 'CountriesId', 'int', CreoleTypes::INTEGER, 'st_countries', 'ID', true, null);
$tMap->addForeignKey('COUNTRIES_AREA_ID', 'CountriesAreaId', 'int', CreoleTypes::INTEGER, 'st_countries_area', 'ID', true, null);
} // doBuild()
} // CountriesAreaHasCountriesMapBuilder

View File

@@ -0,0 +1,76 @@
<?php
/**
* This class adds structure of 'st_countries_area' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.stCountriesPlugin.lib.model.map
*/
class CountriesAreaMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stCountriesPlugin.lib.model.map.CountriesAreaMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_countries_area');
$tMap->setPhpName('CountriesArea');
$tMap->setUseIdGenerator(true);
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('IS_ACTIVE', 'IsActive', 'boolean', CreoleTypes::BOOLEAN, false, null);
} // doBuild()
} // CountriesAreaMapBuilder

View File

@@ -0,0 +1,72 @@
<?php
/**
* This class adds structure of 'st_countries_i18n' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.stCountriesPlugin.lib.model.map
*/
class CountriesI18nMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stCountriesPlugin.lib.model.map.CountriesI18nMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_countries_i18n');
$tMap->setPhpName('CountriesI18n');
$tMap->setUseIdGenerator(false);
$tMap->addForeignPrimaryKey('ID', 'Id', 'int' , CreoleTypes::INTEGER, 'st_countries', 'ID', true, null);
$tMap->addPrimaryKey('CULTURE', 'Culture', 'string', CreoleTypes::VARCHAR, true, 7);
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, false, 255);
} // doBuild()
} // CountriesI18nMapBuilder

View File

@@ -0,0 +1,86 @@
<?php
/**
* This class adds structure of 'st_countries' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.stCountriesPlugin.lib.model.map
*/
class CountriesMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stCountriesPlugin.lib.model.map.CountriesMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_countries');
$tMap->setPhpName('Countries');
$tMap->setUseIdGenerator(true);
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('ISO_A2', 'IsoA2', 'string', CreoleTypes::CHAR, false, 2);
$tMap->addColumn('ISO_A3', 'IsoA3', 'string', CreoleTypes::CHAR, false, 3);
$tMap->addColumn('CONTINENT', 'Continent', 'string', CreoleTypes::LONGVARCHAR, false, null);
$tMap->addColumn('NUMBER', 'Number', 'string', CreoleTypes::VARCHAR, false, 3);
$tMap->addColumn('OPT_NAME', 'OptName', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('IS_ACTIVE', 'IsActive', 'boolean', CreoleTypes::BOOLEAN, false, null);
$tMap->addColumn('IS_DEFAULT', 'IsDefault', 'boolean', CreoleTypes::BOOLEAN, false, null);
} // doBuild()
} // CountriesMapBuilder

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,724 @@
<?php
/**
* Base static class for performing query and update operations on the 'st_countries_area' table.
*
*
*
* @package plugins.stCountriesPlugin.lib.model.om
*/
abstract class BaseCountriesAreaPeer {
/** the default database name for this class */
const DATABASE_NAME = 'propel';
/** the table name for this class */
const TABLE_NAME = 'st_countries_area';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'plugins.stCountriesPlugin.lib.model.CountriesArea';
/** The total number of columns. */
const NUM_COLUMNS = 5;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the CREATED_AT field */
const CREATED_AT = 'st_countries_area.CREATED_AT';
/** the column name for the UPDATED_AT field */
const UPDATED_AT = 'st_countries_area.UPDATED_AT';
/** the column name for the ID field */
const ID = 'st_countries_area.ID';
/** the column name for the NAME field */
const NAME = 'st_countries_area.NAME';
/** the column name for the IS_ACTIVE field */
const IS_ACTIVE = 'st_countries_area.IS_ACTIVE';
/** The PHP to DB Name Mapping */
private static $phpNameMap = null;
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('CreatedAt', 'UpdatedAt', 'Id', 'Name', 'IsActive', ),
BasePeer::TYPE_COLNAME => array (CountriesAreaPeer::CREATED_AT, CountriesAreaPeer::UPDATED_AT, CountriesAreaPeer::ID, CountriesAreaPeer::NAME, CountriesAreaPeer::IS_ACTIVE, ),
BasePeer::TYPE_FIELDNAME => array ('created_at', 'updated_at', 'id', 'name', 'is_active', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('CreatedAt' => 0, 'UpdatedAt' => 1, 'Id' => 2, 'Name' => 3, 'IsActive' => 4, ),
BasePeer::TYPE_COLNAME => array (CountriesAreaPeer::CREATED_AT => 0, CountriesAreaPeer::UPDATED_AT => 1, CountriesAreaPeer::ID => 2, CountriesAreaPeer::NAME => 3, CountriesAreaPeer::IS_ACTIVE => 4, ),
BasePeer::TYPE_FIELDNAME => array ('created_at' => 0, 'updated_at' => 1, 'id' => 2, 'name' => 3, 'is_active' => 4, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
protected static $hydrateMethod = null;
protected static $postHydrateMethod = null;
public static function setHydrateMethod($callback)
{
self::$hydrateMethod = $callback;
}
public static function setPostHydrateMethod($callback)
{
self::$postHydrateMethod = $callback;
}
/**
* @return MapBuilder the map builder for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getMapBuilder()
{
return BasePeer::getMapBuilder('plugins.stCountriesPlugin.lib.model.map.CountriesAreaMapBuilder');
}
/**
* Gets a map (hash) of PHP names to DB column names.
*
* @return array The PHP to DB name map for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
*/
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = CountriesAreaPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
/**
* Translates a fieldname to another type
*
* @param string $name field name
* @param string $fromType One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @param string $toType One of the class type constants
* @return string translated name of the field.
*/
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
/**
* Returns an array of of field names.
*
* @param string $type The type of fieldnames to return:
* One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return array A list of field names
*/
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
}
return self::$fieldNames[$type];
}
/**
* Convenience method which changes table.column to alias.column.
*
* Using this method you can maintain SQL abstraction while using column aliases.
* <code>
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
* </code>
* @param string $alias The alias for the current table.
* @param string $column The column name for current table. (i.e. CountriesAreaPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(CountriesAreaPeer::TABLE_NAME.'.', $alias.'.', $column);
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param criteria object containing the columns to add.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(CountriesAreaPeer::CREATED_AT);
$criteria->addSelectColumn(CountriesAreaPeer::UPDATED_AT);
$criteria->addSelectColumn(CountriesAreaPeer::ID);
$criteria->addSelectColumn(CountriesAreaPeer::NAME);
$criteria->addSelectColumn(CountriesAreaPeer::IS_ACTIVE);
if (stEventDispatcher::getInstance()->getListeners('CountriesAreaPeer.postAddSelectColumns')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'CountriesAreaPeer.postAddSelectColumns'));
}
}
const COUNT = 'COUNT(st_countries_area.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT st_countries_area.ID)';
/**
* Returns the number of rows matching criteria.
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
* @param Connection $con
* @return int Number of matching rows.
*/
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// clear out anything that might confuse the ORDER BY clause
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(CountriesAreaPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(CountriesAreaPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = CountriesAreaPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
// no rows returned; we infer that means 0 matches.
return 0;
}
}
/**
* Method to select one object from the DB.
*
* @param Criteria $criteria object used to create the SELECT statement.
* @param Connection $con
* @return CountriesArea
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = CountriesAreaPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
/**
* Method to do selects.
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con
* @return CountriesArea[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return CountriesAreaPeer::populateObjects(CountriesAreaPeer::doSelectRS($criteria, $con));
}
/**
* Prepares the Criteria object and uses the parent doSelect()
* method to get a ResultSet.
*
* Use this method directly if you want to just get the resultset
* (instead of an array of objects).
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return ResultSet The resultset object with numerically-indexed fields.
* @see BasePeer::doSelect()
*/
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
CountriesAreaPeer::addSelectColumns($criteria);
}
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
// BasePeer returns a Creole ResultSet, set to return
// rows indexed numerically.
$rs = BasePeer::doSelect($criteria, $con);
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
}
return $rs;
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(ResultSet $rs)
{
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
// set the class once to avoid overhead in the loop
$cls = CountriesAreaPeer::getOMClass();
$cls = Propel::import($cls);
// populate the object(s)
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
}
return $results;
}
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
/**
* The class that the Peer will make instances of.
*
* This uses a dot-path notation which is tranalted into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @return string path.to.ClassName
*/
public static function getOMClass()
{
return CountriesAreaPeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a CountriesArea or Criteria object.
*
* @param mixed $values Criteria or CountriesArea object containing data that is used to create the INSERT statement.
* @param Connection $con the connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($values, $con = null)
{
foreach (sfMixer::getCallables('BaseCountriesAreaPeer:doInsert:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseCountriesAreaPeer', $values, $con);
if (false !== $ret)
{
return $ret;
}
}
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} else {
$criteria = $values->buildCriteria(); // build Criteria from CountriesArea object
}
$criteria->remove(CountriesAreaPeer::ID); // remove pkey col since this table uses auto-increment
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
foreach (sfMixer::getCallables('BaseCountriesAreaPeer:doInsert:post') as $callable)
{
call_user_func($callable, 'BaseCountriesAreaPeer', $values, $con, $pk);
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a CountriesArea or Criteria object.
*
* @param mixed $values Criteria or CountriesArea object containing data that is used to create the UPDATE statement.
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
* @return int The number of affected rows (if supported by underlying database driver).
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doUpdate($values, $con = null)
{
foreach (sfMixer::getCallables('BaseCountriesAreaPeer:doUpdate:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseCountriesAreaPeer', $values, $con);
if (false !== $ret)
{
return $ret;
}
}
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
$comparison = $criteria->getComparison(CountriesAreaPeer::ID);
$selectCriteria->add(CountriesAreaPeer::ID, $criteria->remove(CountriesAreaPeer::ID), $comparison);
} else { // $values is CountriesArea object
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
}
// set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
foreach (sfMixer::getCallables('BaseCountriesAreaPeer:doUpdate:post') as $callable)
{
call_user_func($callable, 'BaseCountriesAreaPeer', $values, $con, $ret);
}
return $ret;
}
/**
* Method to DELETE all rows from the st_countries_area table.
*
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
$affectedRows += CountriesAreaPeer::doOnDeleteCascade(new Criteria(), $con);
CountriesAreaPeer::doOnDeleteSetNull(new Criteria(), $con);
$affectedRows += BasePeer::doDeleteAll(CountriesAreaPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a CountriesArea or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CountriesArea object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param Connection $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CountriesAreaPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof CountriesArea) {
$criteria = $values->buildPkeyCriteria();
} else {
// it must be the primary key
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(CountriesAreaPeer::ID, (array) $values, Criteria::IN);
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
$affectedRows += CountriesAreaPeer::doOnDeleteCascade($criteria, $con);CountriesAreaPeer::doOnDeleteSetNull($criteria, $con);
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* This is a method for emulating ON DELETE CASCADE for DBs that don't support this
* feature (like MySQL or SQLite).
*
* This method is not very speedy because it must perform a query first to get
* the implicated records and then perform the deletes by calling those Peer classes.
*
* This method should be used within a transaction if possible.
*
* @param Criteria $criteria
* @param Connection $con
* @return int The number of affected rows (if supported by underlying database driver).
*/
protected static function doOnDeleteCascade(Criteria $criteria, Connection $con)
{
// initialize var to track total num of affected rows
$affectedRows = 0;
// first find the objects that are implicated by the $criteria
$objects = CountriesAreaPeer::doSelect($criteria, $con);
foreach($objects as $obj) {
// delete related CountriesAreaHasCountries objects
$c = new Criteria();
$c->add(CountriesAreaHasCountriesPeer::COUNTRIES_AREA_ID, $obj->getId());
$affectedRows += CountriesAreaHasCountriesPeer::doDelete($c, $con);
}
return $affectedRows;
}
/**
* This is a method for emulating ON DELETE SET NULL DBs that don't support this
* feature (like MySQL or SQLite).
*
* This method is not very speedy because it must perform a query first to get
* the implicated records and then perform the deletes by calling those Peer classes.
*
* This method should be used within a transaction if possible.
*
* @param Criteria $criteria
* @param Connection $con
* @return void
*/
protected static function doOnDeleteSetNull(Criteria $criteria, Connection $con)
{
// first find the objects that are implicated by the $criteria
$objects = CountriesAreaPeer::doSelect($criteria, $con);
foreach($objects as $obj) {
// set fkey col in related Delivery rows to NULL
$selectCriteria = new Criteria(CountriesAreaPeer::DATABASE_NAME);
$updateValues = new Criteria(CountriesAreaPeer::DATABASE_NAME);
$selectCriteria->add(DeliveryPeer::COUNTRIES_AREA_ID, $obj->getId());
$updateValues->add(DeliveryPeer::COUNTRIES_AREA_ID, null);
BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
}
}
/**
* Validates all modified columns of given CountriesArea object.
* If parameter $columns is either a single column name or an array of column names
* than only those columns are validated.
*
* NOTICE: This does not apply to primary or foreign keys for now.
*
* @param CountriesArea $obj The object to validate.
* @param mixed $cols Column name or array of column names.
*
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
*/
public static function doValidate(CountriesArea $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(CountriesAreaPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(CountriesAreaPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(CountriesAreaPeer::DATABASE_NAME, CountriesAreaPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = CountriesAreaPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
/**
* Retrieve a single object by pkey.
*
* @param mixed $pk the primary key.
* @param Connection $con the connection to use
* @return CountriesArea
*/
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(CountriesAreaPeer::DATABASE_NAME);
$criteria->add(CountriesAreaPeer::ID, $pk);
$v = CountriesAreaPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
/**
* Retrieve multiple objects by pkey.
*
* @param array $pks List of primary keys
* @param Connection $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return CountriesArea[]
*/
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(CountriesAreaPeer::ID, $pks, Criteria::IN);
$objs = CountriesAreaPeer::doSelect($criteria, $con);
}
return $objs;
}
} // BaseCountriesAreaPeer
// static code to register the map builder for this Peer with the main Propel class
if (Propel::isInit()) {
// the MapBuilder classes register themselves with Propel during initialization
// so we need to load them here.
try {
BaseCountriesAreaPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
// even if Propel is not yet initialized, the map builder class can be registered
// now and then it will be loaded when Propel initializes.
Propel::registerMapBuilder('plugins.stCountriesPlugin.lib.model.map.CountriesAreaMapBuilder');
}

View File

@@ -0,0 +1,776 @@
<?php
/**
* Base class that represents a row from the 'st_countries_i18n' table.
*
*
*
* @package plugins.stCountriesPlugin.lib.model.om
*/
abstract class BaseCountriesI18n extends BaseObject implements Persistent {
protected static $dispatcher = null;
/**
* The value for the id field.
* @var int
*/
protected $id;
/**
* The value for the culture field.
* @var string
*/
protected $culture;
/**
* The value for the name field.
* @var string
*/
protected $name;
/**
* @var Countries
*/
protected $aCountries;
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInSave = false;
/**
* Flag to prevent endless validation loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInValidation = false;
/**
* Get the [id] column value.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Get the [culture] column value.
*
* @return string
*/
public function getCulture()
{
return $this->culture;
}
/**
* Get the [name] column value.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set the value of [id] column.
*
* @param int $v new value
* @return void
*/
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = CountriesI18nPeer::ID;
}
if ($this->aCountries !== null && $this->aCountries->getId() !== $v) {
$this->aCountries = null;
}
} // setId()
/**
* Set the value of [culture] column.
*
* @param string $v new value
* @return void
*/
public function setCulture($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->culture !== $v) {
$this->culture = $v;
$this->modifiedColumns[] = CountriesI18nPeer::CULTURE;
}
} // setCulture()
/**
* Set the value of [name] column.
*
* @param string $v new value
* @return void
*/
public function setName($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->name !== $v) {
$this->name = $v;
$this->modifiedColumns[] = CountriesI18nPeer::NAME;
}
} // setName()
/**
* Hydrates (populates) the object variables with values from the database resultset.
*
* An offset (1-based "start column") is specified so that objects can be hydrated
* with a subset of the columns in the resultset rows. This is needed, for example,
* for results of JOIN queries where the resultset row includes columns from two or
* more tables.
*
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
* @return int next starting column
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
*/
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
if ($this->getDispatcher()->getListeners('CountriesI18n.preHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'CountriesI18n.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
$startcol = $event['startcol'];
}
$this->id = $rs->getInt($startcol + 0);
$this->culture = $rs->getString($startcol + 1);
$this->name = $rs->getString($startcol + 2);
$this->resetModified();
$this->setNew(false);
if ($this->getDispatcher()->getListeners('CountriesI18n.postHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'CountriesI18n.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 3)));
return $event['startcol'];
}
// FIXME - using NUM_COLUMNS may be clearer.
return $startcol + 3; // 3 = CountriesI18nPeer::NUM_COLUMNS - CountriesI18nPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating CountriesI18n object", $e);
}
}
/**
* Removes this object from datastore and sets delete attribute.
*
* @param Connection $con
* @return void
* @throws PropelException
* @see BaseObject::setDeleted()
* @see BaseObject::isDeleted()
*/
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($this->getDispatcher()->getListeners('CountriesI18n.preDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'CountriesI18n.preDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BaseCountriesI18n:delete:pre'))
{
foreach (sfMixer::getCallables('BaseCountriesI18n:delete:pre') as $callable)
{
$ret = call_user_func($callable, $this, $con);
if ($ret)
{
return;
}
}
}
if ($con === null) {
$con = Propel::getConnection(CountriesI18nPeer::DATABASE_NAME);
}
try {
$con->begin();
CountriesI18nPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
if ($this->getDispatcher()->getListeners('CountriesI18n.postDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'CountriesI18n.postDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BaseCountriesI18n:delete:post'))
{
foreach (sfMixer::getCallables('BaseCountriesI18n:delete:post') as $callable)
{
call_user_func($callable, $this, $con);
}
}
}
/**
* Stores the object in the database. If the object is new,
* it inserts it; otherwise an update is performed. This method
* wraps the doSave() worker method in a transaction.
*
* @param Connection $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see doSave()
*/
public function save($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if (!$this->alreadyInSave) {
if ($this->getDispatcher()->getListeners('CountriesI18n.preSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'CountriesI18n.preSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BaseCountriesI18n:save:pre') as $callable)
{
$affectedRows = call_user_func($callable, $this, $con);
if (is_int($affectedRows))
{
return $affectedRows;
}
}
}
if ($con === null) {
$con = Propel::getConnection(CountriesI18nPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
if (!$this->alreadyInSave) {
if ($this->getDispatcher()->getListeners('CountriesI18n.postSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'CountriesI18n.postSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BaseCountriesI18n:save:post') as $callable)
{
call_user_func($callable, $this, $con, $affectedRows);
}
}
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Stores the object in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param Connection $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave($con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aCountries !== null) {
if ($this->aCountries->isModified() || $this->aCountries->getCurrentCountriesI18n()->isModified()) {
$affectedRows += $this->aCountries->save($con);
}
$this->setCountries($this->aCountries);
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = CountriesI18nPeer::doInsert($this, $con);
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
// should always be true here (even though technically
// BasePeer::doInsert() can insert multiple rows).
$this->setNew(false);
} else {
$affectedRows += CountriesI18nPeer::doUpdate($this, $con);
}
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
}
$this->alreadyInSave = false;
}
return $affectedRows;
} // doSave()
/**
* Array of ValidationFailed objects.
* @var array ValidationFailed[]
*/
protected $validationFailures = array();
/**
* Gets any ValidationFailed objects that resulted from last call to validate().
*
*
* @return array ValidationFailed[]
* @see validate()
*/
public function getValidationFailures()
{
return $this->validationFailures;
}
/**
* Validates the objects modified field values and all objects related to this table.
*
* If $columns is either a column name or an array of column names
* only those columns are validated.
*
* @param mixed $columns Column name or an array of column names.
* @return boolean Whether all columns pass validation.
* @see doValidate()
* @see getValidationFailures()
*/
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
/**
* This function performs the validation work for complex object models.
*
* In addition to checking the current object, all related objects will
* also be validated. If all pass then <code>true</code> is returned; otherwise
* an aggreagated array of ValidationFailed objects will be returned.
*
* @param array $columns Array of column names to validate.
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
*/
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aCountries !== null) {
if (!$this->aCountries->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aCountries->getValidationFailures());
}
}
if (($retval = CountriesI18nPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
/**
* Retrieves a field from the object by name passed in as a string.
*
* @param string $name name
* @param string $type The type of fieldname the $name is of:
* one of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return mixed Value of field.
*/
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = CountriesI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
/**
* Retrieves a field from the object by Position as specified in the xml schema.
* Zero-based.
*
* @param int $pos position in xml schema
* @return mixed Value of field at $pos
*/
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getCulture();
break;
case 2:
return $this->getName();
break;
default:
return null;
break;
} // switch()
}
/**
* Exports the object as an array.
*
* You can specify the key type of the array by passing one of the class
* type constants.
*
* @param string $keyType One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return an associative array containing the field names (as keys) and field values
*/
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = CountriesI18nPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getCulture(),
$keys[2] => $this->getName(),
);
return $result;
}
/**
* Sets a field from the object by name passed in as a string.
*
* @param string $name peer name
* @param mixed $value field value
* @param string $type The type of fieldname the $name is of:
* one of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return void
*/
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = CountriesI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
/**
* Sets a field from the object by Position as specified in the xml schema.
* Zero-based.
*
* @param int $pos position in xml schema
* @param mixed $value field value
* @return void
*/
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setCulture($value);
break;
case 2:
$this->setName($value);
break;
} // switch()
}
/**
* Populates the object using an array.
*
* This is particularly useful when populating an object from one of the
* request arrays (e.g. $_POST). This method goes through the column
* names, checking to see whether a matching key exists in populated
* array. If so the setByName() method is called for that column.
*
* You can specify the key type of the array by additionally passing one
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
*
* @param array $arr An array to populate the object from.
* @param string $keyType The type of keys the array uses.
* @return void
*/
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = CountriesI18nPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setCulture($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setName($arr[$keys[2]]);
}
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(CountriesI18nPeer::DATABASE_NAME);
if ($this->isColumnModified(CountriesI18nPeer::ID)) $criteria->add(CountriesI18nPeer::ID, $this->id);
if ($this->isColumnModified(CountriesI18nPeer::CULTURE)) $criteria->add(CountriesI18nPeer::CULTURE, $this->culture);
if ($this->isColumnModified(CountriesI18nPeer::NAME)) $criteria->add(CountriesI18nPeer::NAME, $this->name);
return $criteria;
}
/**
* Builds a Criteria object containing the primary key for this object.
*
* Unlike buildCriteria() this method includes the primary key values regardless
* of whether or not they have been modified.
*
* @return Criteria The Criteria object containing value(s) for primary key(s).
*/
public function buildPkeyCriteria()
{
$criteria = new Criteria(CountriesI18nPeer::DATABASE_NAME);
$criteria->add(CountriesI18nPeer::ID, $this->id);
$criteria->add(CountriesI18nPeer::CULTURE, $this->culture);
return $criteria;
}
/**
* Returns the composite primary key for this object.
* The array elements will be in same order as specified in XML.
* @return array
*/
public function getPrimaryKey()
{
return array($this->getId(), $this->getCulture());
}
/**
* Returns [composite] primary key fields
*
* @param string $keyType
* @return array
*/
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
{
return array(CountriesI18nPeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType), CountriesI18nPeer::translateFieldName('culture', BasePeer::TYPE_FIELDNAME, $keyType));
}
/**
* Set the [composite] primary key.
*
* @param array $keys The elements of the composite key (order must match the order in XML file).
* @return void
*/
public function setPrimaryKey($keys)
{
$this->setId($keys[0]);
$this->setCulture($keys[1]);
}
/**
* Sets contents of passed object to values from current object.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param object $copyObj An object of CountriesI18n (or compatible) type.
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @throws PropelException
*/
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setName($this->name);
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a pkey column, so set to default value
$copyObj->setCulture(NULL); // this is a pkey column, so set to default value
}
/**
* Makes a copy of this object that will be inserted as a new row in table when saved.
* It creates a new object filling in the simple attributes, but skipping any primary
* keys that are defined for the table.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @return CountriesI18n Clone of current object.
* @throws PropelException
*/
public function copy($deepCopy = false)
{
// we use get_class(), because this might be a subclass
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
/**
* Returns a peer instance associated with this om.
*
* @return string Peer class name
*/
public function getPeer()
{
return 'CountriesI18nPeer';
}
/**
* Declares an association between this object and a Countries object.
*
* @param Countries $v
* @return void
* @throws PropelException
*/
public function setCountries($v)
{
if ($v === null) {
$this->setId(NULL);
} else {
$this->setId($v->getId());
}
$this->aCountries = $v;
}
/**
* Get the associated Countries object
*
* @param Connection Optional Connection object.
* @return Countries The associated Countries object.
* @throws PropelException
*/
public function getCountries($con = null)
{
if ($this->aCountries === null && ($this->id !== null)) {
// include the related Peer class
$this->aCountries = CountriesPeer::retrieveByPK($this->id, $con);
/* The following can be used instead of the line above to
guarantee the related object contains a reference
to this object, but this level of coupling
may be undesirable in many circumstances.
As it can lead to a db query with many results that may
never be used.
$obj = CountriesPeer::retrieveByPK($this->id, $con);
$obj->addCountriess($this);
*/
}
return $this->aCountries;
}
public function getDispatcher()
{
if (null === self::$dispatcher)
{
self::$dispatcher = stEventDispatcher::getInstance();
}
return self::$dispatcher;
}
public function __call($method, $arguments)
{
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'CountriesI18n.' . $method, array('arguments' => $arguments, 'method' => $method)));
if ($event->isProcessed())
{
return $event->getReturnValue();
}
if (!$callable = sfMixer::getCallable('BaseCountriesI18n:'.$method))
{
throw new sfException(sprintf('Call to undefined method BaseCountriesI18n::%s', $method));
}
array_unshift($arguments, $this);
return call_user_func_array($callable, $arguments);
}
} // BaseCountriesI18n

View File

@@ -0,0 +1,834 @@
<?php
/**
* Base static class for performing query and update operations on the 'st_countries_i18n' table.
*
*
*
* @package plugins.stCountriesPlugin.lib.model.om
*/
abstract class BaseCountriesI18nPeer {
/** the default database name for this class */
const DATABASE_NAME = 'propel';
/** the table name for this class */
const TABLE_NAME = 'st_countries_i18n';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'plugins.stCountriesPlugin.lib.model.CountriesI18n';
/** The total number of columns. */
const NUM_COLUMNS = 3;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the ID field */
const ID = 'st_countries_i18n.ID';
/** the column name for the CULTURE field */
const CULTURE = 'st_countries_i18n.CULTURE';
/** the column name for the NAME field */
const NAME = 'st_countries_i18n.NAME';
/** The PHP to DB Name Mapping */
private static $phpNameMap = null;
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'Culture', 'Name', ),
BasePeer::TYPE_COLNAME => array (CountriesI18nPeer::ID, CountriesI18nPeer::CULTURE, CountriesI18nPeer::NAME, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'culture', 'name', ),
BasePeer::TYPE_NUM => array (0, 1, 2, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Culture' => 1, 'Name' => 2, ),
BasePeer::TYPE_COLNAME => array (CountriesI18nPeer::ID => 0, CountriesI18nPeer::CULTURE => 1, CountriesI18nPeer::NAME => 2, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'culture' => 1, 'name' => 2, ),
BasePeer::TYPE_NUM => array (0, 1, 2, )
);
protected static $hydrateMethod = null;
protected static $postHydrateMethod = null;
public static function setHydrateMethod($callback)
{
self::$hydrateMethod = $callback;
}
public static function setPostHydrateMethod($callback)
{
self::$postHydrateMethod = $callback;
}
/**
* @return MapBuilder the map builder for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getMapBuilder()
{
return BasePeer::getMapBuilder('plugins.stCountriesPlugin.lib.model.map.CountriesI18nMapBuilder');
}
/**
* Gets a map (hash) of PHP names to DB column names.
*
* @return array The PHP to DB name map for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
*/
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = CountriesI18nPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
/**
* Translates a fieldname to another type
*
* @param string $name field name
* @param string $fromType One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @param string $toType One of the class type constants
* @return string translated name of the field.
*/
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
/**
* Returns an array of of field names.
*
* @param string $type The type of fieldnames to return:
* One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return array A list of field names
*/
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
}
return self::$fieldNames[$type];
}
/**
* Convenience method which changes table.column to alias.column.
*
* Using this method you can maintain SQL abstraction while using column aliases.
* <code>
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
* </code>
* @param string $alias The alias for the current table.
* @param string $column The column name for current table. (i.e. CountriesI18nPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(CountriesI18nPeer::TABLE_NAME.'.', $alias.'.', $column);
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param criteria object containing the columns to add.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(CountriesI18nPeer::ID);
$criteria->addSelectColumn(CountriesI18nPeer::CULTURE);
$criteria->addSelectColumn(CountriesI18nPeer::NAME);
if (stEventDispatcher::getInstance()->getListeners('CountriesI18nPeer.postAddSelectColumns')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'CountriesI18nPeer.postAddSelectColumns'));
}
}
const COUNT = 'COUNT(st_countries_i18n.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT st_countries_i18n.ID)';
/**
* Returns the number of rows matching criteria.
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
* @param Connection $con
* @return int Number of matching rows.
*/
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// clear out anything that might confuse the ORDER BY clause
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(CountriesI18nPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(CountriesI18nPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = CountriesI18nPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
// no rows returned; we infer that means 0 matches.
return 0;
}
}
/**
* Method to select one object from the DB.
*
* @param Criteria $criteria object used to create the SELECT statement.
* @param Connection $con
* @return CountriesI18n
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = CountriesI18nPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
/**
* Method to do selects.
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con
* @return CountriesI18n[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return CountriesI18nPeer::populateObjects(CountriesI18nPeer::doSelectRS($criteria, $con));
}
/**
* Prepares the Criteria object and uses the parent doSelect()
* method to get a ResultSet.
*
* Use this method directly if you want to just get the resultset
* (instead of an array of objects).
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return ResultSet The resultset object with numerically-indexed fields.
* @see BasePeer::doSelect()
*/
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
CountriesI18nPeer::addSelectColumns($criteria);
}
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
// BasePeer returns a Creole ResultSet, set to return
// rows indexed numerically.
$rs = BasePeer::doSelect($criteria, $con);
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
}
return $rs;
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(ResultSet $rs)
{
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
// set the class once to avoid overhead in the loop
$cls = CountriesI18nPeer::getOMClass();
$cls = Propel::import($cls);
// populate the object(s)
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
}
return $results;
}
/**
* Returns the number of rows matching criteria, joining the related Countries table
*
* @param Criteria $c
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
* @param Connection $con
* @return int Number of matching rows.
*/
public static function doCountJoinCountries(Criteria $criteria, $distinct = false, $con = null)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// clear out anything that might confuse the ORDER BY clause
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(CountriesI18nPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(CountriesI18nPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(CountriesI18nPeer::ID, CountriesPeer::ID);
$rs = CountriesI18nPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
// no rows returned; we infer that means 0 matches.
return 0;
}
}
/**
* Selects a collection of CountriesI18n objects pre-filled with their Countries objects.
*
* @return CountriesI18n[] Array of CountriesI18n objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinCountries(Criteria $c, $con = null)
{
$c = clone $c;
// Set the correct dbName if it has not been overridden
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
CountriesI18nPeer::addSelectColumns($c);
CountriesPeer::addSelectColumns($c);
$c->addJoin(CountriesI18nPeer::ID, CountriesPeer::ID);
$rs = CountriesI18nPeer::doSelectRs($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$obj1 = new CountriesI18n();
$startcol = $obj1->hydrate($rs);
if ($obj1->getId())
{
$obj2 = new Countries();
$obj2->hydrate($rs, $startcol);
$obj2->addCountriesI18n($obj1);
}
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;;
}
return $results;
}
/**
* Returns the number of rows matching criteria, joining all related tables
*
* @param Criteria $c
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
* @param Connection $con
* @return int Number of matching rows.
*/
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
// clear out anything that might confuse the ORDER BY clause
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(CountriesI18nPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(CountriesI18nPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(CountriesI18nPeer::ID, CountriesPeer::ID);
$rs = CountriesI18nPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
// no rows returned; we infer that means 0 matches.
return 0;
}
}
/**
* Selects a collection of CountriesI18n objects pre-filled with all related objects.
*
* @return CountriesI18n[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinAll(Criteria $c, $con = null)
{
$c = clone $c;
// Set the correct dbName if it has not been overridden
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
CountriesI18nPeer::addSelectColumns($c);
$startcol2 = (CountriesI18nPeer::NUM_COLUMNS - CountriesI18nPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
CountriesPeer::addSelectColumns($c);
$startcol3 = $startcol2 + CountriesPeer::NUM_COLUMNS;
$c->addJoin(CountriesI18nPeer::ID, CountriesPeer::ID);
$rs = BasePeer::doSelect($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$omClass = CountriesI18nPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
// Add objects for joined Countries rows
$omClass = CountriesPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol2);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj2 = $temp_obj1->getCountries(); // CHECKME
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addCountriesI18n($obj1); // CHECKME
break;
}
}
if ($newObject) {
$obj2->initCountriesI18ns();
$obj2->addCountriesI18n($obj1);
}
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
}
return $results;
}
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
/**
* The class that the Peer will make instances of.
*
* This uses a dot-path notation which is tranalted into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @return string path.to.ClassName
*/
public static function getOMClass()
{
return CountriesI18nPeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a CountriesI18n or Criteria object.
*
* @param mixed $values Criteria or CountriesI18n object containing data that is used to create the INSERT statement.
* @param Connection $con the connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($values, $con = null)
{
foreach (sfMixer::getCallables('BaseCountriesI18nPeer:doInsert:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseCountriesI18nPeer', $values, $con);
if (false !== $ret)
{
return $ret;
}
}
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} else {
$criteria = $values->buildCriteria(); // build Criteria from CountriesI18n object
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
foreach (sfMixer::getCallables('BaseCountriesI18nPeer:doInsert:post') as $callable)
{
call_user_func($callable, 'BaseCountriesI18nPeer', $values, $con, $pk);
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a CountriesI18n or Criteria object.
*
* @param mixed $values Criteria or CountriesI18n object containing data that is used to create the UPDATE statement.
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
* @return int The number of affected rows (if supported by underlying database driver).
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doUpdate($values, $con = null)
{
foreach (sfMixer::getCallables('BaseCountriesI18nPeer:doUpdate:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseCountriesI18nPeer', $values, $con);
if (false !== $ret)
{
return $ret;
}
}
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
$comparison = $criteria->getComparison(CountriesI18nPeer::ID);
$selectCriteria->add(CountriesI18nPeer::ID, $criteria->remove(CountriesI18nPeer::ID), $comparison);
$comparison = $criteria->getComparison(CountriesI18nPeer::CULTURE);
$selectCriteria->add(CountriesI18nPeer::CULTURE, $criteria->remove(CountriesI18nPeer::CULTURE), $comparison);
} else { // $values is CountriesI18n object
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
}
// set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
foreach (sfMixer::getCallables('BaseCountriesI18nPeer:doUpdate:post') as $callable)
{
call_user_func($callable, 'BaseCountriesI18nPeer', $values, $con, $ret);
}
return $ret;
}
/**
* Method to DELETE all rows from the st_countries_i18n table.
*
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
$affectedRows += BasePeer::doDeleteAll(CountriesI18nPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a CountriesI18n or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or CountriesI18n object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param Connection $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CountriesI18nPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof CountriesI18n) {
$criteria = $values->buildPkeyCriteria();
} else {
// it must be the primary key
$criteria = new Criteria(self::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey
// values
if(count($values) == count($values, COUNT_RECURSIVE))
{
// array is not multi-dimensional
$values = array($values);
}
$vals = array();
foreach($values as $value)
{
$vals[0][] = $value[0];
$vals[1][] = $value[1];
}
$criteria->add(CountriesI18nPeer::ID, $vals[0], Criteria::IN);
$criteria->add(CountriesI18nPeer::CULTURE, $vals[1], Criteria::IN);
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Validates all modified columns of given CountriesI18n object.
* If parameter $columns is either a single column name or an array of column names
* than only those columns are validated.
*
* NOTICE: This does not apply to primary or foreign keys for now.
*
* @param CountriesI18n $obj The object to validate.
* @param mixed $cols Column name or array of column names.
*
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
*/
public static function doValidate(CountriesI18n $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(CountriesI18nPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(CountriesI18nPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(CountriesI18nPeer::DATABASE_NAME, CountriesI18nPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = CountriesI18nPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
/**
* Retrieve object using using composite pkey values.
* @param int $id
@param string $culture
* @param Connection $con
* @return CountriesI18n
*/
public static function retrieveByPK( $id, $culture, $con = null) {
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria();
$criteria->add(CountriesI18nPeer::ID, $id);
$criteria->add(CountriesI18nPeer::CULTURE, $culture);
$v = CountriesI18nPeer::doSelect($criteria, $con);
return !empty($v) ? $v[0] : null;
}
} // BaseCountriesI18nPeer
// static code to register the map builder for this Peer with the main Propel class
if (Propel::isInit()) {
// the MapBuilder classes register themselves with Propel during initialization
// so we need to load them here.
try {
BaseCountriesI18nPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
// even if Propel is not yet initialized, the map builder class can be registered
// now and then it will be loaded when Propel initializes.
Propel::registerMapBuilder('plugins.stCountriesPlugin.lib.model.map.CountriesI18nMapBuilder');
}

View File

@@ -0,0 +1,828 @@
<?php
/**
* Base static class for performing query and update operations on the 'st_countries' table.
*
*
*
* @package plugins.stCountriesPlugin.lib.model.om
*/
abstract class BaseCountriesPeer {
/** the default database name for this class */
const DATABASE_NAME = 'propel';
/** the table name for this class */
const TABLE_NAME = 'st_countries';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'plugins.stCountriesPlugin.lib.model.Countries';
/** The total number of columns. */
const NUM_COLUMNS = 10;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the CREATED_AT field */
const CREATED_AT = 'st_countries.CREATED_AT';
/** the column name for the UPDATED_AT field */
const UPDATED_AT = 'st_countries.UPDATED_AT';
/** the column name for the ID field */
const ID = 'st_countries.ID';
/** the column name for the ISO_A2 field */
const ISO_A2 = 'st_countries.ISO_A2';
/** the column name for the ISO_A3 field */
const ISO_A3 = 'st_countries.ISO_A3';
/** the column name for the CONTINENT field */
const CONTINENT = 'st_countries.CONTINENT';
/** the column name for the NUMBER field */
const NUMBER = 'st_countries.NUMBER';
/** the column name for the OPT_NAME field */
const OPT_NAME = 'st_countries.OPT_NAME';
/** the column name for the IS_ACTIVE field */
const IS_ACTIVE = 'st_countries.IS_ACTIVE';
/** the column name for the IS_DEFAULT field */
const IS_DEFAULT = 'st_countries.IS_DEFAULT';
/** The PHP to DB Name Mapping */
private static $phpNameMap = null;
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('CreatedAt', 'UpdatedAt', 'Id', 'IsoA2', 'IsoA3', 'Continent', 'Number', 'OptName', 'IsActive', 'IsDefault', ),
BasePeer::TYPE_COLNAME => array (CountriesPeer::CREATED_AT, CountriesPeer::UPDATED_AT, CountriesPeer::ID, CountriesPeer::ISO_A2, CountriesPeer::ISO_A3, CountriesPeer::CONTINENT, CountriesPeer::NUMBER, CountriesPeer::OPT_NAME, CountriesPeer::IS_ACTIVE, CountriesPeer::IS_DEFAULT, ),
BasePeer::TYPE_FIELDNAME => array ('created_at', 'updated_at', 'id', 'iso_a2', 'iso_a3', 'continent', 'number', 'opt_name', 'is_active', 'is_default', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('CreatedAt' => 0, 'UpdatedAt' => 1, 'Id' => 2, 'IsoA2' => 3, 'IsoA3' => 4, 'Continent' => 5, 'Number' => 6, 'OptName' => 7, 'IsActive' => 8, 'IsDefault' => 9, ),
BasePeer::TYPE_COLNAME => array (CountriesPeer::CREATED_AT => 0, CountriesPeer::UPDATED_AT => 1, CountriesPeer::ID => 2, CountriesPeer::ISO_A2 => 3, CountriesPeer::ISO_A3 => 4, CountriesPeer::CONTINENT => 5, CountriesPeer::NUMBER => 6, CountriesPeer::OPT_NAME => 7, CountriesPeer::IS_ACTIVE => 8, CountriesPeer::IS_DEFAULT => 9, ),
BasePeer::TYPE_FIELDNAME => array ('created_at' => 0, 'updated_at' => 1, 'id' => 2, 'iso_a2' => 3, 'iso_a3' => 4, 'continent' => 5, 'number' => 6, 'opt_name' => 7, 'is_active' => 8, 'is_default' => 9, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
);
protected static $hydrateMethod = null;
protected static $postHydrateMethod = null;
public static function setHydrateMethod($callback)
{
self::$hydrateMethod = $callback;
}
public static function setPostHydrateMethod($callback)
{
self::$postHydrateMethod = $callback;
}
/**
* @return MapBuilder the map builder for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getMapBuilder()
{
return BasePeer::getMapBuilder('plugins.stCountriesPlugin.lib.model.map.CountriesMapBuilder');
}
/**
* Gets a map (hash) of PHP names to DB column names.
*
* @return array The PHP to DB name map for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
*/
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = CountriesPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
/**
* Translates a fieldname to another type
*
* @param string $name field name
* @param string $fromType One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @param string $toType One of the class type constants
* @return string translated name of the field.
*/
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
/**
* Returns an array of of field names.
*
* @param string $type The type of fieldnames to return:
* One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return array A list of field names
*/
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
}
return self::$fieldNames[$type];
}
/**
* Convenience method which changes table.column to alias.column.
*
* Using this method you can maintain SQL abstraction while using column aliases.
* <code>
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
* </code>
* @param string $alias The alias for the current table.
* @param string $column The column name for current table. (i.e. CountriesPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(CountriesPeer::TABLE_NAME.'.', $alias.'.', $column);
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param criteria object containing the columns to add.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(CountriesPeer::CREATED_AT);
$criteria->addSelectColumn(CountriesPeer::UPDATED_AT);
$criteria->addSelectColumn(CountriesPeer::ID);
$criteria->addSelectColumn(CountriesPeer::ISO_A2);
$criteria->addSelectColumn(CountriesPeer::ISO_A3);
$criteria->addSelectColumn(CountriesPeer::CONTINENT);
$criteria->addSelectColumn(CountriesPeer::NUMBER);
$criteria->addSelectColumn(CountriesPeer::OPT_NAME);
$criteria->addSelectColumn(CountriesPeer::IS_ACTIVE);
$criteria->addSelectColumn(CountriesPeer::IS_DEFAULT);
if (stEventDispatcher::getInstance()->getListeners('CountriesPeer.postAddSelectColumns')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'CountriesPeer.postAddSelectColumns'));
}
}
const COUNT = 'COUNT(st_countries.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT st_countries.ID)';
/**
* Returns the number of rows matching criteria.
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
* @param Connection $con
* @return int Number of matching rows.
*/
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// clear out anything that might confuse the ORDER BY clause
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(CountriesPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(CountriesPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = CountriesPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
// no rows returned; we infer that means 0 matches.
return 0;
}
}
/**
* Method to select one object from the DB.
*
* @param Criteria $criteria object used to create the SELECT statement.
* @param Connection $con
* @return Countries
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = CountriesPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
/**
* Method to do selects.
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con
* @return Countries[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return CountriesPeer::populateObjects(CountriesPeer::doSelectRS($criteria, $con));
}
/**
* Prepares the Criteria object and uses the parent doSelect()
* method to get a ResultSet.
*
* Use this method directly if you want to just get the resultset
* (instead of an array of objects).
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return ResultSet The resultset object with numerically-indexed fields.
* @see BasePeer::doSelect()
*/
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
CountriesPeer::addSelectColumns($criteria);
}
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
// BasePeer returns a Creole ResultSet, set to return
// rows indexed numerically.
$rs = BasePeer::doSelect($criteria, $con);
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
}
return $rs;
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(ResultSet $rs)
{
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
// set the class once to avoid overhead in the loop
$cls = CountriesPeer::getOMClass();
$cls = Propel::import($cls);
// populate the object(s)
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
}
return $results;
}
/**
* Selects a collection of Countries objects pre-filled with their i18n objects.
*
* @return array Array of Countries objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectWithI18n(Criteria $c, $culture = null, $con = null)
{
$c = clone $c;
if ($culture === null)
{
$culture = sfContext::getInstance()->getUser()->getCulture();
}
// Set the correct dbName if it has not been overridden
if ($c->getDbName() == Propel::getDefaultDB())
{
$c->setDbName(self::DATABASE_NAME);
}
if (!$c->getSelectColumns())
{
CountriesPeer::addSelectColumns($c);
CountriesI18nPeer::addSelectColumns($c);
}
$c->addJoin(CountriesPeer::ID, sprintf('%s AND %s = \'%s\'', CountriesI18nPeer::ID, CountriesI18nPeer::CULTURE, $culture), Criteria::LEFT_JOIN);
$rs = CountriesPeer::doSelectRs($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$obj1 = new Countries();
$startcol = $obj1->hydrate($rs);
$obj1->setCulture($culture);
$obj2 = new CountriesI18n();
$obj2->hydrate($rs, $startcol);
$obj1->setCountriesI18nForCulture($obj2, $culture);
$obj2->setCountries($obj1);
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
}
return $results;
}
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
/**
* The class that the Peer will make instances of.
*
* This uses a dot-path notation which is tranalted into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @return string path.to.ClassName
*/
public static function getOMClass()
{
return CountriesPeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a Countries or Criteria object.
*
* @param mixed $values Criteria or Countries object containing data that is used to create the INSERT statement.
* @param Connection $con the connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($values, $con = null)
{
foreach (sfMixer::getCallables('BaseCountriesPeer:doInsert:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseCountriesPeer', $values, $con);
if (false !== $ret)
{
return $ret;
}
}
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} else {
$criteria = $values->buildCriteria(); // build Criteria from Countries object
}
$criteria->remove(CountriesPeer::ID); // remove pkey col since this table uses auto-increment
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
foreach (sfMixer::getCallables('BaseCountriesPeer:doInsert:post') as $callable)
{
call_user_func($callable, 'BaseCountriesPeer', $values, $con, $pk);
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a Countries or Criteria object.
*
* @param mixed $values Criteria or Countries object containing data that is used to create the UPDATE statement.
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
* @return int The number of affected rows (if supported by underlying database driver).
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doUpdate($values, $con = null)
{
foreach (sfMixer::getCallables('BaseCountriesPeer:doUpdate:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseCountriesPeer', $values, $con);
if (false !== $ret)
{
return $ret;
}
}
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
$comparison = $criteria->getComparison(CountriesPeer::ID);
$selectCriteria->add(CountriesPeer::ID, $criteria->remove(CountriesPeer::ID), $comparison);
} else { // $values is Countries object
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
}
// set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
foreach (sfMixer::getCallables('BaseCountriesPeer:doUpdate:post') as $callable)
{
call_user_func($callable, 'BaseCountriesPeer', $values, $con, $ret);
}
return $ret;
}
/**
* Method to DELETE all rows from the st_countries table.
*
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
$affectedRows += CountriesPeer::doOnDeleteCascade(new Criteria(), $con);
CountriesPeer::doOnDeleteSetNull(new Criteria(), $con);
$affectedRows += BasePeer::doDeleteAll(CountriesPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a Countries or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or Countries object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param Connection $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(CountriesPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof Countries) {
$criteria = $values->buildPkeyCriteria();
} else {
// it must be the primary key
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(CountriesPeer::ID, (array) $values, Criteria::IN);
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
$affectedRows += CountriesPeer::doOnDeleteCascade($criteria, $con);CountriesPeer::doOnDeleteSetNull($criteria, $con);
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* This is a method for emulating ON DELETE CASCADE for DBs that don't support this
* feature (like MySQL or SQLite).
*
* This method is not very speedy because it must perform a query first to get
* the implicated records and then perform the deletes by calling those Peer classes.
*
* This method should be used within a transaction if possible.
*
* @param Criteria $criteria
* @param Connection $con
* @return int The number of affected rows (if supported by underlying database driver).
*/
protected static function doOnDeleteCascade(Criteria $criteria, Connection $con)
{
// initialize var to track total num of affected rows
$affectedRows = 0;
// first find the objects that are implicated by the $criteria
$objects = CountriesPeer::doSelect($criteria, $con);
foreach($objects as $obj) {
// delete related CountriesAreaHasCountries objects
$c = new Criteria();
$c->add(CountriesAreaHasCountriesPeer::COUNTRIES_ID, $obj->getId());
$affectedRows += CountriesAreaHasCountriesPeer::doDelete($c, $con);
// delete related CountriesI18n objects
$c = new Criteria();
$c->add(CountriesI18nPeer::ID, $obj->getId());
$affectedRows += CountriesI18nPeer::doDelete($c, $con);
}
return $affectedRows;
}
/**
* This is a method for emulating ON DELETE SET NULL DBs that don't support this
* feature (like MySQL or SQLite).
*
* This method is not very speedy because it must perform a query first to get
* the implicated records and then perform the deletes by calling those Peer classes.
*
* This method should be used within a transaction if possible.
*
* @param Criteria $criteria
* @param Connection $con
* @return void
*/
protected static function doOnDeleteSetNull(Criteria $criteria, Connection $con)
{
// first find the objects that are implicated by the $criteria
$objects = CountriesPeer::doSelect($criteria, $con);
foreach($objects as $obj) {
// set fkey col in related OrderUserDataBilling rows to NULL
$selectCriteria = new Criteria(CountriesPeer::DATABASE_NAME);
$updateValues = new Criteria(CountriesPeer::DATABASE_NAME);
$selectCriteria->add(OrderUserDataBillingPeer::COUNTRIES_ID, $obj->getId());
$updateValues->add(OrderUserDataBillingPeer::COUNTRIES_ID, null);
BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
// set fkey col in related OrderUserDataDelivery rows to NULL
$selectCriteria = new Criteria(CountriesPeer::DATABASE_NAME);
$updateValues = new Criteria(CountriesPeer::DATABASE_NAME);
$selectCriteria->add(OrderUserDataDeliveryPeer::COUNTRIES_ID, $obj->getId());
$updateValues->add(OrderUserDataDeliveryPeer::COUNTRIES_ID, null);
BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
// set fkey col in related Language rows to NULL
$selectCriteria = new Criteria(CountriesPeer::DATABASE_NAME);
$updateValues = new Criteria(CountriesPeer::DATABASE_NAME);
$selectCriteria->add(LanguagePeer::COUNTRY_ID, $obj->getId());
$updateValues->add(LanguagePeer::COUNTRY_ID, null);
BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
}
}
/**
* Validates all modified columns of given Countries object.
* If parameter $columns is either a single column name or an array of column names
* than only those columns are validated.
*
* NOTICE: This does not apply to primary or foreign keys for now.
*
* @param Countries $obj The object to validate.
* @param mixed $cols Column name or array of column names.
*
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
*/
public static function doValidate(Countries $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(CountriesPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(CountriesPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(CountriesPeer::DATABASE_NAME, CountriesPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = CountriesPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
/**
* Retrieve a single object by pkey.
*
* @param mixed $pk the primary key.
* @param Connection $con the connection to use
* @return Countries
*/
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(CountriesPeer::DATABASE_NAME);
$criteria->add(CountriesPeer::ID, $pk);
$v = CountriesPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
/**
* Retrieve multiple objects by pkey.
*
* @param array $pks List of primary keys
* @param Connection $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return Countries[]
*/
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(CountriesPeer::ID, $pks, Criteria::IN);
$objs = CountriesPeer::doSelect($criteria, $con);
}
return $objs;
}
} // BaseCountriesPeer
// static code to register the map builder for this Peer with the main Propel class
if (Propel::isInit()) {
// the MapBuilder classes register themselves with Propel during initialization
// so we need to load them here.
try {
BaseCountriesPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
// even if Propel is not yet initialized, the map builder class can be registered
// now and then it will be loaded when Propel initializes.
Propel::registerMapBuilder('plugins.stCountriesPlugin.lib.model.map.CountriesMapBuilder');
}

View File

@@ -0,0 +1,370 @@
<?php
/**
* SOTESHOP/stCountriesPlugin
*
* Ten plik należy do aplikacji stCountriesPlugin opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stCountriesPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: stCountries.class.php 5356 2010-05-31 11:07:06Z michal $
* @author Marcin Olejniczak <marcin.olejniczak@sote.pl>
*/
/**
* Klasa do obsługi krajów.
*
* @package stCountriesPlugin
* @subpackage libs
*/
class stCountries
{
/**
* Przestrzeń nazw
*/
const SESSION_NAMESPACE = 'soteshop/countries';
const ISO_CODES = [
"BD" => "BGD",
"BE" => "BEL",
"BF" => "BFA",
"BG" => "BGR",
"BA" => "BIH",
"BB" => "BRB",
"WF" => "WLF",
"BL" => "BLM",
"BM" => "BMU",
"BN" => "BRN",
"BO" => "BOL",
"BH" => "BHR",
"BI" => "BDI",
"BJ" => "BEN",
"BT" => "BTN",
"JM" => "JAM",
"BV" => "BVT",
"BW" => "BWA",
"WS" => "WSM",
"BQ" => "BES",
"BR" => "BRA",
"BS" => "BHS",
"JE" => "JEY",
"BY" => "BLR",
"BZ" => "BLZ",
"RU" => "RUS",
"RW" => "RWA",
"RS" => "SRB",
"TL" => "TLS",
"RE" => "REU",
"TM" => "TKM",
"TJ" => "TJK",
"RO" => "ROU",
"TK" => "TKL",
"GW" => "GNB",
"GU" => "GUM",
"GT" => "GTM",
"GS" => "SGS",
"GR" => "GRC",
"GQ" => "GNQ",
"GP" => "GLP",
"JP" => "JPN",
"GY" => "GUY",
"GG" => "GGY",
"GF" => "GUF",
"GE" => "GEO",
"GD" => "GRD",
"GB" => "GBR",
"GA" => "GAB",
"SV" => "SLV",
"GN" => "GIN",
"GM" => "GMB",
"GL" => "GRL",
"GI" => "GIB",
"GH" => "GHA",
"OM" => "OMN",
"TN" => "TUN",
"JO" => "JOR",
"HR" => "HRV",
"HT" => "HTI",
"HU" => "HUN",
"HK" => "HKG",
"HN" => "HND",
"HM" => "HMD",
"VE" => "VEN",
"PR" => "PRI",
"PS" => "PSE",
"PW" => "PLW",
"PT" => "PRT",
"SJ" => "SJM",
"PY" => "PRY",
"IQ" => "IRQ",
"PA" => "PAN",
"PF" => "PYF",
"PG" => "PNG",
"PE" => "PER",
"PK" => "PAK",
"PH" => "PHL",
"PN" => "PCN",
"PL" => "POL",
"PM" => "SPM",
"ZM" => "ZMB",
"EH" => "ESH",
"EE" => "EST",
"EG" => "EGY",
"ZA" => "ZAF",
"EC" => "ECU",
"IT" => "ITA",
"VN" => "VNM",
"SB" => "SLB",
"ET" => "ETH",
"SO" => "SOM",
"ZW" => "ZWE",
"SA" => "SAU",
"ES" => "ESP",
"ER" => "ERI",
"ME" => "MNE",
"MD" => "MDA",
"MG" => "MDG",
"MF" => "MAF",
"MA" => "MAR",
"MC" => "MCO",
"UZ" => "UZB",
"MM" => "MMR",
"ML" => "MLI",
"MO" => "MAC",
"MN" => "MNG",
"MH" => "MHL",
"MK" => "MKD",
"MU" => "MUS",
"MT" => "MLT",
"MW" => "MWI",
"MV" => "MDV",
"MQ" => "MTQ",
"MP" => "MNP",
"MS" => "MSR",
"MR" => "MRT",
"IM" => "IMN",
"UG" => "UGA",
"TZ" => "TZA",
"MY" => "MYS",
"MX" => "MEX",
"IL" => "ISR",
"FR" => "FRA",
"IO" => "IOT",
"SH" => "SHN",
"FI" => "FIN",
"FJ" => "FJI",
"FK" => "FLK",
"FM" => "FSM",
"FO" => "FRO",
"NI" => "NIC",
"NL" => "NLD",
"NO" => "NOR",
"NA" => "NAM",
"VU" => "VUT",
"NC" => "NCL",
"NE" => "NER",
"NF" => "NFK",
"NG" => "NGA",
"NZ" => "NZL",
"NP" => "NPL",
"NR" => "NRU",
"NU" => "NIU",
"CK" => "COK",
"XK" => "XKX",
"CI" => "CIV",
"CH" => "CHE",
"CO" => "COL",
"CN" => "CHN",
"CM" => "CMR",
"CL" => "CHL",
"CC" => "CCK",
"CA" => "CAN",
"CG" => "COG",
"CF" => "CAF",
"CD" => "COD",
"CZ" => "CZE",
"CY" => "CYP",
"CX" => "CXR",
"CR" => "CRI",
"CW" => "CUW",
"CV" => "CPV",
"CU" => "CUB",
"SZ" => "SWZ",
"SY" => "SYR",
"SX" => "SXM",
"KG" => "KGZ",
"KE" => "KEN",
"SS" => "SSD",
"SR" => "SUR",
"KI" => "KIR",
"KH" => "KHM",
"KN" => "KNA",
"KM" => "COM",
"ST" => "STP",
"SK" => "SVK",
"KR" => "KOR",
"SI" => "SVN",
"KP" => "PRK",
"KW" => "KWT",
"SN" => "SEN",
"SM" => "SMR",
"SL" => "SLE",
"SC" => "SYC",
"KZ" => "KAZ",
"KY" => "CYM",
"SG" => "SGP",
"SE" => "SWE",
"SD" => "SDN",
"DO" => "DOM",
"DM" => "DMA",
"DJ" => "DJI",
"DK" => "DNK",
"VG" => "VGB",
"DE" => "DEU",
"YE" => "YEM",
"DZ" => "DZA",
"US" => "USA",
"UY" => "URY",
"YT" => "MYT",
"UM" => "UMI",
"LB" => "LBN",
"LC" => "LCA",
"LA" => "LAO",
"TV" => "TUV",
"TW" => "TWN",
"TT" => "TTO",
"TR" => "TUR",
"LK" => "LKA",
"LI" => "LIE",
"LV" => "LVA",
"TO" => "TON",
"LT" => "LTU",
"LU" => "LUX",
"LR" => "LBR",
"LS" => "LSO",
"TH" => "THA",
"TF" => "ATF",
"TG" => "TGO",
"TD" => "TCD",
"TC" => "TCA",
"LY" => "LBY",
"VA" => "VAT",
"VC" => "VCT",
"AE" => "ARE",
"AD" => "AND",
"AG" => "ATG",
"AF" => "AFG",
"AI" => "AIA",
"VI" => "VIR",
"IS" => "ISL",
"IR" => "IRN",
"AM" => "ARM",
"AL" => "ALB",
"AO" => "AGO",
"AQ" => "ATA",
"AS" => "ASM",
"AR" => "ARG",
"AU" => "AUS",
"AT" => "AUT",
"AW" => "ABW",
"IN" => "IND",
"AX" => "ALA",
"AZ" => "AZE",
"IE" => "IRL",
"ID" => "IDN",
"UA" => "UKR",
"QA" => "QAT",
"MZ" => "MOZ"
];
/**
* Instanacja obiektu stCountries
* @var stCountries object
*/
protected static $instance = null;
/**
* Zmienna całej klasy
* @var int
*/
private $countries = null;
/**
* Przelicznik instancji
* @var int
*/
private $counter = 1;
/**
* Inicjalizacja countries
*
* @param string $context instancja obiektu sfContext::getInstance()
*/
private $context;
/**
* Incjalizacja klasy stCountries
*
* @param string $context
*/
public function initialize($context)
{
$this->context = $context;
$this->countries = $context->getUser()->getAttribute('countries', null, self::SESSION_NAMESPACE);
}
/**
* Zwraca instancje obiektu
*
* @param string $context
* @return stCountries
*/
public static function getInstance($context)
{
if (!isset(self::$instance))
{
$class = __CLASS__;
self::$instance = new $class();
self::$instance->initialize($context);
}
return self::$instance;
}
/**
* Zapisuje ID countries dla uzytkownika
*
* @param idCountries $id
*/
public function set($id)
{
$this->context->getUser()->setAttribute('countries', $id);
}
/**
* Konwertuje kod ALPHA-2 do ALPHA-3
*
* @param string $alpha2 Kod kraju w formacie ISO3
* @return string|null
*/
public static function convAlpha2ToAlpha3(string $alpha2): ?string
{
return isset(self::ISO_CODES[$alpha2]) ? self::ISO_CODES[$alpha2] : null;
}
/**
* Konwertuje kod ALPHA-3 do ALPHA-2
*
* @param string $alpha3 Kod kraju w formacie ALPHA-3
* @return string|null
*/
public static function convAlpha3ToAlpha2(string $alpha3): ?string
{
$result = array_search($alpha3, self::ISO_CODES);
return false !== $result ? $result : null;
}
}