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,114 @@
<?php
class AllegroAuction extends BaseAllegroAuction {
protected $productPrice = null;
protected $productOptionsArray = null;
public function productHasOptions()
{
return $this->getProduct() && $this->getProduct()->getOptHasOptions() > 1;
}
public function addCommand($uuid, $type)
{
$commands = $this->getCommands() ? $this->getCommands() : array();
$commands[$type] = $uuid;
$this->setCommands($commands);
}
public function getCommands()
{
$commands = parent::getCommands();
return $commands ? $commands : array();
}
public function getCommand($type)
{
$commands = $this->getCommands();
return $commands && isset($commands[$type]) ? $commands[$type] : null;
}
public function getEnvironment()
{
return 'AllegroPl';
}
public function getAuctionLink()
{
return stAllegroApi::getOfferUrl($this->getAuctionId());
}
public function setProductOptions($v)
{
// throw new Exception($v);
parent::setProductOptions($v);
$this->productOptionsArray = null;
}
public function getProductOptionsArray()
{
if (null === $this->productOptionsArray)
{
$ids = array();
if ($this->productHasOptions())
{
$selected = $this->getProductOptions() ? explode(",", $this->getProductOptions()) : array();
$values = array();
$index = 0;
foreach ($selected as $id)
{
$option = ProductOptionsValuePeer::retrieveByPK($id);
if ($option)
{
$values[$index][trim($option->getOptValue())] = $option->getId();
}
$index++;
}
$product = $this->getProduct();
if (null === $this->productPrice)
{
$this->productPrice = $product->getPriceBrutto();
}
$ids = stNewProductOptions::updateProduct($product, $ids, $values, false);
$price = stPrice::computePriceModifiers($product, $this->productPrice, 'brutto');
$product->setPriceBrutto($price);
$product->resetModified();
stNewProductOptions::clearStaticPool();
}
$this->productOptionsArray = $ids;
}
return $this->productOptionsArray;
}
public function save($con = null)
{
if (!$this->productHasOptions())
{
$this->setProductOptions(null);
}
return parent::save($con);
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* SOTESHOP/stAllegroPlugin
*
* Ten plik należy do aplikacji stAllegroPlugin 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 stAllegroPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: AllegroAuctionHasOrder.php 16339 2011-12-01 12:09:59Z piotr $
* @author Piotr Halas <piotr.halas@sote.pl>
*/
/**
* Klasa AllegroAuctionHasOrder
*
* @package stAllegroPlugin
* @subpackage libs
*/
class AllegroAuctionHasOrder extends BaseAllegroAuctionHasOrder
{
public function save($con = null)
{
parent::save($con);
$this->getOrder()->setOptAllegroAuctionId($this->getAllegroAuctionId());
$this->getOrder()->save();
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* SOTESHOP/stAllegroPlugin
*
* Ten plik należy do aplikacji stAllegroPlugin 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 stAllegroPlugin
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: AllegroAuctionHasOrderPeer.php 4776 2010-04-28 08:58:48Z piotr $
* @author Piotr Halas <piotr.halas@sote.pl>
*/
/**
* Klasa AllegroAuctionHasOrderPeer
*
* @package stAllegroPlugin
* @subpackage libs
*/
class AllegroAuctionHasOrderPeer extends BaseAllegroAuctionHasOrderPeer {
public static function exists($trans_id, AllegroAuction $auction)
{
$c = new Criteria();
$c->add(self::TRANS_ID, $trans_id);
$c->add(self::ALLEGRO_AUCTION_ID, $auction->getAuctionId());
return self::doCount($c) > 0;
}
}

View File

@@ -0,0 +1,112 @@
<?php
class AllegroAuctionPeer extends BaseAllegroAuctionPeer {
public static function doSelectByProduct($productId, $environment) {
$c = new Criteria();
$c->add(self::PRODUCT_ID, $productId);
$c->add(self::SITE, $environment);
$c->addAscendingOrderByColumn(self::ID);
$c->setIgnoreCase(false);
return self::doSelect($c);
}
public static function getAuctionByOrder($order) {
$c = new Criteria();
$c->add(AllegroAuctionHasOrderPeer::ORDER_ID, $order->getId());
$auctionHasOrder = AllegroAuctionHasOrderPeer::doSelectOne($c);
if (is_object($auctionHasOrder)) {
$c = new Criteria();
$c->add(self::AUCTION_ID, $auctionHasOrder->getAllegroAuctionId());
return self::doSelectOne($c);
}
return null;
}
/**
* Pobiera aukcje dla danego zamówienia
*
* @param Order $order
* @return AllegroAuction[]
*/
public static function getAuctionsByOrder(Order $order) {
$c = new Criteria();
$c->add(AllegroAuctionHasOrderPeer::ORDER_ID, $order->getId());
$c->addJoin(self::AUCTION_ID, AllegroAuctionHasOrderPeer::ALLEGRO_AUCTION_ID);
return self::doSelect($c);
}
/**
* Pobiera aukcje po id/numerze oferty Allegro
*
* @param string $number
* @return AllegroAuction
*/
public static function retrieveByAuctionNumber($number)
{
$c = new Criteria();
$c->add(self::AUCTION_ID, $number);
return self::doSelectOne($c);
}
/**
* Pobiera aukcje po id
*
* @param Order $order
* @return AllegroAuction[]
*/
public static function doSelectByAuctionIds(array $ids)
{
$c = new Criteria();
$c->add(self::AUCTION_ID, $ids, Criteria::IN);
$offers = array();
foreach (self::doSelectJoinProduct($c) as $offer)
{
$offers[$offer->getAuctionId()] = $offer;
}
return $offers;
}
public static function doSelectAuctionIdsByOrder(Order $order)
{
$c = new Criteria();
$c->addSelectColumn(OrderProductPeer::ALLEGRO_AUCTION_ID);
$c->add(OrderProductPeer::ORDER_ID, $order->getId());
$rs = OrderProductPeer::doSelectRS($c);
$ids = array();
while($rs->next())
{
$ids[] = $rs->getInt(1);
}
return $ids;
}
public static function updateRequiresSync($productId = null, $optionId = null)
{
$selCriteria = new Criteria();
$selCriteria->add(AllegroAuctionPeer::ID, null, Criteria::ISNOTNULL);
if (null !== $productId)
{
$selCriteria->add(AllegroAuctionPeer::PRODUCT_ID, $productId);
}
if ($optionId)
{
$selCriteria->add(AllegroAuctionPeer::PRODUCT_OPTIONS, sprintf('(%1$s = \'%2$d\' OR %1$s LIKE \'%%,%2$d\')', AllegroAuctionPeer::PRODUCT_OPTIONS, $optionId), Criteria::CUSTOM);
}
$upCriteria = new Criteria();
$upCriteria->add(AllegroAuctionPeer::REQUIRES_SYNC, true);
BasePeer::doUpdate($selCriteria, $upCriteria, Propel::getConnection());
}
}

View File

@@ -0,0 +1,12 @@
<?php
/**
* Subclass for representing a row from the 'st_allegro_parcel_tracking_number_queue' table.
*
*
*
* @package plugins.stAllegroPlugin.lib.model
*/
class AllegroParcelTrackingNumberQueue extends BaseAllegroParcelTrackingNumberQueue
{
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* Subclass for performing query and update operations on the 'st_allegro_parcel_tracking_number_queue' table.
*
*
*
* @package plugins.stAllegroPlugin.lib.model
*/
class AllegroParcelTrackingNumberQueuePeer extends BaseAllegroParcelTrackingNumberQueuePeer
{
public static function addParcelTrackingNumber(Order $order)
{
$c = new Criteria();
$c->add(self::ORDER_ID, $order->getId());
if (!self::doCount($c))
{
$allegroParcelTrackingNumberQueue = new AllegroParcelTrackingNumberQueue();
$allegroParcelTrackingNumberQueue->setOrder($order);
$allegroParcelTrackingNumberQueue->save();
}
}
}

View File

@@ -0,0 +1,664 @@
<?php
class AllegroApiOffer extends BaseObject implements Persistent
{
/**
* Oferta allegro
*
* @var object|null
*/
protected $allegroOffer;
/**
* Wybrane opcje produktu
*
* @var array|null
*/
protected $selectedProductOptionsIds = null;
/**
* Oferta Allegro po stronie sklepu
*
* @var AllegroAuction
*/
protected $allegroAuction = null;
public function buildPkeyCriteria()
{
$c = new Criteria();
$c->add(constant($this->getPeer().'::ID'), $this->getId());
return $c;
}
public function getPeer()
{
return get_class($this).'Peer';
}
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
{
$fields = call_user_func(array($this->getPeer(), 'translateFieldName'), 'id', BasePeer::TYPE_FIELDNAME, $keyType);
return array($fields);
}
public function setAfterSalesServices(array $afterSalesServices)
{
foreach ($afterSalesServices as $index => $service)
{
if (empty($service['id']))
{
$service = null;
}
$afterSalesServices[$index] = $service;
}
$this->__call('setAfterSalesServices', [$afterSalesServices]);
}
public function __toString()
{
return $this->getAdminGeneratorTitle();
}
/**
* Undocumented function
*
* @param object|null $allegroOffer
*/
public function __construct($allegroOffer = null)
{
$this->allegroOffer = $allegroOffer;
if (null === $this->allegroOffer)
{
$this->allegroOffer = stAllegroApi::arrayToObject(array(
'product' => null,
'category' => null,
'parameters' => null,
'publication' => null,
'afterSalesServices' => null,
'sizeTable' => null,
'discounts' => null,
'location' => null,
'images' => null,
'tax' => null,
'name' => null,
'external' => null,
'sellingMode' => null,
'stock' => null,
'description' => null,
'delivery' => null,
'payments' => null,
));
}
try
{
if (!isset($allegroOffer->location))
{
$config = stConfig::getInstance('stAllegroBackend');
$this->setLocation(array(
'city' => $config->get('allegro_pl_city'),
'countryCode' => 'PL',
'postCode' => $config->get('allegro_pl_post_code'),
'province' => strtoupper($config->get('allegro_pl_state')),
));
}
}
catch (Exception $e)
{
}
}
public function getAdminGeneratorTitle()
{
return $this->getName() . ' ('.$this->getId().')';
}
public function __clone()
{
if (!$this->isNew())
{
$duration = $this->getPublication()->duration;
$this->allegroOffer->publication = null;
$this->setPublication(array(
'duration' => $duration,
'status' => stAllegroApi::STATUS_INACTIVE,
));
unset($this->allegroOffer->validation);
unset($this->allegroOffer->updatedAt);
unset($this->allegroOffer->createdAt);
$this->setNew(true);
$allegroAuction = new AllegroAuction();
$allegroAuction->fromArray($this->getAllegroAuction()->toArray());
$allegroAuction->setId(null);
$allegroAuction->setCreatedAt(null);
$allegroAuction->setUpdatedAt(null);
$allegroAuction->setCommands(null);
$allegroAuction->setEnded(null);
$allegroAuction->setEndedAt(null);
$this->allegroAuction = $allegroAuction;
$this->allegroOffer->id = null;
}
}
public function setFromArray(array $data)
{
foreach ($data as $name => $value)
{
$property = 'set'.lcfirst(sfInflector::camelize($name));
if ($name == 'description' && $value && !is_array($value))
{
$value = json_decode($value);
}
$this->$property($value);
}
}
public function getPrimaryKey()
{
return $this->getId();
}
public function setPrimaryKey($primaryKey)
{
$this->allegroOffer->id = $primaryKey;
}
/**
* Zwraca GUID oferty
*
* @return string
*/
public function getId()
{
return isset($this->allegroOffer->id) ? $this->allegroOffer->id : null;
}
public function getAllowSync()
{
return $this->getAllegroAuction()->getAllowSync();
}
public function setAllowSync($allowSync)
{
$this->getAllegroAuction()->setAllowSync($allowSync);
}
/**
* Zwraca ofertę Allegro po stronie sklepu
*
* @return AllegroAuction
*/
public function getAllegroAuction()
{
if (null === $this->allegroAuction)
{
$allegroAuction = $this->getId() ? AllegroAuctionPeer::retrieveByAuctionNumber($this->getId()) : null;
if (null === $allegroAuction)
{
$allegroAuction = new AllegroAuction();
$allegroAuction->setName($this->getName());
$allegroAuction->setAuctionId($this->getId());
}
$this->allegroAuction = $allegroAuction;
}
return $this->allegroAuction;
}
/**
* Wystaw ofertę
*
* @return $this
* @throws stAllegroException
* @throws PropelException
*/
public function publish()
{
$api = stAllegroApi::getInstance();
$response = $api->publishOffers(array($this->getId()));
$this->getAllegroAuction()->addCommand($response->id, 'publish');
$this->getAllegroAuction()->setEnded(null);
$this->getAllegroAuction()->setEndedAt(null);
$this->getAllegroAuction()->save();
return $this;
}
/**
* Zakończ ofertę
*
* @return $this
* @throws stAllegroException
* @throws PropelException
*/
public function end()
{
$api = stAllegroApi::getInstance();
$api->publishOffers(array($this->getId()), false);
$this->getAllegroAuction()->setAllowSync(false);
$this->getAllegroAuction()->save();
return $this;
}
public function getStatusLabel()
{
$enum = stAllegroApi::getStatusList();
return isset($enum[$this->getPublication()->status]) ? $enum[$this->getPublication()->status] : '';
}
public function getPrimaryImage()
{
return $this->allegroOffer->primaryImage ? $this->allegroOffer->primaryImage->url : null;
}
public function getStockSold()
{
return $this->getStock()->sold;
}
public function getStockAvailable()
{
return $this->getStock()->available;
}
public function getShopProductStock()
{
$stock = null;
if ($this->getShopProduct())
{
stNewProductOptions::clearCache($this->getShopProduct());
$this->getAllegroAuction()->getProductOptionsArray();
$stock = $this->getShopProduct()->getStock();
}
return $stock;
}
/**
* Ustawia powiązanie produktu z ofertą
*
* @param Product $product
* @return self
*/
public function setShopProduct(Product $product = null)
{
if (null !== $product)
{
$this->getAllegroAuction()->setProduct($product);
$this->setShopProductId($product->getId());
}
return $this;
}
/**
* Zwraca powiązany produkt z ofertą
*
* @return Product
*/
public function getShopProduct()
{
return $this->getAllegroAuction()->getProduct();
}
public function getShopProductCode()
{
return $this->getAllegroAuction()->getProduct() ? $this->getAllegroAuction()->getProduct()->getCode() : null;
}
public function setProductId($id)
{
$this->setShopProductId($id);
}
public function getProductId()
{
return $this->getShopProductId();
}
/**
* Ustawia id powiązanego produktu z ofertą
*
* @param int $id
* @return self
*/
public function setShopProductId($id)
{
$this->getAllegroAuction()->setProductId($id);
$this->setExternal(array('id' => $id));
return $this;
}
/**
* Zwraca id powiązanego produktu z ofertą
*
* @return int
*/
public function getShopProductId()
{
return $this->getShopProduct() ? $this->getShopProduct()->getId() : null;
}
/**
* Zwraca nazwę
*
* @return string|null
*/
public function getName()
{
return $this->allegroOffer ? $this->allegroOffer->name : null;
}
/**
* Ustawia nazwę
*
* @param string $name Nazwa oferty
*
* @return self
*/
public function setName(string $name)
{
$this->allegroOffer->name = $name;
return $this;
}
public function setParameters(array $parameters)
{
$this->allegroOffer->parameters = array();
if (is_numeric(key($parameters)))
{
foreach ($parameters as $parameter)
{
$this->allegroOffer->parameters[$parameter['id']] = stAllegroApi::arrayToObject($parameter);
}
}
else
{
$this->allegroOffer->parameters = $this->transformOfferParameters($parameters);
}
}
public function setShopProductOptions($v)
{
$this->getAllegroAuction()->setProductOptions($v);
}
public function getShopProductOptions()
{
return $this->getAllegroAuction()->getProductOptions();
}
public function isAdminGeneratorActionVisible($name)
{
return $name == 'preview' && $this->getPublication()->status == stAllegroApi::STATUS_ACTIVE ||
$name == 'duplicate' && ($this->getPublication()->status == stAllegroApi::STATUS_ACTIVE || $this->getPublication()->status == stAllegroApi::STATUS_ENDED) ||
$name == '_delete';
}
public function getIsSystemDefault()
{
return $this->getPublication()->status != stAllegroApi::STATUS_INACTIVE;
}
public function getOfferUrl()
{
return stAllegroApi::getOfferUrl($this->getId());
}
public function delete($con = null)
{
stAllegroApi::getInstance()->deleteDraftOffer($this->getId());
}
public function save($con = null)
{
$config = stConfig::getInstance('stAllegroBackend');
$productChanged = $this->getAllegroAuction()->isColumnModified(AllegroAuctionPeer::PRODUCT_ID) || $this->getAllegroAuction()->isColumnModified(AllegroAuctionPeer::PRODUCT_OPTIONS);
if ($this->isNew())
{
$response = stAllegroApi::getInstance()->createOffer($this->allegroOffer);
$this->allegroOffer = $response;
if (null === $this->allegroAuction)
{
$this->allegroAuction = new AllegroAuction();
$this->allegroAuction->setName($response->name);
}
$this->allegroAuction->setAuctionId($response->id);
$this->allegroAuction->save();
$this->setNew(false);
}
else
{
$this->allegroAuction->save();
$product = $this->getAllegroAuction()->getProduct();
if ($productChanged)
{
$this->getAllegroAuction()->getProductOptionsArray();
if ($config->get('offer_sync_product_price'))
{
$commision = new AllegroCommission();
$this->allegroOffer->sellingMode->price->amount = $commision->calculatePrice($product->getPriceBrutto());
}
}
$response = stAllegroApi::getInstance()->updateOffer($this->getId(), $this->allegroOffer);
if ($response->validation && $response->validation->errors)
{
$this->allegroOffer->validation = $response->validation;
}
else
{
$this->allegroOffer = $response;
if ($productChanged)
{
$priceModifiers = $product->getPriceModifiers();
/**
* @see BasketProduct::setPriceModifiers()
**/
foreach ($priceModifiers as $index => $value) {
if (isset($value['custom']['label'])) {
$label = $value['custom']['label'];
unset($value['custom']['label']);
$value['label'] = $label;
$priceModifiers[$index] = $value;
}
}
$stmt = Propel::getConnection()->prepareStatement(sprintf('UPDATE %s SET %s = ?, %s = ?, %s = ?, %s = ?, %s = ? WHERE %s = ?', OrderProductPeer::TABLE_NAME, OrderProductPeer::CODE, OrderProductPeer::IMAGE, OrderProductPeer::NAME, OrderProductPeer::PRODUCT_ID, OrderProductPeer::PRICE_MODIFIERS, OrderProductPeer::ALLEGRO_AUCTION_ID));
$stmt->setString(1, $product->getCode());
$stmt->setString(2, $product->getOptImage());
$stmt->setString(3, $config->get('import_product_name', 'offer') == 'offer' ? $this->getName() : $product->getName());
$stmt->setInt(4, $product->getId());
$stmt->setString(5, serialize($priceModifiers));
$stmt->setString(6, $this->getId());
$stmt->executeQuery();
}
}
}
return true;
}
public function __call($name, $arguments)
{
$type = substr($name, 0, 3);
$property = lcfirst(substr($name, 3));
if (property_exists($this->allegroOffer, $property))
{
if ($type == 'get')
{
return $this->allegroOffer->$property;
}
elseif ($type == 'set')
{
$this->setAllegroApiParameter($property, $arguments[0]);
return;
}
}
throw new \BadMethodCallException('Method does not exist.');
}
protected function setAllegroApiParameter($name, $value)
{
if (is_array($value))
{
if (!isset($value[0]))
{
$this->allegroOffer->$name = stAllegroApi::arrayToObject(array_merge((array)$this->allegroOffer->$name, $value), true);
}
else
{
$this->allegroOffer->$name = stAllegroApi::arrayToObject($value, true);
}
}
else
{
$this->allegroOffer->$name = !empty($value) ? $value : null;
}
}
protected function transformOfferParameters(array $data)
{
$parameters = array();
foreach ($data as $type => $values)
{
switch($type)
{
case 'dictionary':
foreach ($values as $id => $value)
{
if ($value && $value['value'])
{
$parameter = new stdClass();
$parameter->id = $id;
$parameter->valuesIds = is_array($value['value']) ? $value['value'] : array($value['value']);
if (isset($value['custom']) && !empty($value['custom']))
{
$parameter->values = array($value['custom']);
}
$parameters[$id] = $parameter;
}
}
break;
case 'float':
case 'integer':
foreach ($values as $id => $value)
{
$parameter = new stdClass();
$parameter->id = $id;
if (is_array($value))
{
$parameter->rangeValue = new stdClass();
$parameter->rangeValue->from = $value['from'];
$parameter->rangeValue->to = $value['to'];
if ($value['from'] !== "" || $value['to'] !== "")
{
$parameters[$id] = $parameter;
}
}
else
{
$parameter->values = array($value);
if ($value !== "")
{
$parameters[$id] = $parameter;
}
}
}
break;
case 'string':
foreach ($values as $id => $value)
{
$parameter = new stdClass();
$parameter->id = $id;
if (is_array($value))
{
$parameter->values = array();
foreach ($value as $v)
{
if ($v)
{
$parameter->values[] = $v;
}
}
if ($parameter->values)
{
$parameters[$id] = $parameter;
}
}
else
{
$parameter->values = array($value);
if ($value)
{
$parameters[$id] = $parameter;
}
}
}
break;
}
}
return $parameters;
}
}

View File

@@ -0,0 +1,53 @@
<?php
class AllegroApiOfferMapBuilder
{
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stAllegroPlugin.lib.model.AllegroApiOfferMapBuilder';
/**
* 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_allegro_api_offer');
$tMap->setPhpName('AllegroApiOffer');
$tMap->addPrimaryKey('ID', 'Id', 'string', CreoleTypes::CHAR, true, 38);
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, true, 255);
} // doBuild()
}

View File

@@ -0,0 +1,190 @@
<?php
class AllegroApiOfferPeer
{
const TABLE_NAME = 'st_allegro_api_offer';
const ID = self::TABLE_NAME.'.id';
const NAME = self::TABLE_NAME.'.name';
const STATUS = self::TABLE_NAME.'.status';
const PRICE_AMOUNT_FROM = self::TABLE_NAME.'.price_amount_from';
const PRICE_AMOUNT_TO = self::TABLE_NAME.'.price_amount_to';
const PRODUCT_CODE = self::TABLE_NAME.'.product_code';
const SHOP_PRODUCT = self::TABLE_NAME.'.external_id';
const PRODUCT_ID = self::TABLE_NAME.'.product_id';
const ALLEGRO_FIELD_MAPPING = array(
self::ID => 'offer.id',
self::NAME => 'name',
self::STATUS => 'publication.status',
self::PRICE_AMOUNT_FROM => 'sellingMode.price.amount.gte',
self::PRICE_AMOUNT_TO => 'sellingMode.price.amount.lte',
self::SHOP_PRODUCT => 'external.id',
self::PRODUCT_ID => 'external.id',
);
public static function getAllegroField($field)
{
return isset(self::ALLEGRO_FIELD_MAPPING[$field]) ? self::ALLEGRO_FIELD_MAPPING[$field] : null;
}
/**
* Ostatnio wykonane kryteria
*
* @var Criteria
*/
protected static $lastCriteria = null;
protected static $lastResults = null;
/**
* Zwraca cennik dostawy według GUID
*
* @param string $id GUID
* @return AllegroApiOffer
*/
public static function retrieveByPK($id)
{
$response = stAllegroApi::getInstance()->getOffer($id);
// throw new Exception("<pre>".var_export($response, true)."</pre>");
$allegroApiOffer = new AllegroApiOffer($response);
$allegroApiOffer->setNew(false);
return $allegroApiOffer;
}
/**
* Zwraca cennik dostaw na podstawie przekazanych kryteriów
*
* @param Criteria $c Kryteria
* @return AllegroApiOffer
*/
public static function doSelectOne(Criteria $c)
{
$results = self::doSelect($c);
return $results ? $results[0] : null;
}
/**
* Zwraca tablicę cenników dostaw na podstawie przekazanych kryteriów
*
* @param Criteria $c Kryteria
* @return AllegroApiOffer[]
*/
public static function doSelect(Criteria $c)
{
if (null === self::$lastCriteria || !self::$lastCriteria->equals($c))
{
$results = array();
$response = self::getAllegroApiOffersResponse($c);
foreach ($response->offers as $offer)
{
$allegroApiOffer = new AllegroApiOffer($offer);
$allegroApiOffer->setNew(false);
$results[] = $allegroApiOffer;
}
self::$lastCriteria = $c;
self::$lastResults = $results;
}
return self::$lastResults;
}
public static function doCount(Criteria $c)
{
$c = clone $c;
$c->clearOrderByColumns();
$c->setOffset(0);
$c->setLimit(null);
$response = self::getAllegroApiOffersResponse($c);
return $response->totalCount;
}
/**
* Zwraca oferty z Allegro API
*
* @param Criteria $c Kryteria
* @return object
* @throws stAllegroException
*/
protected static function getAllegroApiOffersResponse(Criteria $c)
{
$params = array(
'limit' => $c->getLimit(),
'offset' => $c->getOffset(),
'sellingMode.format' => 'BUY_NOW'
);
if (null !== $c->get(self::STATUS) && "" !== $c->get(self::STATUS))
{
$params['publication.status'] = $c->get(self::STATUS);
}
if (null !== $c->get(self::ID) && "" !== $c->get(self::ID))
{
$params[self::getAllegroField(self::ID)] = $c->get(self::ID);
}
if (null !== $c->get(self::NAME) && "" !== $c->get(self::NAME))
{
$params[self::getAllegroField(self::NAME)] = trim($c->get(self::NAME), '%');
}
if (null !== $c->get(self::PRICE_AMOUNT_FROM) && "" !== $c->get(self::PRICE_AMOUNT_FROM))
{
$params[self::getAllegroField(self::PRICE_AMOUNT_FROM)] = $c->get(self::PRICE_AMOUNT_FROM);
}
if (null !== $c->get(self::PRICE_AMOUNT_TO) && "" !== $c->get(self::PRICE_AMOUNT_TO))
{
$params[self::getAllegroField(self::PRICE_AMOUNT_TO)] = $c->get(self::PRICE_AMOUNT_TO);
}
if (null !== $c->get(self::SHOP_PRODUCT) && "" !== $c->get(self::SHOP_PRODUCT))
{
$params[self::getAllegroField(self::SHOP_PRODUCT)] = $c->get(self::SHOP_PRODUCT);
}
if (null !== $c->get(self::PRODUCT_ID) && "" !== $c->get(self::PRODUCT_ID))
{
$params[self::getAllegroField(self::PRODUCT_ID)] = $c->get(self::PRODUCT_ID);
}
return stAllegroApi::getInstance()->getOffers($params);
}
public static function getMapBuilder()
{
return BasePeer::getMapBuilder(AllegroApiOfferMapBuilder::CLASS_NAME);
}
public static function translateFieldName($name, $fromType, $toType)
{
return $name;
}
}
// 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 {
AllegroApiOfferPeer::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(AllegroApiOfferMapBuilder::CLASS_NAME);
}

View File

@@ -0,0 +1,195 @@
<?php
class AllegroApiShippingRate extends BaseObject implements Persistent
{
/**
* GUID cennika dostaw
*
* @var string
*/
protected $id;
/**
* Nazwa cennika dostaw
*
* @var string
*/
protected $name;
/**
* Data ostatniej modyfikacji cennika dostaw
*
* @var int|null
*/
protected $lastModified;
/**
* Lista stawek cennika dostaw
*
* @var array|null
*/
protected $rates;
public function buildPkeyCriteria()
{
$c = new Criteria();
$c->add(constant($this->getPeer().'::ID'), $this->getId());
return $c;
}
public function getPeer()
{
return get_class($this).'Peer';
}
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
{
$fields = call_user_func(array($this->getPeer(), 'translateFieldName'), 'id', BasePeer::TYPE_FIELDNAME, $keyType);
return array($fields);
}
public function getPrimaryKey()
{
return $this->id;
}
public function setPrimaryKey($primaryKey)
{
$this->id = $primaryKey;
}
/**
* Zwraca GUID cennika dostaw
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* Ustawia GUID cennika dostaw
*
* @param string $id GUID cennika dostaw
*
* @return self
*/
public function setId(string $id)
{
$this->id = $id;
return $this;
}
/**
* Zwraca nazwę cennika dostaw
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Ustawia nazwę cennika dostaw
*
* @param string $name Nazwa cennika dostaw
*
* @return self
*/
public function setName(string $name)
{
$this->name = $name;
return $this;
}
/**
* Zwraca datę ostatniej modyfikacji cennika dostaw
*
* @return int|null
*/
public function getLastModified()
{
return $this->lastModified;
}
/**
* Ustawia datę ostatniej modyfikacji cennika dostaw
*
* @param int $lastModified Data ostatniej modyfikacji cennika dostaw
*
* @return self
*/
public function setLastModified(int $lastModified)
{
$this->lastModified = $lastModified;
return $this;
}
/**
* Zwraca listę stawek cennika dostaw
*
* @return array|null
*/
public function getRates()
{
return $this->rates;
}
/**
* Ustawia listę stawek cennika dostaw
*
* @param array $rates Lista stawek cennika dostaw
*
* @return self
*/
public function setRates(array $rates)
{
$this->rates = $rates;
return $this;
}
/**
* Zwraca stawkę cennika dostawy po GUID
*
* @param string $id GUID stawki
* @param string|null $default Wartość domyślna w przypadku braku stawki
* @return array
*/
public function getRate($id, $default = null)
{
return isset($this->rates[$id]) ? $this->rates[$id] : $default;
}
public function delete($con = null)
{
}
public function save($con = null)
{
if ($this->isNew())
{
$response = stAllegroApi::getInstance()->createShippingRate(array(
'name' => $this->name,
'rates' => $this->rates
));
$this->id = $response->id;
}
else
{
stAllegroApi::getInstance()->updateShippingRate($this->id, array(
'name' => $this->name,
'rates' => $this->rates,
));
}
return true;
}
}

View File

@@ -0,0 +1,54 @@
<?php
class AllegroApiShippingRateMapBuilder
{
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stAllegroPlugin.lib.model.AllegroApiShippingRateMapBuilder';
/**
* 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_allegro_api_shipping_rate');
$tMap->setPhpName('AllegroApiShippingRate');
$tMap->addPrimaryKey('ID', 'Id', 'string', CreoleTypes::CHAR, true, 38);
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, true, 255);
$tMap->addColumn('LAST_MODIFIED', 'LastModified', 'int', CreoleTypes::TIMESTAMP);
} // doBuild()
}

View File

@@ -0,0 +1,142 @@
<?php
class AllegroApiShippingRatePeer
{
const TABLE_NAME = 'st_allegro_api_shipping_rate';
const ID = self::TABLE_NAME.'.id';
const NAME = self::TABLE_NAME.'.name';
const LAST_MODIFIED = self::TABLE_NAME.'.last_modified';
/**
* Ostatnio wykonane kryteria
*
* @var Criteria
*/
protected static $lastCriteria = null;
protected static $lastResults = null;
/**
* Zwraca cennik dostawy według GUID
*
* @param string $id GUID
* @return AllegroApiShippingRate
*/
public static function retrieveByPK($id)
{
$rates = array();
$shippingRate = stAllegroApi::getInstance()->getShippingRate($id);
foreach ($shippingRate->rates as $methodId => $rate)
{
$rates[$methodId] = array(
'first_item_rate' => array(
'amount' => $rate->firstItemRate->amount,
'currency' => $rate->firstItemRate->currency,
'default' => 0.00
),
'next_item_rate' => array(
'amount' => $rate->nextItemRate->amount,
'currency' => $rate->firstItemRate->currency,
'default' => 0.00
),
'max_quantity_per_package' => $rate->maxQuantityPerPackage,
);
}
$allegroApiShippingRate = new AllegroApiShippingRate();
$allegroApiShippingRate->setId($shippingRate->id);
$allegroApiShippingRate->setName($shippingRate->name);
$allegroApiShippingRate->setRates($rates);
$allegroApiShippingRate->setLastModified($shippingRate->lastModified ? strtotime($shippingRate->lastModified) : null);
$allegroApiShippingRate->setNew(false);
return $allegroApiShippingRate;
}
/**
* Zwraca cennik dostaw na podstawie przekazanych kryteriów
*
* @param Criteria $c Kryteria
* @return AllegroApiShippingRate
*/
public static function doSelectOne(Criteria $c)
{
$results = self::doSelect($c);
return $results ? $results[0] : null;
}
/**
* Zwraca tablicę cenników dostaw na podstawie przekazanych kryteriów
*
* @param Criteria $c Kryteria
* @return AllegroApiShippingRate[]
*/
public static function doSelect(Criteria $c)
{
if (null === self::$lastCriteria || !self::$lastCriteria->equals($c))
{
$results = array();
$query = trim($c->get(self::NAME), '%');
foreach (stAllegroApi::getInstance()->getShippingRates() as $shippingRate)
{
if (null === $query || "" === $query || false !== stripos($shippingRate->name, $query))
{
$allegroApiShippingRate = new AllegroApiShippingRate();
$allegroApiShippingRate->setId($shippingRate->id);
$allegroApiShippingRate->setName($shippingRate->name);
$allegroApiShippingRate->setNew(false);
$results[] = $allegroApiShippingRate;
}
}
self::$lastCriteria = $c;
self::$lastResults = array_slice($results, $c->getOffset(), $c->getLimit() > 0 ? $c->getLimit() : null);
}
return self::$lastResults;
}
public static function doCount(Criteria $c)
{
$c = clone $c;
$c->clearOrderByColumns();
$c->setOffset(0);
$c->setLimit(null);
$results = self::doSelect($c);
return count($results);
}
public static function getMapBuilder()
{
return BasePeer::getMapBuilder(AllegroApiShippingRateMapBuilder::CLASS_NAME);
}
public static function translateFieldName($name, $fromType, $toType)
{
return $name;
}
}
// 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 {
AllegroApiShippingRatePeer::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(AllegroApiShippingRateMapBuilder::CLASS_NAME);
}

View File

@@ -0,0 +1,74 @@
<?php
/**
* This class adds structure of 'st_allegro_auction_has_order' 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.stAllegroPlugin.lib.model.map
*/
class AllegroAuctionHasOrderMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stAllegroPlugin.lib.model.map.AllegroAuctionHasOrderMapBuilder';
/**
* 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_allegro_auction_has_order');
$tMap->setPhpName('AllegroAuctionHasOrder');
$tMap->setUseIdGenerator(false);
$tMap->addPrimaryKey('TRANS_ID', 'TransId', 'string', CreoleTypes::BIGINT, true, null);
$tMap->addPrimaryKey('ALLEGRO_AUCTION_ID', 'AllegroAuctionId', 'string', CreoleTypes::BIGINT, true, null);
$tMap->addForeignPrimaryKey('ORDER_ID', 'OrderId', 'int' , CreoleTypes::INTEGER, 'st_order', 'ID', true, null);
$tMap->addColumn('ALLEGRO_USER_ID', 'AllegroUserId', 'string', CreoleTypes::BIGINT, true, null);
} // doBuild()
} // AllegroAuctionHasOrderMapBuilder

View File

@@ -0,0 +1,92 @@
<?php
/**
* This class adds structure of 'st_allegro_auction' 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.stAllegroPlugin.lib.model.map
*/
class AllegroAuctionMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stAllegroPlugin.lib.model.map.AllegroAuctionMapBuilder';
/**
* 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_allegro_auction');
$tMap->setPhpName('AllegroAuction');
$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('PRODUCT_ID', 'ProductId', 'int', CreoleTypes::INTEGER, 'st_product', 'ID', true, null);
$tMap->addColumn('PRODUCT_OPTIONS', 'ProductOptions', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('REQUIRES_SYNC', 'RequiresSync', 'int', CreoleTypes::INTEGER, false, null);
$tMap->addColumn('ALLOW_SYNC', 'AllowSync', 'boolean', CreoleTypes::BOOLEAN, false, null);
$tMap->addColumn('SITE', 'Site', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('AUCTION_ID', 'AuctionId', 'string', CreoleTypes::BIGINT, false, null);
$tMap->addColumn('ENDED', 'Ended', 'boolean', CreoleTypes::BOOLEAN, false, null);
$tMap->addColumn('ENDED_AT', 'EndedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addColumn('COMMANDS', 'Commands', 'array', CreoleTypes::VARCHAR, false, 1024);
} // doBuild()
} // AllegroAuctionMapBuilder

View File

@@ -0,0 +1,70 @@
<?php
/**
* This class adds structure of 'st_allegro_parcel_tracking_number_queue' 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.stAllegroPlugin.lib.model.map
*/
class AllegroParcelTrackingNumberQueueMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stAllegroPlugin.lib.model.map.AllegroParcelTrackingNumberQueueMapBuilder';
/**
* 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_allegro_parcel_tracking_number_queue');
$tMap->setPhpName('AllegroParcelTrackingNumberQueue');
$tMap->setUseIdGenerator(false);
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
$tMap->addForeignPrimaryKey('ORDER_ID', 'OrderId', 'int' , CreoleTypes::INTEGER, 'st_order', 'ID', true, null);
} // doBuild()
} // AllegroParcelTrackingNumberQueueMapBuilder

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,830 @@
<?php
/**
* Base class that represents a row from the 'st_allegro_auction_has_order' table.
*
*
*
* @package plugins.stAllegroPlugin.lib.model.om
*/
abstract class BaseAllegroAuctionHasOrder extends BaseObject implements Persistent {
protected static $dispatcher = null;
/**
* The value for the trans_id field.
* @var string
*/
protected $trans_id;
/**
* The value for the allegro_auction_id field.
* @var string
*/
protected $allegro_auction_id;
/**
* The value for the order_id field.
* @var int
*/
protected $order_id;
/**
* The value for the allegro_user_id field.
* @var string
*/
protected $allegro_user_id;
/**
* @var Order
*/
protected $aOrder;
/**
* 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 [trans_id] column value.
*
* @return string
*/
public function getTransId()
{
return $this->trans_id;
}
/**
* Get the [allegro_auction_id] column value.
*
* @return string
*/
public function getAllegroAuctionId()
{
return $this->allegro_auction_id;
}
/**
* Get the [order_id] column value.
*
* @return int
*/
public function getOrderId()
{
return $this->order_id;
}
/**
* Get the [allegro_user_id] column value.
*
* @return string
*/
public function getAllegroUserId()
{
return $this->allegro_user_id;
}
/**
* Set the value of [trans_id] column.
*
* @param string $v new value
* @return void
*/
public function setTransId($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->trans_id !== $v) {
$this->trans_id = $v;
$this->modifiedColumns[] = AllegroAuctionHasOrderPeer::TRANS_ID;
}
} // setTransId()
/**
* Set the value of [allegro_auction_id] column.
*
* @param string $v new value
* @return void
*/
public function setAllegroAuctionId($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->allegro_auction_id !== $v) {
$this->allegro_auction_id = $v;
$this->modifiedColumns[] = AllegroAuctionHasOrderPeer::ALLEGRO_AUCTION_ID;
}
} // setAllegroAuctionId()
/**
* Set the value of [order_id] column.
*
* @param int $v new value
* @return void
*/
public function setOrderId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->order_id !== $v) {
$this->order_id = $v;
$this->modifiedColumns[] = AllegroAuctionHasOrderPeer::ORDER_ID;
}
if ($this->aOrder !== null && $this->aOrder->getId() !== $v) {
$this->aOrder = null;
}
} // setOrderId()
/**
* Set the value of [allegro_user_id] column.
*
* @param string $v new value
* @return void
*/
public function setAllegroUserId($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->allegro_user_id !== $v) {
$this->allegro_user_id = $v;
$this->modifiedColumns[] = AllegroAuctionHasOrderPeer::ALLEGRO_USER_ID;
}
} // setAllegroUserId()
/**
* 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('AllegroAuctionHasOrder.preHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'AllegroAuctionHasOrder.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
$startcol = $event['startcol'];
}
$this->trans_id = $rs->getString($startcol + 0);
$this->allegro_auction_id = $rs->getString($startcol + 1);
$this->order_id = $rs->getInt($startcol + 2);
$this->allegro_user_id = $rs->getString($startcol + 3);
$this->resetModified();
$this->setNew(false);
if ($this->getDispatcher()->getListeners('AllegroAuctionHasOrder.postHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'AllegroAuctionHasOrder.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 4)));
return $event['startcol'];
}
// FIXME - using NUM_COLUMNS may be clearer.
return $startcol + 4; // 4 = AllegroAuctionHasOrderPeer::NUM_COLUMNS - AllegroAuctionHasOrderPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating AllegroAuctionHasOrder 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('AllegroAuctionHasOrder.preDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'AllegroAuctionHasOrder.preDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BaseAllegroAuctionHasOrder:delete:pre'))
{
foreach (sfMixer::getCallables('BaseAllegroAuctionHasOrder:delete:pre') as $callable)
{
$ret = call_user_func($callable, $this, $con);
if ($ret)
{
return;
}
}
}
if ($con === null) {
$con = Propel::getConnection(AllegroAuctionHasOrderPeer::DATABASE_NAME);
}
try {
$con->begin();
AllegroAuctionHasOrderPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
if ($this->getDispatcher()->getListeners('AllegroAuctionHasOrder.postDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'AllegroAuctionHasOrder.postDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BaseAllegroAuctionHasOrder:delete:post'))
{
foreach (sfMixer::getCallables('BaseAllegroAuctionHasOrder: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('AllegroAuctionHasOrder.preSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'AllegroAuctionHasOrder.preSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BaseAllegroAuctionHasOrder:save:pre') as $callable)
{
$affectedRows = call_user_func($callable, $this, $con);
if (is_int($affectedRows))
{
return $affectedRows;
}
}
}
if ($con === null) {
$con = Propel::getConnection(AllegroAuctionHasOrderPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
if (!$this->alreadyInSave) {
if ($this->getDispatcher()->getListeners('AllegroAuctionHasOrder.postSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'AllegroAuctionHasOrder.postSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BaseAllegroAuctionHasOrder: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->aOrder !== null) {
if ($this->aOrder->isModified()) {
$affectedRows += $this->aOrder->save($con);
}
$this->setOrder($this->aOrder);
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = AllegroAuctionHasOrderPeer::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 += AllegroAuctionHasOrderPeer::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->aOrder !== null) {
if (!$this->aOrder->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aOrder->getValidationFailures());
}
}
if (($retval = AllegroAuctionHasOrderPeer::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 = AllegroAuctionHasOrderPeer::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->getTransId();
break;
case 1:
return $this->getAllegroAuctionId();
break;
case 2:
return $this->getOrderId();
break;
case 3:
return $this->getAllegroUserId();
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 = AllegroAuctionHasOrderPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getTransId(),
$keys[1] => $this->getAllegroAuctionId(),
$keys[2] => $this->getOrderId(),
$keys[3] => $this->getAllegroUserId(),
);
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 = AllegroAuctionHasOrderPeer::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->setTransId($value);
break;
case 1:
$this->setAllegroAuctionId($value);
break;
case 2:
$this->setOrderId($value);
break;
case 3:
$this->setAllegroUserId($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 = AllegroAuctionHasOrderPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setTransId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setAllegroAuctionId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setOrderId($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setAllegroUserId($arr[$keys[3]]);
}
/**
* 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(AllegroAuctionHasOrderPeer::DATABASE_NAME);
if ($this->isColumnModified(AllegroAuctionHasOrderPeer::TRANS_ID)) $criteria->add(AllegroAuctionHasOrderPeer::TRANS_ID, $this->trans_id);
if ($this->isColumnModified(AllegroAuctionHasOrderPeer::ALLEGRO_AUCTION_ID)) $criteria->add(AllegroAuctionHasOrderPeer::ALLEGRO_AUCTION_ID, $this->allegro_auction_id);
if ($this->isColumnModified(AllegroAuctionHasOrderPeer::ORDER_ID)) $criteria->add(AllegroAuctionHasOrderPeer::ORDER_ID, $this->order_id);
if ($this->isColumnModified(AllegroAuctionHasOrderPeer::ALLEGRO_USER_ID)) $criteria->add(AllegroAuctionHasOrderPeer::ALLEGRO_USER_ID, $this->allegro_user_id);
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(AllegroAuctionHasOrderPeer::DATABASE_NAME);
$criteria->add(AllegroAuctionHasOrderPeer::TRANS_ID, $this->trans_id);
$criteria->add(AllegroAuctionHasOrderPeer::ALLEGRO_AUCTION_ID, $this->allegro_auction_id);
$criteria->add(AllegroAuctionHasOrderPeer::ORDER_ID, $this->order_id);
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->getTransId(), $this->getAllegroAuctionId(), $this->getOrderId());
}
/**
* Returns [composite] primary key fields
*
* @param string $keyType
* @return array
*/
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
{
return array(AllegroAuctionHasOrderPeer::translateFieldName('trans_id', BasePeer::TYPE_FIELDNAME, $keyType), AllegroAuctionHasOrderPeer::translateFieldName('allegro_auction_id', BasePeer::TYPE_FIELDNAME, $keyType), AllegroAuctionHasOrderPeer::translateFieldName('order_id', 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->setTransId($keys[0]);
$this->setAllegroAuctionId($keys[1]);
$this->setOrderId($keys[2]);
}
/**
* 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 AllegroAuctionHasOrder (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->setAllegroUserId($this->allegro_user_id);
$copyObj->setNew(true);
$copyObj->setTransId(NULL); // this is a pkey column, so set to default value
$copyObj->setAllegroAuctionId(NULL); // this is a pkey column, so set to default value
$copyObj->setOrderId(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 AllegroAuctionHasOrder 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 'AllegroAuctionHasOrderPeer';
}
/**
* Declares an association between this object and a Order object.
*
* @param Order $v
* @return void
* @throws PropelException
*/
public function setOrder($v)
{
if ($v === null) {
$this->setOrderId(NULL);
} else {
$this->setOrderId($v->getId());
}
$this->aOrder = $v;
}
/**
* Get the associated Order object
*
* @param Connection Optional Connection object.
* @return Order The associated Order object.
* @throws PropelException
*/
public function getOrder($con = null)
{
if ($this->aOrder === null && ($this->order_id !== null)) {
// include the related Peer class
$this->aOrder = OrderPeer::retrieveByPK($this->order_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 = OrderPeer::retrieveByPK($this->order_id, $con);
$obj->addOrders($this);
*/
}
return $this->aOrder;
}
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, 'AllegroAuctionHasOrder.' . $method, array('arguments' => $arguments, 'method' => $method)));
if ($event->isProcessed())
{
return $event->getReturnValue();
}
if (!$callable = sfMixer::getCallable('BaseAllegroAuctionHasOrder:'.$method))
{
throw new sfException(sprintf('Call to undefined method BaseAllegroAuctionHasOrder::%s', $method));
}
array_unshift($arguments, $this);
return call_user_func_array($callable, $arguments);
}
} // BaseAllegroAuctionHasOrder

View File

@@ -0,0 +1,846 @@
<?php
/**
* Base static class for performing query and update operations on the 'st_allegro_auction_has_order' table.
*
*
*
* @package plugins.stAllegroPlugin.lib.model.om
*/
abstract class BaseAllegroAuctionHasOrderPeer {
/** the default database name for this class */
const DATABASE_NAME = 'propel';
/** the table name for this class */
const TABLE_NAME = 'st_allegro_auction_has_order';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'plugins.stAllegroPlugin.lib.model.AllegroAuctionHasOrder';
/** The total number of columns. */
const NUM_COLUMNS = 4;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the TRANS_ID field */
const TRANS_ID = 'st_allegro_auction_has_order.TRANS_ID';
/** the column name for the ALLEGRO_AUCTION_ID field */
const ALLEGRO_AUCTION_ID = 'st_allegro_auction_has_order.ALLEGRO_AUCTION_ID';
/** the column name for the ORDER_ID field */
const ORDER_ID = 'st_allegro_auction_has_order.ORDER_ID';
/** the column name for the ALLEGRO_USER_ID field */
const ALLEGRO_USER_ID = 'st_allegro_auction_has_order.ALLEGRO_USER_ID';
/** 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 ('TransId', 'AllegroAuctionId', 'OrderId', 'AllegroUserId', ),
BasePeer::TYPE_COLNAME => array (AllegroAuctionHasOrderPeer::TRANS_ID, AllegroAuctionHasOrderPeer::ALLEGRO_AUCTION_ID, AllegroAuctionHasOrderPeer::ORDER_ID, AllegroAuctionHasOrderPeer::ALLEGRO_USER_ID, ),
BasePeer::TYPE_FIELDNAME => array ('trans_id', 'allegro_auction_id', 'order_id', 'allegro_user_id', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
/**
* 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 ('TransId' => 0, 'AllegroAuctionId' => 1, 'OrderId' => 2, 'AllegroUserId' => 3, ),
BasePeer::TYPE_COLNAME => array (AllegroAuctionHasOrderPeer::TRANS_ID => 0, AllegroAuctionHasOrderPeer::ALLEGRO_AUCTION_ID => 1, AllegroAuctionHasOrderPeer::ORDER_ID => 2, AllegroAuctionHasOrderPeer::ALLEGRO_USER_ID => 3, ),
BasePeer::TYPE_FIELDNAME => array ('trans_id' => 0, 'allegro_auction_id' => 1, 'order_id' => 2, 'allegro_user_id' => 3, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
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.stAllegroPlugin.lib.model.map.AllegroAuctionHasOrderMapBuilder');
}
/**
* 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 = AllegroAuctionHasOrderPeer::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. AllegroAuctionHasOrderPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(AllegroAuctionHasOrderPeer::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(AllegroAuctionHasOrderPeer::TRANS_ID);
$criteria->addSelectColumn(AllegroAuctionHasOrderPeer::ALLEGRO_AUCTION_ID);
$criteria->addSelectColumn(AllegroAuctionHasOrderPeer::ORDER_ID);
$criteria->addSelectColumn(AllegroAuctionHasOrderPeer::ALLEGRO_USER_ID);
if (stEventDispatcher::getInstance()->getListeners('AllegroAuctionHasOrderPeer.postAddSelectColumns')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'AllegroAuctionHasOrderPeer.postAddSelectColumns'));
}
}
const COUNT = 'COUNT(st_allegro_auction_has_order.TRANS_ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT st_allegro_auction_has_order.TRANS_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(AllegroAuctionHasOrderPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(AllegroAuctionHasOrderPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = AllegroAuctionHasOrderPeer::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 AllegroAuctionHasOrder
* @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 = AllegroAuctionHasOrderPeer::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 AllegroAuctionHasOrder[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return AllegroAuctionHasOrderPeer::populateObjects(AllegroAuctionHasOrderPeer::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;
AllegroAuctionHasOrderPeer::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 = AllegroAuctionHasOrderPeer::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 Order 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 doCountJoinOrder(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(AllegroAuctionHasOrderPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(AllegroAuctionHasOrderPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(AllegroAuctionHasOrderPeer::ORDER_ID, OrderPeer::ID);
$rs = AllegroAuctionHasOrderPeer::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 AllegroAuctionHasOrder objects pre-filled with their Order objects.
*
* @return AllegroAuctionHasOrder[] Array of AllegroAuctionHasOrder objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinOrder(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);
}
AllegroAuctionHasOrderPeer::addSelectColumns($c);
OrderPeer::addSelectColumns($c);
$c->addJoin(AllegroAuctionHasOrderPeer::ORDER_ID, OrderPeer::ID);
$rs = AllegroAuctionHasOrderPeer::doSelectRs($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$obj1 = new AllegroAuctionHasOrder();
$startcol = $obj1->hydrate($rs);
if ($obj1->getOrderId())
{
$obj2 = new Order();
$obj2->hydrate($rs, $startcol);
$obj2->addAllegroAuctionHasOrder($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(AllegroAuctionHasOrderPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(AllegroAuctionHasOrderPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(AllegroAuctionHasOrderPeer::ORDER_ID, OrderPeer::ID);
$rs = AllegroAuctionHasOrderPeer::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 AllegroAuctionHasOrder objects pre-filled with all related objects.
*
* @return AllegroAuctionHasOrder[]
* @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);
}
AllegroAuctionHasOrderPeer::addSelectColumns($c);
$startcol2 = (AllegroAuctionHasOrderPeer::NUM_COLUMNS - AllegroAuctionHasOrderPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
OrderPeer::addSelectColumns($c);
$startcol3 = $startcol2 + OrderPeer::NUM_COLUMNS;
$c->addJoin(AllegroAuctionHasOrderPeer::ORDER_ID, OrderPeer::ID);
$rs = BasePeer::doSelect($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$omClass = AllegroAuctionHasOrderPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
// Add objects for joined Order rows
$omClass = OrderPeer::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->getOrder(); // CHECKME
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addAllegroAuctionHasOrder($obj1); // CHECKME
break;
}
}
if ($newObject) {
$obj2->initAllegroAuctionHasOrders();
$obj2->addAllegroAuctionHasOrder($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 AllegroAuctionHasOrderPeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a AllegroAuctionHasOrder or Criteria object.
*
* @param mixed $values Criteria or AllegroAuctionHasOrder 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('BaseAllegroAuctionHasOrderPeer:doInsert:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseAllegroAuctionHasOrderPeer', $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 AllegroAuctionHasOrder 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('BaseAllegroAuctionHasOrderPeer:doInsert:post') as $callable)
{
call_user_func($callable, 'BaseAllegroAuctionHasOrderPeer', $values, $con, $pk);
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a AllegroAuctionHasOrder or Criteria object.
*
* @param mixed $values Criteria or AllegroAuctionHasOrder 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('BaseAllegroAuctionHasOrderPeer:doUpdate:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseAllegroAuctionHasOrderPeer', $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(AllegroAuctionHasOrderPeer::TRANS_ID);
$selectCriteria->add(AllegroAuctionHasOrderPeer::TRANS_ID, $criteria->remove(AllegroAuctionHasOrderPeer::TRANS_ID), $comparison);
$comparison = $criteria->getComparison(AllegroAuctionHasOrderPeer::ALLEGRO_AUCTION_ID);
$selectCriteria->add(AllegroAuctionHasOrderPeer::ALLEGRO_AUCTION_ID, $criteria->remove(AllegroAuctionHasOrderPeer::ALLEGRO_AUCTION_ID), $comparison);
$comparison = $criteria->getComparison(AllegroAuctionHasOrderPeer::ORDER_ID);
$selectCriteria->add(AllegroAuctionHasOrderPeer::ORDER_ID, $criteria->remove(AllegroAuctionHasOrderPeer::ORDER_ID), $comparison);
} else { // $values is AllegroAuctionHasOrder 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('BaseAllegroAuctionHasOrderPeer:doUpdate:post') as $callable)
{
call_user_func($callable, 'BaseAllegroAuctionHasOrderPeer', $values, $con, $ret);
}
return $ret;
}
/**
* Method to DELETE all rows from the st_allegro_auction_has_order 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(AllegroAuctionHasOrderPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a AllegroAuctionHasOrder or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or AllegroAuctionHasOrder 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(AllegroAuctionHasOrderPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof AllegroAuctionHasOrder) {
$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];
$vals[2][] = $value[2];
}
$criteria->add(AllegroAuctionHasOrderPeer::TRANS_ID, $vals[0], Criteria::IN);
$criteria->add(AllegroAuctionHasOrderPeer::ALLEGRO_AUCTION_ID, $vals[1], Criteria::IN);
$criteria->add(AllegroAuctionHasOrderPeer::ORDER_ID, $vals[2], 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 AllegroAuctionHasOrder 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 AllegroAuctionHasOrder $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(AllegroAuctionHasOrder $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(AllegroAuctionHasOrderPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(AllegroAuctionHasOrderPeer::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(AllegroAuctionHasOrderPeer::DATABASE_NAME, AllegroAuctionHasOrderPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = AllegroAuctionHasOrderPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
/**
* Retrieve object using using composite pkey values.
* @param string $trans_id
@param string $allegro_auction_id
@param int $order_id
* @param Connection $con
* @return AllegroAuctionHasOrder
*/
public static function retrieveByPK( $trans_id, $allegro_auction_id, $order_id, $con = null) {
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria();
$criteria->add(AllegroAuctionHasOrderPeer::TRANS_ID, $trans_id);
$criteria->add(AllegroAuctionHasOrderPeer::ALLEGRO_AUCTION_ID, $allegro_auction_id);
$criteria->add(AllegroAuctionHasOrderPeer::ORDER_ID, $order_id);
$v = AllegroAuctionHasOrderPeer::doSelect($criteria, $con);
return !empty($v) ? $v[0] : null;
}
} // BaseAllegroAuctionHasOrderPeer
// 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 {
BaseAllegroAuctionHasOrderPeer::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.stAllegroPlugin.lib.model.map.AllegroAuctionHasOrderMapBuilder');
}

View File

@@ -0,0 +1,896 @@
<?php
/**
* Base static class for performing query and update operations on the 'st_allegro_auction' table.
*
*
*
* @package plugins.stAllegroPlugin.lib.model.om
*/
abstract class BaseAllegroAuctionPeer {
/** the default database name for this class */
const DATABASE_NAME = 'propel';
/** the table name for this class */
const TABLE_NAME = 'st_allegro_auction';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'plugins.stAllegroPlugin.lib.model.AllegroAuction';
/** The total number of columns. */
const NUM_COLUMNS = 13;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the CREATED_AT field */
const CREATED_AT = 'st_allegro_auction.CREATED_AT';
/** the column name for the UPDATED_AT field */
const UPDATED_AT = 'st_allegro_auction.UPDATED_AT';
/** the column name for the ID field */
const ID = 'st_allegro_auction.ID';
/** the column name for the PRODUCT_ID field */
const PRODUCT_ID = 'st_allegro_auction.PRODUCT_ID';
/** the column name for the PRODUCT_OPTIONS field */
const PRODUCT_OPTIONS = 'st_allegro_auction.PRODUCT_OPTIONS';
/** the column name for the REQUIRES_SYNC field */
const REQUIRES_SYNC = 'st_allegro_auction.REQUIRES_SYNC';
/** the column name for the ALLOW_SYNC field */
const ALLOW_SYNC = 'st_allegro_auction.ALLOW_SYNC';
/** the column name for the SITE field */
const SITE = 'st_allegro_auction.SITE';
/** the column name for the NAME field */
const NAME = 'st_allegro_auction.NAME';
/** the column name for the AUCTION_ID field */
const AUCTION_ID = 'st_allegro_auction.AUCTION_ID';
/** the column name for the ENDED field */
const ENDED = 'st_allegro_auction.ENDED';
/** the column name for the ENDED_AT field */
const ENDED_AT = 'st_allegro_auction.ENDED_AT';
/** the column name for the COMMANDS field */
const COMMANDS = 'st_allegro_auction.COMMANDS';
/** 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', 'ProductId', 'ProductOptions', 'RequiresSync', 'AllowSync', 'Site', 'Name', 'AuctionId', 'Ended', 'EndedAt', 'Commands', ),
BasePeer::TYPE_COLNAME => array (AllegroAuctionPeer::CREATED_AT, AllegroAuctionPeer::UPDATED_AT, AllegroAuctionPeer::ID, AllegroAuctionPeer::PRODUCT_ID, AllegroAuctionPeer::PRODUCT_OPTIONS, AllegroAuctionPeer::REQUIRES_SYNC, AllegroAuctionPeer::ALLOW_SYNC, AllegroAuctionPeer::SITE, AllegroAuctionPeer::NAME, AllegroAuctionPeer::AUCTION_ID, AllegroAuctionPeer::ENDED, AllegroAuctionPeer::ENDED_AT, AllegroAuctionPeer::COMMANDS, ),
BasePeer::TYPE_FIELDNAME => array ('created_at', 'updated_at', 'id', 'product_id', 'product_options', 'requires_sync', 'allow_sync', 'site', 'name', 'auction_id', 'ended', 'ended_at', 'commands', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, )
);
/**
* 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, 'ProductId' => 3, 'ProductOptions' => 4, 'RequiresSync' => 5, 'AllowSync' => 6, 'Site' => 7, 'Name' => 8, 'AuctionId' => 9, 'Ended' => 10, 'EndedAt' => 11, 'Commands' => 12, ),
BasePeer::TYPE_COLNAME => array (AllegroAuctionPeer::CREATED_AT => 0, AllegroAuctionPeer::UPDATED_AT => 1, AllegroAuctionPeer::ID => 2, AllegroAuctionPeer::PRODUCT_ID => 3, AllegroAuctionPeer::PRODUCT_OPTIONS => 4, AllegroAuctionPeer::REQUIRES_SYNC => 5, AllegroAuctionPeer::ALLOW_SYNC => 6, AllegroAuctionPeer::SITE => 7, AllegroAuctionPeer::NAME => 8, AllegroAuctionPeer::AUCTION_ID => 9, AllegroAuctionPeer::ENDED => 10, AllegroAuctionPeer::ENDED_AT => 11, AllegroAuctionPeer::COMMANDS => 12, ),
BasePeer::TYPE_FIELDNAME => array ('created_at' => 0, 'updated_at' => 1, 'id' => 2, 'product_id' => 3, 'product_options' => 4, 'requires_sync' => 5, 'allow_sync' => 6, 'site' => 7, 'name' => 8, 'auction_id' => 9, 'ended' => 10, 'ended_at' => 11, 'commands' => 12, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, )
);
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.stAllegroPlugin.lib.model.map.AllegroAuctionMapBuilder');
}
/**
* 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 = AllegroAuctionPeer::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. AllegroAuctionPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(AllegroAuctionPeer::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(AllegroAuctionPeer::CREATED_AT);
$criteria->addSelectColumn(AllegroAuctionPeer::UPDATED_AT);
$criteria->addSelectColumn(AllegroAuctionPeer::ID);
$criteria->addSelectColumn(AllegroAuctionPeer::PRODUCT_ID);
$criteria->addSelectColumn(AllegroAuctionPeer::PRODUCT_OPTIONS);
$criteria->addSelectColumn(AllegroAuctionPeer::REQUIRES_SYNC);
$criteria->addSelectColumn(AllegroAuctionPeer::ALLOW_SYNC);
$criteria->addSelectColumn(AllegroAuctionPeer::SITE);
$criteria->addSelectColumn(AllegroAuctionPeer::NAME);
$criteria->addSelectColumn(AllegroAuctionPeer::AUCTION_ID);
$criteria->addSelectColumn(AllegroAuctionPeer::ENDED);
$criteria->addSelectColumn(AllegroAuctionPeer::ENDED_AT);
$criteria->addSelectColumn(AllegroAuctionPeer::COMMANDS);
if (stEventDispatcher::getInstance()->getListeners('AllegroAuctionPeer.postAddSelectColumns')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'AllegroAuctionPeer.postAddSelectColumns'));
}
}
const COUNT = 'COUNT(st_allegro_auction.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT st_allegro_auction.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(AllegroAuctionPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(AllegroAuctionPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = AllegroAuctionPeer::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 AllegroAuction
* @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 = AllegroAuctionPeer::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 AllegroAuction[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return AllegroAuctionPeer::populateObjects(AllegroAuctionPeer::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;
AllegroAuctionPeer::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 = AllegroAuctionPeer::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 Product 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 doCountJoinProduct(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(AllegroAuctionPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(AllegroAuctionPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(AllegroAuctionPeer::PRODUCT_ID, ProductPeer::ID);
$rs = AllegroAuctionPeer::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 AllegroAuction objects pre-filled with their Product objects.
*
* @return AllegroAuction[] Array of AllegroAuction objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinProduct(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);
}
AllegroAuctionPeer::addSelectColumns($c);
ProductPeer::addSelectColumns($c);
$c->addJoin(AllegroAuctionPeer::PRODUCT_ID, ProductPeer::ID);
$rs = AllegroAuctionPeer::doSelectRs($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$obj1 = new AllegroAuction();
$startcol = $obj1->hydrate($rs);
if ($obj1->getProductId())
{
$obj2 = new Product();
$obj2->hydrate($rs, $startcol);
$obj2->addAllegroAuction($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(AllegroAuctionPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(AllegroAuctionPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(AllegroAuctionPeer::PRODUCT_ID, ProductPeer::ID);
$rs = AllegroAuctionPeer::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 AllegroAuction objects pre-filled with all related objects.
*
* @return AllegroAuction[]
* @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);
}
AllegroAuctionPeer::addSelectColumns($c);
$startcol2 = (AllegroAuctionPeer::NUM_COLUMNS - AllegroAuctionPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
ProductPeer::addSelectColumns($c);
$startcol3 = $startcol2 + ProductPeer::NUM_COLUMNS;
$c->addJoin(AllegroAuctionPeer::PRODUCT_ID, ProductPeer::ID);
$rs = BasePeer::doSelect($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$omClass = AllegroAuctionPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
// Add objects for joined Product rows
$omClass = ProductPeer::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->getProduct(); // CHECKME
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addAllegroAuction($obj1); // CHECKME
break;
}
}
if ($newObject) {
$obj2->initAllegroAuctions();
$obj2->addAllegroAuction($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 AllegroAuctionPeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a AllegroAuction or Criteria object.
*
* @param mixed $values Criteria or AllegroAuction 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('BaseAllegroAuctionPeer:doInsert:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseAllegroAuctionPeer', $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 AllegroAuction object
}
$criteria->remove(AllegroAuctionPeer::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('BaseAllegroAuctionPeer:doInsert:post') as $callable)
{
call_user_func($callable, 'BaseAllegroAuctionPeer', $values, $con, $pk);
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a AllegroAuction or Criteria object.
*
* @param mixed $values Criteria or AllegroAuction 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('BaseAllegroAuctionPeer:doUpdate:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseAllegroAuctionPeer', $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(AllegroAuctionPeer::ID);
$selectCriteria->add(AllegroAuctionPeer::ID, $criteria->remove(AllegroAuctionPeer::ID), $comparison);
} else { // $values is AllegroAuction 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('BaseAllegroAuctionPeer:doUpdate:post') as $callable)
{
call_user_func($callable, 'BaseAllegroAuctionPeer', $values, $con, $ret);
}
return $ret;
}
/**
* Method to DELETE all rows from the st_allegro_auction 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(AllegroAuctionPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a AllegroAuction or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or AllegroAuction 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(AllegroAuctionPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof AllegroAuction) {
$criteria = $values->buildPkeyCriteria();
} else {
// it must be the primary key
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(AllegroAuctionPeer::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 += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Validates all modified columns of given AllegroAuction 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 AllegroAuction $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(AllegroAuction $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(AllegroAuctionPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(AllegroAuctionPeer::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(AllegroAuctionPeer::DATABASE_NAME, AllegroAuctionPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = AllegroAuctionPeer::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 AllegroAuction
*/
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(AllegroAuctionPeer::DATABASE_NAME);
$criteria->add(AllegroAuctionPeer::ID, $pk);
$v = AllegroAuctionPeer::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 AllegroAuction[]
*/
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(AllegroAuctionPeer::ID, $pks, Criteria::IN);
$objs = AllegroAuctionPeer::doSelect($criteria, $con);
}
return $objs;
}
} // BaseAllegroAuctionPeer
// 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 {
BaseAllegroAuctionPeer::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.stAllegroPlugin.lib.model.map.AllegroAuctionMapBuilder');
}

View File

@@ -0,0 +1,748 @@
<?php
/**
* Base class that represents a row from the 'st_allegro_parcel_tracking_number_queue' table.
*
*
*
* @package plugins.stAllegroPlugin.lib.model.om
*/
abstract class BaseAllegroParcelTrackingNumberQueue extends BaseObject implements Persistent {
protected static $dispatcher = null;
/**
* The value for the created_at field.
* @var int
*/
protected $created_at;
/**
* The value for the order_id field.
* @var int
*/
protected $order_id;
/**
* @var Order
*/
protected $aOrder;
/**
* 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 [optionally formatted] [created_at] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the integer unix timestamp will be returned.
* @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL).
* @throws PropelException - if unable to convert the date/time to timestamp.
*/
public function getCreatedAt($format = 'Y-m-d H:i:s')
{
if ($this->created_at === null || $this->created_at === '') {
return null;
} elseif (!is_int($this->created_at)) {
// a non-timestamp value was set externally, so we convert it
$ts = strtotime($this->created_at);
if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
}
} else {
$ts = $this->created_at;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
/**
* Get the [order_id] column value.
*
* @return int
*/
public function getOrderId()
{
return $this->order_id;
}
/**
* Set the value of [created_at] column.
*
* @param int $v new value
* @return void
*/
public function setCreatedAt($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->created_at !== $ts) {
$this->created_at = $ts;
$this->modifiedColumns[] = AllegroParcelTrackingNumberQueuePeer::CREATED_AT;
}
} // setCreatedAt()
/**
* Set the value of [order_id] column.
*
* @param int $v new value
* @return void
*/
public function setOrderId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->order_id !== $v) {
$this->order_id = $v;
$this->modifiedColumns[] = AllegroParcelTrackingNumberQueuePeer::ORDER_ID;
}
if ($this->aOrder !== null && $this->aOrder->getId() !== $v) {
$this->aOrder = null;
}
} // setOrderId()
/**
* 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('AllegroParcelTrackingNumberQueue.preHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'AllegroParcelTrackingNumberQueue.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
$startcol = $event['startcol'];
}
$this->created_at = $rs->getTimestamp($startcol + 0, null);
$this->order_id = $rs->getInt($startcol + 1);
$this->resetModified();
$this->setNew(false);
if ($this->getDispatcher()->getListeners('AllegroParcelTrackingNumberQueue.postHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'AllegroParcelTrackingNumberQueue.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 2)));
return $event['startcol'];
}
// FIXME - using NUM_COLUMNS may be clearer.
return $startcol + 2; // 2 = AllegroParcelTrackingNumberQueuePeer::NUM_COLUMNS - AllegroParcelTrackingNumberQueuePeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating AllegroParcelTrackingNumberQueue 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('AllegroParcelTrackingNumberQueue.preDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'AllegroParcelTrackingNumberQueue.preDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BaseAllegroParcelTrackingNumberQueue:delete:pre'))
{
foreach (sfMixer::getCallables('BaseAllegroParcelTrackingNumberQueue:delete:pre') as $callable)
{
$ret = call_user_func($callable, $this, $con);
if ($ret)
{
return;
}
}
}
if ($con === null) {
$con = Propel::getConnection(AllegroParcelTrackingNumberQueuePeer::DATABASE_NAME);
}
try {
$con->begin();
AllegroParcelTrackingNumberQueuePeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
if ($this->getDispatcher()->getListeners('AllegroParcelTrackingNumberQueue.postDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'AllegroParcelTrackingNumberQueue.postDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BaseAllegroParcelTrackingNumberQueue:delete:post'))
{
foreach (sfMixer::getCallables('BaseAllegroParcelTrackingNumberQueue: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('AllegroParcelTrackingNumberQueue.preSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'AllegroParcelTrackingNumberQueue.preSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BaseAllegroParcelTrackingNumberQueue:save:pre') as $callable)
{
$affectedRows = call_user_func($callable, $this, $con);
if (is_int($affectedRows))
{
return $affectedRows;
}
}
}
if ($this->isNew() && !$this->isColumnModified(AllegroParcelTrackingNumberQueuePeer::CREATED_AT))
{
$this->setCreatedAt(time());
}
if ($con === null) {
$con = Propel::getConnection(AllegroParcelTrackingNumberQueuePeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
if (!$this->alreadyInSave) {
if ($this->getDispatcher()->getListeners('AllegroParcelTrackingNumberQueue.postSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'AllegroParcelTrackingNumberQueue.postSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BaseAllegroParcelTrackingNumberQueue: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->aOrder !== null) {
if ($this->aOrder->isModified()) {
$affectedRows += $this->aOrder->save($con);
}
$this->setOrder($this->aOrder);
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = AllegroParcelTrackingNumberQueuePeer::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 += AllegroParcelTrackingNumberQueuePeer::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->aOrder !== null) {
if (!$this->aOrder->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aOrder->getValidationFailures());
}
}
if (($retval = AllegroParcelTrackingNumberQueuePeer::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 = AllegroParcelTrackingNumberQueuePeer::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->getCreatedAt();
break;
case 1:
return $this->getOrderId();
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 = AllegroParcelTrackingNumberQueuePeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getCreatedAt(),
$keys[1] => $this->getOrderId(),
);
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 = AllegroParcelTrackingNumberQueuePeer::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->setCreatedAt($value);
break;
case 1:
$this->setOrderId($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 = AllegroParcelTrackingNumberQueuePeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setCreatedAt($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setOrderId($arr[$keys[1]]);
}
/**
* 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(AllegroParcelTrackingNumberQueuePeer::DATABASE_NAME);
if ($this->isColumnModified(AllegroParcelTrackingNumberQueuePeer::CREATED_AT)) $criteria->add(AllegroParcelTrackingNumberQueuePeer::CREATED_AT, $this->created_at);
if ($this->isColumnModified(AllegroParcelTrackingNumberQueuePeer::ORDER_ID)) $criteria->add(AllegroParcelTrackingNumberQueuePeer::ORDER_ID, $this->order_id);
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(AllegroParcelTrackingNumberQueuePeer::DATABASE_NAME);
$criteria->add(AllegroParcelTrackingNumberQueuePeer::ORDER_ID, $this->order_id);
return $criteria;
}
/**
* Returns the primary key for this object (row).
* @return int
*/
public function getPrimaryKey()
{
return $this->getOrderId();
}
/**
* Returns [composite] primary key fields
*
* @param string $keyType
* @return array
*/
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
{
return array(AllegroParcelTrackingNumberQueuePeer::translateFieldName('order_id', BasePeer::TYPE_FIELDNAME, $keyType));
}
/**
* Generic method to set the primary key (order_id column).
*
* @param int $key Primary key.
* @return void
*/
public function setPrimaryKey($key)
{
$this->setOrderId($key);
}
/**
* 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 AllegroParcelTrackingNumberQueue (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->setCreatedAt($this->created_at);
$copyObj->setNew(true);
$copyObj->setOrderId(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 AllegroParcelTrackingNumberQueue 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 'AllegroParcelTrackingNumberQueuePeer';
}
/**
* Declares an association between this object and a Order object.
*
* @param Order $v
* @return void
* @throws PropelException
*/
public function setOrder($v)
{
if ($v === null) {
$this->setOrderId(NULL);
} else {
$this->setOrderId($v->getId());
}
$this->aOrder = $v;
}
/**
* Get the associated Order object
*
* @param Connection Optional Connection object.
* @return Order The associated Order object.
* @throws PropelException
*/
public function getOrder($con = null)
{
if ($this->aOrder === null && ($this->order_id !== null)) {
// include the related Peer class
$this->aOrder = OrderPeer::retrieveByPK($this->order_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 = OrderPeer::retrieveByPK($this->order_id, $con);
$obj->addOrders($this);
*/
}
return $this->aOrder;
}
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, 'AllegroParcelTrackingNumberQueue.' . $method, array('arguments' => $arguments, 'method' => $method)));
if ($event->isProcessed())
{
return $event->getReturnValue();
}
if (!$callable = sfMixer::getCallable('BaseAllegroParcelTrackingNumberQueue:'.$method))
{
throw new sfException(sprintf('Call to undefined method BaseAllegroParcelTrackingNumberQueue::%s', $method));
}
array_unshift($arguments, $this);
return call_user_func_array($callable, $arguments);
}
} // BaseAllegroParcelTrackingNumberQueue

View File

@@ -0,0 +1,839 @@
<?php
/**
* Base static class for performing query and update operations on the 'st_allegro_parcel_tracking_number_queue' table.
*
*
*
* @package plugins.stAllegroPlugin.lib.model.om
*/
abstract class BaseAllegroParcelTrackingNumberQueuePeer {
/** the default database name for this class */
const DATABASE_NAME = 'propel';
/** the table name for this class */
const TABLE_NAME = 'st_allegro_parcel_tracking_number_queue';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'plugins.stAllegroPlugin.lib.model.AllegroParcelTrackingNumberQueue';
/** The total number of columns. */
const NUM_COLUMNS = 2;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the CREATED_AT field */
const CREATED_AT = 'st_allegro_parcel_tracking_number_queue.CREATED_AT';
/** the column name for the ORDER_ID field */
const ORDER_ID = 'st_allegro_parcel_tracking_number_queue.ORDER_ID';
/** 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', 'OrderId', ),
BasePeer::TYPE_COLNAME => array (AllegroParcelTrackingNumberQueuePeer::CREATED_AT, AllegroParcelTrackingNumberQueuePeer::ORDER_ID, ),
BasePeer::TYPE_FIELDNAME => array ('created_at', 'order_id', ),
BasePeer::TYPE_NUM => array (0, 1, )
);
/**
* 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, 'OrderId' => 1, ),
BasePeer::TYPE_COLNAME => array (AllegroParcelTrackingNumberQueuePeer::CREATED_AT => 0, AllegroParcelTrackingNumberQueuePeer::ORDER_ID => 1, ),
BasePeer::TYPE_FIELDNAME => array ('created_at' => 0, 'order_id' => 1, ),
BasePeer::TYPE_NUM => array (0, 1, )
);
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.stAllegroPlugin.lib.model.map.AllegroParcelTrackingNumberQueueMapBuilder');
}
/**
* 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 = AllegroParcelTrackingNumberQueuePeer::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. AllegroParcelTrackingNumberQueuePeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(AllegroParcelTrackingNumberQueuePeer::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(AllegroParcelTrackingNumberQueuePeer::CREATED_AT);
$criteria->addSelectColumn(AllegroParcelTrackingNumberQueuePeer::ORDER_ID);
if (stEventDispatcher::getInstance()->getListeners('AllegroParcelTrackingNumberQueuePeer.postAddSelectColumns')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'AllegroParcelTrackingNumberQueuePeer.postAddSelectColumns'));
}
}
const COUNT = 'COUNT(st_allegro_parcel_tracking_number_queue.ORDER_ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT st_allegro_parcel_tracking_number_queue.ORDER_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(AllegroParcelTrackingNumberQueuePeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(AllegroParcelTrackingNumberQueuePeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = AllegroParcelTrackingNumberQueuePeer::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 AllegroParcelTrackingNumberQueue
* @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 = AllegroParcelTrackingNumberQueuePeer::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 AllegroParcelTrackingNumberQueue[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return AllegroParcelTrackingNumberQueuePeer::populateObjects(AllegroParcelTrackingNumberQueuePeer::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;
AllegroParcelTrackingNumberQueuePeer::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 = AllegroParcelTrackingNumberQueuePeer::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 Order 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 doCountJoinOrder(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(AllegroParcelTrackingNumberQueuePeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(AllegroParcelTrackingNumberQueuePeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(AllegroParcelTrackingNumberQueuePeer::ORDER_ID, OrderPeer::ID);
$rs = AllegroParcelTrackingNumberQueuePeer::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 AllegroParcelTrackingNumberQueue objects pre-filled with their Order objects.
*
* @return AllegroParcelTrackingNumberQueue[] Array of AllegroParcelTrackingNumberQueue objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinOrder(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);
}
AllegroParcelTrackingNumberQueuePeer::addSelectColumns($c);
OrderPeer::addSelectColumns($c);
$c->addJoin(AllegroParcelTrackingNumberQueuePeer::ORDER_ID, OrderPeer::ID);
$rs = AllegroParcelTrackingNumberQueuePeer::doSelectRs($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$obj1 = new AllegroParcelTrackingNumberQueue();
$startcol = $obj1->hydrate($rs);
if ($obj1->getOrderId())
{
$obj2 = new Order();
$obj2->hydrate($rs, $startcol);
$obj2->addAllegroParcelTrackingNumberQueue($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(AllegroParcelTrackingNumberQueuePeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(AllegroParcelTrackingNumberQueuePeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(AllegroParcelTrackingNumberQueuePeer::ORDER_ID, OrderPeer::ID);
$rs = AllegroParcelTrackingNumberQueuePeer::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 AllegroParcelTrackingNumberQueue objects pre-filled with all related objects.
*
* @return AllegroParcelTrackingNumberQueue[]
* @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);
}
AllegroParcelTrackingNumberQueuePeer::addSelectColumns($c);
$startcol2 = (AllegroParcelTrackingNumberQueuePeer::NUM_COLUMNS - AllegroParcelTrackingNumberQueuePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
OrderPeer::addSelectColumns($c);
$startcol3 = $startcol2 + OrderPeer::NUM_COLUMNS;
$c->addJoin(AllegroParcelTrackingNumberQueuePeer::ORDER_ID, OrderPeer::ID);
$rs = BasePeer::doSelect($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$omClass = AllegroParcelTrackingNumberQueuePeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
// Add objects for joined Order rows
$omClass = OrderPeer::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->getOrder(); // CHECKME
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addAllegroParcelTrackingNumberQueue($obj1); // CHECKME
break;
}
}
if ($newObject) {
$obj2->initAllegroParcelTrackingNumberQueues();
$obj2->addAllegroParcelTrackingNumberQueue($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 AllegroParcelTrackingNumberQueuePeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a AllegroParcelTrackingNumberQueue or Criteria object.
*
* @param mixed $values Criteria or AllegroParcelTrackingNumberQueue 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('BaseAllegroParcelTrackingNumberQueuePeer:doInsert:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseAllegroParcelTrackingNumberQueuePeer', $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 AllegroParcelTrackingNumberQueue 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('BaseAllegroParcelTrackingNumberQueuePeer:doInsert:post') as $callable)
{
call_user_func($callable, 'BaseAllegroParcelTrackingNumberQueuePeer', $values, $con, $pk);
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a AllegroParcelTrackingNumberQueue or Criteria object.
*
* @param mixed $values Criteria or AllegroParcelTrackingNumberQueue 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('BaseAllegroParcelTrackingNumberQueuePeer:doUpdate:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseAllegroParcelTrackingNumberQueuePeer', $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(AllegroParcelTrackingNumberQueuePeer::ORDER_ID);
$selectCriteria->add(AllegroParcelTrackingNumberQueuePeer::ORDER_ID, $criteria->remove(AllegroParcelTrackingNumberQueuePeer::ORDER_ID), $comparison);
} else { // $values is AllegroParcelTrackingNumberQueue 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('BaseAllegroParcelTrackingNumberQueuePeer:doUpdate:post') as $callable)
{
call_user_func($callable, 'BaseAllegroParcelTrackingNumberQueuePeer', $values, $con, $ret);
}
return $ret;
}
/**
* Method to DELETE all rows from the st_allegro_parcel_tracking_number_queue 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(AllegroParcelTrackingNumberQueuePeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a AllegroParcelTrackingNumberQueue or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or AllegroParcelTrackingNumberQueue 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(AllegroParcelTrackingNumberQueuePeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof AllegroParcelTrackingNumberQueue) {
$criteria = $values->buildPkeyCriteria();
} else {
// it must be the primary key
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(AllegroParcelTrackingNumberQueuePeer::ORDER_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 += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Validates all modified columns of given AllegroParcelTrackingNumberQueue 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 AllegroParcelTrackingNumberQueue $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(AllegroParcelTrackingNumberQueue $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(AllegroParcelTrackingNumberQueuePeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(AllegroParcelTrackingNumberQueuePeer::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(AllegroParcelTrackingNumberQueuePeer::DATABASE_NAME, AllegroParcelTrackingNumberQueuePeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = AllegroParcelTrackingNumberQueuePeer::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 AllegroParcelTrackingNumberQueue
*/
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(AllegroParcelTrackingNumberQueuePeer::DATABASE_NAME);
$criteria->add(AllegroParcelTrackingNumberQueuePeer::ORDER_ID, $pk);
$v = AllegroParcelTrackingNumberQueuePeer::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 AllegroParcelTrackingNumberQueue[]
*/
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(AllegroParcelTrackingNumberQueuePeer::ORDER_ID, $pks, Criteria::IN);
$objs = AllegroParcelTrackingNumberQueuePeer::doSelect($criteria, $con);
}
return $objs;
}
} // BaseAllegroParcelTrackingNumberQueuePeer
// 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 {
BaseAllegroParcelTrackingNumberQueuePeer::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.stAllegroPlugin.lib.model.map.AllegroParcelTrackingNumberQueueMapBuilder');
}