first commit
This commit is contained in:
314
plugins/stDiscountPlugin/lib/model/Discount.php
Normal file
314
plugins/stDiscountPlugin/lib/model/Discount.php
Normal file
@@ -0,0 +1,314 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stDiscountPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stDiscountPlugin 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 stDiscountPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: Discount.php 2008 2009-11-05 11:13:04Z piotr $
|
||||
*/
|
||||
|
||||
if (SF_APP == 'backend')
|
||||
{
|
||||
require_once sfConfig::get('sf_root_dir').'/apps/frontend/lib/stBasket.class.php';
|
||||
}
|
||||
|
||||
class Discount extends BaseDiscount
|
||||
{
|
||||
const PRICE_TYPE = 'P';
|
||||
const PERCENT_TYPE = '%';
|
||||
|
||||
protected $products = null;
|
||||
|
||||
protected static $availability = null;
|
||||
|
||||
protected $isDiscountRange = null;
|
||||
|
||||
public function __toString() {
|
||||
return $this->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sprawdza czy rabat jest dostępny dla wybranego użytkownika
|
||||
*
|
||||
* @param null|sfGuardUser $user
|
||||
* @return bool
|
||||
*/
|
||||
public function isAvailableForUser($user = null)
|
||||
{
|
||||
if ($user && !empty($user->getWholesale()) && null === $this->getWholesaleValue())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$uid = $user ? DiscountPeer::doSelectIdsByUser($user) : [];
|
||||
|
||||
return null !== $this->getValueByUser($user) && (!$user && $this->getAllowAnonymousClients() || $user && $this->getAllClients() || isset($uid[$this->getId()]));
|
||||
}
|
||||
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->type != 'O')
|
||||
{
|
||||
$this->setConditions(null);
|
||||
}
|
||||
elseif ($this->type == 'O')
|
||||
{
|
||||
$this->setAllProducts(true);
|
||||
}
|
||||
|
||||
$clearCache = $this->isModified();
|
||||
|
||||
$ret = parent::save($con);
|
||||
|
||||
if ($clearCache)
|
||||
{
|
||||
DiscountPeer::clearCache();
|
||||
stPartialCache::clear('stProduct', '_productGroup', array('app' => 'frontend'));
|
||||
stPartialCache::clear('stProduct', '_new', array('app' => 'frontend'));
|
||||
stFastCacheManager::clearCache();
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getTypeLabel()
|
||||
{
|
||||
$types = DiscountPeer::getDiscountTypes();
|
||||
|
||||
return $this->type ? $types[$this->type] : null;
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
$ret = parent::delete($con);
|
||||
DiscountPeer::clearCache();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getCondition($name, $default = null)
|
||||
{
|
||||
$conditions = $this->getConditions();
|
||||
|
||||
$value = isset($conditions[$name]) ? $conditions[$name] : $default;
|
||||
|
||||
return is_numeric($value) ? floatval($value) : $value;
|
||||
}
|
||||
|
||||
public function isDiscountRange()
|
||||
{
|
||||
if (null === $this->isDiscountRange)
|
||||
{
|
||||
$this->isDiscountRange = !$this->isNew() && $this->countDiscountRanges() > 0;
|
||||
}
|
||||
|
||||
return $this->isDiscountRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca wartość rabatu dla wybranego użytkownika
|
||||
*
|
||||
* @param null|sfGuardUser $user
|
||||
* @return float
|
||||
*/
|
||||
public function getValueByUser($user = null)
|
||||
{
|
||||
return null !== $user && !empty($user->getWholesale()) ? $this->getWholesaleValue() : $this->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Nakłada rabat na przekazaną cenę
|
||||
*
|
||||
* @param float $amount Cena
|
||||
* @param null|sfGuardUser $user Użytkownik
|
||||
* @param bool $withCurrency Uwzględnij walutę
|
||||
* @return float
|
||||
*/
|
||||
public function apply($amount, $user = null, $withCurrency = true)
|
||||
{
|
||||
if ($this->getPriceType() == self::PERCENT_TYPE)
|
||||
{
|
||||
$amount = stPrice::applyDiscount($amount, $this->getValueByUser($user));
|
||||
}
|
||||
else
|
||||
{
|
||||
$discountValue = $this->getValueByUser($user);
|
||||
|
||||
if ($withCurrency)
|
||||
{
|
||||
$discountValue = stCurrency::exchange($discountValue);
|
||||
}
|
||||
|
||||
$amount -= $discountValue;
|
||||
}
|
||||
|
||||
return $amount > 0 ? $amount : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca produkty przypisane do zestawu
|
||||
*
|
||||
* @param bool $with_default Uwzględnij produkt główny
|
||||
* @param bool $check Zweryfikuj dostępność produktów
|
||||
* @return Product[]
|
||||
* @throws PropelException
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function getProducts($with_default = true, $check = true)
|
||||
{
|
||||
if (null === $this->products)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->addSelectColumn(DiscountHasProductPeer::PRODUCT_ID);
|
||||
$c->add(DiscountHasProductPeer::DISCOUNT_ID, $this->getId());
|
||||
$rs = DiscountHasProductPeer::doSelectRS($c);
|
||||
|
||||
$ids = array();
|
||||
|
||||
while($rs->next())
|
||||
{
|
||||
list($id) = $rs->getRow();
|
||||
$ids[] = $id;
|
||||
}
|
||||
|
||||
$c = new Criteria();
|
||||
$c->add(ProductPeer::ID, $ids, Criteria::IN);
|
||||
ProductPeer::addFilterCriteria(null, $c);
|
||||
|
||||
$this->products = ProductPeer::doSelectWithI18n($c);
|
||||
|
||||
if ($check)
|
||||
{
|
||||
if (count($ids) != count($this->products))
|
||||
{
|
||||
$this->products = array();
|
||||
}
|
||||
|
||||
$avail = $this->getAvailability();
|
||||
|
||||
foreach ($this->products as $p)
|
||||
{
|
||||
if (!stBasket::isEnabled($p) || $avail && ($p->getAvailabilityId() == $avail->getId() || $p->getFrontendAvailability()->getId() == $avail->getId()))
|
||||
{
|
||||
$this->products = array();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($with_default && $this->products)
|
||||
{
|
||||
return array_merge(array($this->getProduct()), $this->products);
|
||||
}
|
||||
|
||||
return $this->products;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca łączną cenę zestawu
|
||||
*
|
||||
* @param bool $with_discount Uwzględniaj rabaty
|
||||
* @param bool $with_tax Uwzgędniaj podatek
|
||||
* @return float
|
||||
* @throws PropelException
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function getTotalProductAmount($with_discount = true, $with_tax = true)
|
||||
{
|
||||
$total = 0;
|
||||
|
||||
$sf_user = sfContext::getInstance()->getUser();
|
||||
|
||||
$user = $sf_user->isAuthenticated() ? $sf_user->getGuardUser() : null;
|
||||
|
||||
$with_discount = $with_discount && !stDiscount::isDisabledForWholesale($user);
|
||||
|
||||
$products = $this->getProducts();
|
||||
|
||||
if (empty($products))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($this->getPriceType() == self::PERCENT_TYPE)
|
||||
{
|
||||
foreach ($products as $product)
|
||||
{
|
||||
$price = $product->getPriceBrutto(true);
|
||||
|
||||
$total += $price;
|
||||
}
|
||||
|
||||
if ($with_discount)
|
||||
{
|
||||
$total = stPrice::applyDiscount($total, $this->getValueByUser($user));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($products as $product)
|
||||
{
|
||||
$price = $product->getPriceBrutto(true);
|
||||
|
||||
$total += $price;
|
||||
}
|
||||
|
||||
if ($with_discount)
|
||||
{
|
||||
$total -= stCurrency::exchange($this->getValueByUser($user));
|
||||
}
|
||||
}
|
||||
|
||||
return $with_tax ? $total : stPrice::extract($total, $products[0]->getVatValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca łączną wagę zestawu
|
||||
*
|
||||
* @return float
|
||||
* @throws PropelException
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function getTotalWeight()
|
||||
{
|
||||
$weight = 0;
|
||||
|
||||
foreach ($this->getProducts() as $product)
|
||||
{
|
||||
$weight += $product->getWeight();
|
||||
}
|
||||
|
||||
return $weight;
|
||||
}
|
||||
|
||||
protected static function getAvailability()
|
||||
{
|
||||
if (null === self::$availability)
|
||||
{
|
||||
$config = stConfig::getInstance('stAvailabilityBackend');
|
||||
|
||||
$id = $config->get('hide_products_avail');
|
||||
|
||||
|
||||
if ($id && $config->get('hide_products_avail_on'))
|
||||
{
|
||||
self::$availability = AvailabilityPeer::retrieveByPK($id);
|
||||
}
|
||||
else
|
||||
{
|
||||
self::$availability = false;
|
||||
}
|
||||
}
|
||||
|
||||
return self::$availability;
|
||||
}
|
||||
}
|
||||
|
||||
sfPropelBehavior::add('Discount', array('act_as_sortable' => array('column' => 'priority')));
|
||||
148
plugins/stDiscountPlugin/lib/model/DiscountCouponCode.php
Normal file
148
plugins/stDiscountPlugin/lib/model/DiscountCouponCode.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_discount_coupon_code' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model
|
||||
*/
|
||||
class DiscountCouponCode extends BaseDiscountCouponCode
|
||||
{
|
||||
|
||||
protected $isValid = null;
|
||||
|
||||
public function getAdminGeneratorTitle()
|
||||
{
|
||||
return $this->getCode();
|
||||
}
|
||||
|
||||
public function setCcEditDiscount($v)
|
||||
{
|
||||
$this->setDiscount($v);
|
||||
}
|
||||
|
||||
public function getCode()
|
||||
{
|
||||
if (parent::getCode() === null)
|
||||
{
|
||||
$this->generate();
|
||||
}
|
||||
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function isValid()
|
||||
{
|
||||
if (null === $this->isValid)
|
||||
{
|
||||
$this->isValid = $this->validateUsage() && $this->validateDate();
|
||||
}
|
||||
|
||||
return $this->isValid;
|
||||
}
|
||||
|
||||
public function getAllowAllProducts()
|
||||
{
|
||||
$value = parent::getAllowAllProducts();
|
||||
|
||||
return null === $value && !$this->isNew() ? true : $value;
|
||||
}
|
||||
|
||||
public function incrementUsage()
|
||||
{
|
||||
$this->setUsed($this->used + 1);
|
||||
}
|
||||
|
||||
public function setValidFrom($v)
|
||||
{
|
||||
parent::setValidFrom($v);
|
||||
|
||||
$this->isValid = null;
|
||||
}
|
||||
|
||||
public function setValidTo($v)
|
||||
{
|
||||
parent::setValidTo($v);
|
||||
|
||||
$this->isValid = null;
|
||||
}
|
||||
|
||||
public function setValidUsage($v)
|
||||
{
|
||||
parent::setValidUsage($v);
|
||||
|
||||
$this->isValid = null;
|
||||
}
|
||||
|
||||
public function setUsed($v)
|
||||
{
|
||||
parent::setUsed($v);
|
||||
|
||||
$this->isValid = null;
|
||||
}
|
||||
|
||||
public function getUsageLeft()
|
||||
{
|
||||
$left = $this->getValidUsage() - $this->getUsed();
|
||||
|
||||
return $left > 0 ? $left : 0;
|
||||
}
|
||||
|
||||
public function setValidFor($v)
|
||||
{
|
||||
$valid_to = date('Y-m-d H:i:s', time() + $v * 24 * 60 * 60);
|
||||
|
||||
$this->setValidTo($valid_to);
|
||||
}
|
||||
|
||||
public function validateUsage()
|
||||
{
|
||||
return !$this->getValidUsage() || $this->getUsed() < $this->getValidUsage();
|
||||
}
|
||||
|
||||
public function validateDate()
|
||||
{
|
||||
$current_time = time();
|
||||
|
||||
return (!$this->getValidFrom() || strtotime($this->getValidFrom()) <= $current_time) && (!$this->getValidTo() || strtotime($this->getValidTo()) >= $current_time);
|
||||
}
|
||||
|
||||
public function save($con = null)
|
||||
{
|
||||
if (null === $this->code)
|
||||
{
|
||||
$this->generate();
|
||||
}
|
||||
|
||||
if ($this->valid_usage > 0 && $this->used > $this->valid_usage)
|
||||
{
|
||||
$this->used = $this->valid_usage;
|
||||
}
|
||||
|
||||
return parent::save($con);
|
||||
}
|
||||
|
||||
|
||||
public function generate()
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->addSelectColumn('MAX('.DiscountCouponCodePeer::ID.')');
|
||||
$rs = DiscountCouponCodePeer::doSelectRs($c);
|
||||
|
||||
if ($rs->next())
|
||||
{
|
||||
$prefix = $rs->getInt(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$prefix = 1;
|
||||
}
|
||||
|
||||
$config = stConfig::getInstance('stDiscountBackend');
|
||||
|
||||
$generator = new stKeyGenerator($prefix + 1, $config->get('code_format'));
|
||||
|
||||
$this->setCode($generator->generate());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_discount_coupon_code_has_category' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model
|
||||
*/
|
||||
class DiscountCouponCodeHasCategory extends BaseDiscountCouponCodeHasCategory
|
||||
{
|
||||
public function save($con = null)
|
||||
{
|
||||
$isNew = $this->isNew();
|
||||
|
||||
$result = parent::save($con);
|
||||
|
||||
if ($isNew && $this->getCategory()->hasChildren())
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$con->executeQuery(sprintf("INSERT INTO %s (%s, %s, %s) SELECT %d, %s, %d FROM %s WHERE %s BETWEEN %d AND %d AND %s = %d",
|
||||
DiscountCouponCodeHasCategoryPeer::TABLE_NAME,
|
||||
DiscountCouponCodeHasCategoryPeer::DISCOUNT_COUPON_CODE_ID,
|
||||
DiscountCouponCodeHasCategoryPeer::CATEGORY_ID,
|
||||
DiscountCouponCodeHasCategoryPeer::IS_OPT,
|
||||
$this->getDiscountCouponCodeId(),
|
||||
CategoryPeer::ID,
|
||||
1,
|
||||
CategoryPeer::TABLE_NAME,
|
||||
CategoryPeer::LFT,
|
||||
$this->getCategory()->getLft() + 1,
|
||||
$this->getCategory()->getRgt() - 1,
|
||||
CategoryPeer::SCOPE,
|
||||
$this->getCategory()->getScope()
|
||||
));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'st_discount_coupon_code_has_category' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model
|
||||
*/
|
||||
class DiscountCouponCodeHasCategoryPeer extends BaseDiscountCouponCodeHasCategoryPeer
|
||||
{
|
||||
public static function doSelectCategoriesForTokenInput(DiscountCouponCode $discount)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(self::DISCOUNT_COUPON_CODE_ID, $discount->getId());
|
||||
|
||||
$c->addJoin(self::CATEGORY_ID, CategoryPeer::ID);
|
||||
|
||||
$c->add(self::IS_OPT, false);
|
||||
|
||||
$c->addAscendingOrderByColumn(self::CATEGORY_ID);
|
||||
|
||||
return CategoryPeer::doSelectCategoriesTokens($c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_discount_coupon_code_has_producer' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model
|
||||
*/
|
||||
class DiscountCouponCodeHasProducer extends BaseDiscountCouponCodeHasProducer
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'st_discount_coupon_code_has_producer' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model
|
||||
*/
|
||||
class DiscountCouponCodeHasProducerPeer extends BaseDiscountCouponCodeHasProducerPeer
|
||||
{
|
||||
public static function doSelectProducerForTokenInput(DiscountCouponCode $discount)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(self::DISCOUNT_COUPON_CODE_ID, $discount->getId());
|
||||
|
||||
$c->addJoin(self::PRODUCER_ID, ProducerPeer::ID);
|
||||
|
||||
$c->addAscendingOrderByColumn(self::PRODUCER_ID);
|
||||
|
||||
return ProducerPeer::doSelectTokens($c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_discount_coupon_code_has_product' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model
|
||||
*/
|
||||
class DiscountCouponCodeHasProduct extends BaseDiscountCouponCodeHasProduct
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'st_discount_coupon_code_has_product' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model
|
||||
*/
|
||||
class DiscountCouponCodeHasProductPeer extends BaseDiscountCouponCodeHasProductPeer
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'st_discount_coupon_code' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model
|
||||
*/
|
||||
class DiscountCouponCodePeer extends BaseDiscountCouponCodePeer
|
||||
{
|
||||
public static function retrieveNewCode()
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->addSelectColumn('MAX('.DiscountCouponCodePeer::ID.')');
|
||||
|
||||
$rs = DiscountCouponCodePeer::doSelectRS($c);
|
||||
|
||||
if ($rs->next())
|
||||
{
|
||||
$id = $rs->getInt(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = 0;
|
||||
}
|
||||
|
||||
$c->clear();
|
||||
|
||||
for ($n = 0; $n <= 10; $n++)
|
||||
{
|
||||
$code = base_convert(60000 + $id * 1000 + rand(1, 1000), 10, 35);
|
||||
|
||||
$c->add(self::CODE, $code);
|
||||
|
||||
if (!self::doCount($c))
|
||||
{
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function retrieveByCode($code)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(self::CODE, $code);
|
||||
|
||||
return self::doSelectOne($c);
|
||||
}
|
||||
}
|
||||
41
plugins/stDiscountPlugin/lib/model/DiscountHasCategory.php
Normal file
41
plugins/stDiscountPlugin/lib/model/DiscountHasCategory.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_discount_has_category' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model
|
||||
*/
|
||||
class DiscountHasCategory extends BaseDiscountHasCategory
|
||||
{
|
||||
public function save($con = null)
|
||||
{
|
||||
$isNew = $this->isNew();
|
||||
|
||||
$result = parent::save($con);
|
||||
|
||||
if ($isNew && $this->getCategory()->hasChildren())
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$con->executeQuery(sprintf("INSERT INTO %s (%s, %s, %s) SELECT %d, %s, %d FROM %s WHERE %s BETWEEN %d AND %d AND %s = %d",
|
||||
DiscountHasCategoryPeer::TABLE_NAME,
|
||||
DiscountHasCategoryPeer::DISCOUNT_ID,
|
||||
DiscountHasCategoryPeer::CATEGORY_ID,
|
||||
DiscountHasCategoryPeer::IS_OPT,
|
||||
$this->getDiscountId(),
|
||||
CategoryPeer::ID,
|
||||
1,
|
||||
CategoryPeer::TABLE_NAME,
|
||||
CategoryPeer::LFT,
|
||||
$this->getCategory()->getLft() + 1,
|
||||
$this->getCategory()->getRgt() - 1,
|
||||
CategoryPeer::SCOPE,
|
||||
$this->getCategory()->getScope()
|
||||
));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'st_discount_has_category' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model
|
||||
*/
|
||||
class DiscountHasCategoryPeer extends BaseDiscountHasCategoryPeer
|
||||
{
|
||||
public static function doSelectCategoriesForTokenInput(Discount $discount)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(self::DISCOUNT_ID, $discount->getId());
|
||||
|
||||
$c->add(self::IS_OPT, false);
|
||||
|
||||
$c->addJoin(self::CATEGORY_ID, CategoryPeer::ID);
|
||||
|
||||
$c->addAscendingOrderByColumn(self::CATEGORY_ID);
|
||||
|
||||
return CategoryPeer::doSelectCategoriesTokens($c);
|
||||
}
|
||||
}
|
||||
12
plugins/stDiscountPlugin/lib/model/DiscountHasProducer.php
Normal file
12
plugins/stDiscountPlugin/lib/model/DiscountHasProducer.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_discount_has_producer' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model
|
||||
*/
|
||||
class DiscountHasProducer extends BaseDiscountHasProducer
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'st_discount_has_producer' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model
|
||||
*/
|
||||
class DiscountHasProducerPeer extends BaseDiscountHasProducerPeer
|
||||
{
|
||||
public static function doSelectProducerForTokenInput(Discount $discount)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(self::DISCOUNT_ID, $discount->getId());
|
||||
|
||||
$c->addJoin(self::PRODUCER_ID, ProducerPeer::ID);
|
||||
|
||||
$c->addAscendingOrderByColumn(self::PRODUCER_ID);
|
||||
|
||||
return ProducerPeer::doSelectTokens($c);
|
||||
}
|
||||
}
|
||||
32
plugins/stDiscountPlugin/lib/model/DiscountHasProduct.php
Normal file
32
plugins/stDiscountPlugin/lib/model/DiscountHasProduct.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stDiscountPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stDiscountPlugin 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 stDiscountPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: DiscountHasProduct.php 10 2009-08-24 09:32:18Z michal $
|
||||
*/
|
||||
|
||||
class DiscountHasProduct extends BaseDiscountHasProduct
|
||||
{
|
||||
public function save($con = null)
|
||||
{
|
||||
$ret = parent::save($con);
|
||||
stFastCacheManager::clearCache();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
$ret = parent::delete($con);
|
||||
stFastCacheManager::clearCache();
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stDiscountPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stDiscountPlugin 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 stDiscountPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: DiscountHasProductPeer.php 10 2009-08-24 09:32:18Z michal $
|
||||
*/
|
||||
|
||||
class DiscountHasProductPeer extends BaseDiscountHasProductPeer
|
||||
{
|
||||
}
|
||||
324
plugins/stDiscountPlugin/lib/model/DiscountPeer.php
Normal file
324
plugins/stDiscountPlugin/lib/model/DiscountPeer.php
Normal file
@@ -0,0 +1,324 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stDiscountPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stDiscountPlugin 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 stDiscountPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: DiscountPeer.php 10 2009-08-24 09:32:18Z michal $
|
||||
*/
|
||||
|
||||
class DiscountPeer extends BaseDiscountPeer
|
||||
{
|
||||
protected static $activeDiscounts = null;
|
||||
|
||||
protected static $idsForUser = array();
|
||||
|
||||
protected static $discountsForUser = array();
|
||||
|
||||
protected static $productBatchIds = array();
|
||||
|
||||
protected static $productBatchDiscountIds = null;
|
||||
|
||||
public static function getDiscountTypes()
|
||||
{
|
||||
return array(
|
||||
'P' => __('Na produkty', null, 'stDiscountBackend'),
|
||||
'O' => __('Na zamówienie', null, 'stDiscountBackend'),
|
||||
'S' => __('Na zestaw', null, 'stDiscountBackend')
|
||||
);
|
||||
}
|
||||
|
||||
public static function doSelectIdsByUser(sfGuardUser $user)
|
||||
{
|
||||
if (!isset(self::$idsForUser[$user->getId()]))
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->addSelectColumn(UserHasDiscountPeer::DISCOUNT_ID);
|
||||
$c->add(UserHasDiscountPeer::SF_GUARD_USER_ID, $user->getId());
|
||||
$rs = UserHasDiscountPeer::doSelectRS($c);
|
||||
$ids = array();
|
||||
while($rs->next())
|
||||
{
|
||||
list($id) = $rs->getRow();
|
||||
$ids[$id] = $id;
|
||||
}
|
||||
self::$idsForUser[$user->getId()] = $ids;
|
||||
}
|
||||
|
||||
return self::$idsForUser[$user->getId()];
|
||||
}
|
||||
|
||||
public static function setProductBatchIds(array $ids)
|
||||
{
|
||||
if (self::$productBatchIds != $ids)
|
||||
{
|
||||
self::$productBatchIds = $ids;
|
||||
self::$productBatchDiscountIds = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function fetchAllProductBatchDiscountIds()
|
||||
{
|
||||
if (null === self::$productBatchDiscountIds && self::$productBatchIds)
|
||||
{
|
||||
$ids = array();
|
||||
|
||||
foreach (self::$productBatchIds as $product_id)
|
||||
{
|
||||
$ids[$product_id] = array();
|
||||
}
|
||||
|
||||
self::updateProductBatchDiscountIds(self::$productBatchIds);
|
||||
}
|
||||
|
||||
return self::$productBatchDiscountIds;
|
||||
}
|
||||
|
||||
public static function updateProductBatchDiscountIds(array $productIds)
|
||||
{
|
||||
if ($productIds)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->addSelectColumn(ProductHasCategoryPeer::PRODUCT_ID);
|
||||
$c->addSelectColumn(DiscountHasCategoryPeer::DISCOUNT_ID);
|
||||
$c->addJoin(DiscountHasCategoryPeer::CATEGORY_ID, ProductHasCategoryPeer::CATEGORY_ID);
|
||||
$c->add(ProductHasCategoryPeer::PRODUCT_ID, $productIds, Criteria::IN);
|
||||
$c->addGroupByColumn(ProductHasCategoryPeer::PRODUCT_ID);
|
||||
$c->addGroupByColumn(DiscountHasCategoryPeer::DISCOUNT_ID);
|
||||
|
||||
$rs = ProductHasCategoryPeer::doSelectRS($c);
|
||||
|
||||
while($rs->next())
|
||||
{
|
||||
list($product_id, $id) = $rs->getRow();
|
||||
self::$productBatchDiscountIds[$product_id][$id] = $id;
|
||||
}
|
||||
|
||||
$c = new Criteria();
|
||||
$c->addSelectColumn(ProductPeer::ID);
|
||||
$c->addSelectColumn(DiscountHasProducerPeer::DISCOUNT_ID);
|
||||
$c->addJoin(DiscountHasProducerPeer::PRODUCER_ID, ProductPeer::PRODUCER_ID);
|
||||
$c->add(ProductPeer::ID, $productIds, Criteria::IN);
|
||||
|
||||
$rs = DiscountHasProducerPeer::doSelectRS($c);
|
||||
|
||||
while($rs->next())
|
||||
{
|
||||
list($product_id, $id) = $rs->getRow();
|
||||
self::$productBatchDiscountIds[$product_id][$id] = $id;
|
||||
}
|
||||
|
||||
$c = new Criteria();
|
||||
$c->addSelectColumn(DiscountHasProductPeer::PRODUCT_ID);
|
||||
$c->addSelectColumn(DiscountHasProductPeer::DISCOUNT_ID);
|
||||
$c->add(DiscountHasProductPeer::PRODUCT_ID, $productIds, Criteria::IN);
|
||||
$rs = DiscountHasProductPeer::doSelectRS($c);
|
||||
|
||||
while($rs->next())
|
||||
{
|
||||
list($product_id, $id) = $rs->getRow();
|
||||
self::$productBatchDiscountIds[$product_id][$id] = $id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function doSelectIdsByProduct(Product $product)
|
||||
{
|
||||
self::fetchAllProductBatchDiscountIds();
|
||||
$product_id = $product->getId();
|
||||
|
||||
if (!isset(self::$productBatchDiscountIds[$product_id]))
|
||||
{
|
||||
self::$productBatchDiscountIds[$product_id] = array();
|
||||
|
||||
self::updateProductBatchDiscountIds(array($product_id));
|
||||
}
|
||||
|
||||
return self::$productBatchDiscountIds[$product_id];
|
||||
}
|
||||
|
||||
public static function doSelectIdsByProductIds($product_ids)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->addSelectColumn(DiscountHasProductPeer::DISCOUNT_ID);
|
||||
$c->add(DiscountHasProductPeer::PRODUCT_ID, $product_ids, Criteria::IN);
|
||||
$c->addGroupByColumn(DiscountHasProductPeer::DISCOUNT_ID);
|
||||
$rs = DiscountHasProductPeer::doSelectRS($c);
|
||||
$ids = array();
|
||||
while($rs->next())
|
||||
{
|
||||
$ids[] = $rs->getInt(1);
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
public static function doSelectOneByProductAndUser(Product $product, sfGuardUser $user = null)
|
||||
{
|
||||
$discounts = self::doSelectActiveCached();
|
||||
|
||||
if (isset($discounts['P']))
|
||||
{
|
||||
$discount = current($discounts['P']);
|
||||
|
||||
if ($discount->getAllProducts() && $discount->isAvailableForUser($user))
|
||||
{
|
||||
return $discount;
|
||||
}
|
||||
|
||||
$user_discounts = self::doSelectForUserCached($user);
|
||||
|
||||
if ($user_discounts)
|
||||
{
|
||||
$pids = self::doSelectIdsByProduct($product);
|
||||
|
||||
foreach ($user_discounts as $discount)
|
||||
{
|
||||
if ($discount->getAllProducts() || isset($pids[$discount->getId()]))
|
||||
{
|
||||
return $discount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function doSelectForUserCached(sfGuardUser $user = null)
|
||||
{
|
||||
$discounts = self::doSelectActiveCached();
|
||||
|
||||
$id = null !== $user ? $user->getId() : 0;
|
||||
|
||||
if (!isset(self::$discountsForUser[$id]))
|
||||
{
|
||||
$results = array();
|
||||
|
||||
if (isset($discounts['P']))
|
||||
{
|
||||
foreach ($discounts['P'] as $discount)
|
||||
{
|
||||
if ($discount->isAvailableForUser($user))
|
||||
{
|
||||
$results[$discount->getId()] = $discount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self::$discountsForUser[$id] = $results;
|
||||
}
|
||||
|
||||
return self::$discountsForUser[$id];
|
||||
}
|
||||
|
||||
public static function doSelectActiveCached()
|
||||
{
|
||||
if (null === self::$activeDiscounts)
|
||||
{
|
||||
$fc = new stFunctionCache('stDiscount');
|
||||
|
||||
$c = new Criteria();
|
||||
$c->add(self::TYPE, array('O', 'P'), Criteria::IN);
|
||||
|
||||
self::setHydrateMethod(array('DiscountPeer', 'hydrateActiveCached'));
|
||||
|
||||
self::$activeDiscounts = $fc->cacheCall(array('DiscountPeer','doSelectActive'), array($c));
|
||||
|
||||
self::$activeDiscounts = stEventDispatcher::getInstance()->filter(new sfEvent(null, 'DiscountPeer.doSelectActiveCached'), self::$activeDiscounts)->getReturnValue();
|
||||
|
||||
self::setHydrateMethod(null);
|
||||
}
|
||||
|
||||
return self::$activeDiscounts;
|
||||
}
|
||||
|
||||
public static function doSelectActive(Criteria $c)
|
||||
{
|
||||
$c->add(self::ACTIVE, true);
|
||||
$c->addDescendingOrderByColumn(self::PRIORITY);
|
||||
|
||||
return self::doSelect($c);
|
||||
}
|
||||
|
||||
public static function doSelectProductsInSet(Product $product)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->addSelectColumn(DiscountHasProductPeer::DISCOUNT_ID);
|
||||
$c->add(DiscountHasProductPeer::PRODUCT_ID, $product->getId());
|
||||
$c->addJoin(DiscountPeer::ID, DiscountHasProductPeer::DISCOUNT_ID);
|
||||
$rs = DiscountHasProductPeer::doSelectRS($c);
|
||||
}
|
||||
|
||||
public static function doSelectSetDiscounts(Product $product, sfGuardUser $user = null)
|
||||
{
|
||||
$uid = $user ? self::doSelectIdsByUser($user) : array();
|
||||
|
||||
$discount = null;
|
||||
|
||||
$c = new Criteria();
|
||||
$c->add(self::TYPE, 'S');
|
||||
|
||||
$c->add(self::PRODUCT_ID, $product->getId());
|
||||
|
||||
if ($user)
|
||||
{
|
||||
if ($uid)
|
||||
{
|
||||
$uc = $c->getNewCriterion(self::ID, $uid, Criteria::IN);
|
||||
$uc->addOr($c->getNewCriterion(self::ALL_CLIENTS, true));
|
||||
$c->add($uc);
|
||||
}
|
||||
else
|
||||
{
|
||||
$c->add(self::ALL_CLIENTS, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$c->add(self::ALLOW_ANONYMOUS_CLIENTS, true);
|
||||
}
|
||||
|
||||
$discounts = [];
|
||||
|
||||
foreach (self::doSelectActive($c) as $discount)
|
||||
{
|
||||
if ($discount->isAvailableForUser($user))
|
||||
{
|
||||
$discount->setProduct($product);
|
||||
$discounts[] = $discount;
|
||||
}
|
||||
}
|
||||
|
||||
return $discounts;
|
||||
}
|
||||
|
||||
public static function hydrateActiveCached($rs)
|
||||
{
|
||||
$results = array();
|
||||
|
||||
while($rs->next())
|
||||
{
|
||||
$obj = new Discount();
|
||||
$obj->hydrate($rs);
|
||||
|
||||
$results[$obj->getType()][$obj->getId()] = $obj;
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public static function clearCache()
|
||||
{
|
||||
$cache = new stFunctionCache('stDiscount');
|
||||
$cache->removeAll();
|
||||
stFastCacheManager::clearCache();
|
||||
}
|
||||
}
|
||||
20
plugins/stDiscountPlugin/lib/model/DiscountRange.php
Normal file
20
plugins/stDiscountPlugin/lib/model/DiscountRange.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class DiscountRange extends BaseDiscountRange
|
||||
{
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isColumnModified(DiscountRangePeer::DISCOUNT_ID))
|
||||
{
|
||||
$this->getDiscount()->setAllowAnonymousClients(false);
|
||||
$this->getDiscount()->setAllClients(false);
|
||||
$this->getDiscount()->setAutoActive(false);
|
||||
}
|
||||
|
||||
return parent::save($con);
|
||||
}
|
||||
}
|
||||
24
plugins/stDiscountPlugin/lib/model/DiscountRangePeer.php
Normal file
24
plugins/stDiscountPlugin/lib/model/DiscountRangePeer.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
class DiscountRangePeer extends BaseDiscountRangePeer
|
||||
{
|
||||
public static function getDiscountsForSelect()
|
||||
{
|
||||
$items = array();
|
||||
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(DiscountPeer::TYPE, 'P');
|
||||
|
||||
foreach (DiscountPeer::doSelect($c) as $item)
|
||||
{
|
||||
$items[$item->getId()] = $item->getName();
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
40
plugins/stDiscountPlugin/lib/model/DiscountUser.php
Normal file
40
plugins/stDiscountPlugin/lib/model/DiscountUser.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_discount_user' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model
|
||||
*/
|
||||
class DiscountUser extends BaseDiscountUser
|
||||
{
|
||||
public function getValue()
|
||||
{
|
||||
return $this->discount;
|
||||
}
|
||||
|
||||
public function getPriceType()
|
||||
{
|
||||
return '%';
|
||||
}
|
||||
|
||||
public function apply($amount)
|
||||
{
|
||||
if ($this->getPriceType() == Discount::PERCENT_TYPE)
|
||||
{
|
||||
$amount = stPrice::applyDiscount($amount, $this->getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
$amount -= stCurrency::exchange($this->getValue());
|
||||
}
|
||||
|
||||
return $amount > 0 ? $amount : 0;
|
||||
}
|
||||
|
||||
public function getValueByUser()
|
||||
{
|
||||
return $this->getValue();
|
||||
}
|
||||
}
|
||||
26
plugins/stDiscountPlugin/lib/model/DiscountUserPeer.php
Normal file
26
plugins/stDiscountPlugin/lib/model/DiscountUserPeer.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'st_discount_user' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model
|
||||
*/
|
||||
class DiscountUserPeer extends BaseDiscountUserPeer
|
||||
{
|
||||
protected static $discounts = array();
|
||||
|
||||
public static function doSelectOneByUser($user)
|
||||
{
|
||||
if (!isset(self::$discounts[$user->getId()]))
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(DiscountUserPeer::SF_GUARD_USER_ID, $user->getId());
|
||||
$discount = self::doSelectOne($c);
|
||||
self::$discounts[$user->getId()] = $discount && $discount->getValue() > 0 ? $discount : false;
|
||||
}
|
||||
|
||||
return self::$discounts[$user->getId()] ? self::$discounts[$user->getId()] : null;
|
||||
}
|
||||
}
|
||||
19
plugins/stDiscountPlugin/lib/model/UserHasDiscount.php
Normal file
19
plugins/stDiscountPlugin/lib/model/UserHasDiscount.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stDiscountPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stDiscountPlugin 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 stDiscountPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: UserHasDiscount.php 10 2009-08-24 09:32:18Z michal $
|
||||
*/
|
||||
|
||||
class UserHasDiscount extends BaseUserHasDiscount
|
||||
{
|
||||
}
|
||||
19
plugins/stDiscountPlugin/lib/model/UserHasDiscountPeer.php
Normal file
19
plugins/stDiscountPlugin/lib/model/UserHasDiscountPeer.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stDiscountPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stDiscountPlugin 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 stDiscountPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: UserHasDiscountPeer.php 10 2009-08-24 09:32:18Z michal $
|
||||
*/
|
||||
|
||||
class UserHasDiscountPeer extends BaseUserHasDiscountPeer
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_discount_coupon_code_has_category' 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.stDiscountPlugin.lib.model.map
|
||||
*/
|
||||
class DiscountCouponCodeHasCategoryMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stDiscountPlugin.lib.model.map.DiscountCouponCodeHasCategoryMapBuilder';
|
||||
|
||||
/**
|
||||
* 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_discount_coupon_code_has_category');
|
||||
$tMap->setPhpName('DiscountCouponCodeHasCategory');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('DISCOUNT_COUPON_CODE_ID', 'DiscountCouponCodeId', 'int' , CreoleTypes::INTEGER, 'st_discount_coupon_code', 'ID', true, null);
|
||||
|
||||
$tMap->addForeignPrimaryKey('CATEGORY_ID', 'CategoryId', 'int' , CreoleTypes::INTEGER, 'st_category', 'ID', true, null);
|
||||
|
||||
$tMap->addColumn('IS_OPT', 'IsOpt', 'boolean', CreoleTypes::BOOLEAN, true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // DiscountCouponCodeHasCategoryMapBuilder
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_discount_coupon_code_has_producer' 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.stDiscountPlugin.lib.model.map
|
||||
*/
|
||||
class DiscountCouponCodeHasProducerMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stDiscountPlugin.lib.model.map.DiscountCouponCodeHasProducerMapBuilder';
|
||||
|
||||
/**
|
||||
* 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_discount_coupon_code_has_producer');
|
||||
$tMap->setPhpName('DiscountCouponCodeHasProducer');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('DISCOUNT_COUPON_CODE_ID', 'DiscountCouponCodeId', 'int' , CreoleTypes::INTEGER, 'st_discount_coupon_code', 'ID', true, null);
|
||||
|
||||
$tMap->addForeignPrimaryKey('PRODUCER_ID', 'ProducerId', 'int' , CreoleTypes::INTEGER, 'st_producer', 'ID', true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // DiscountCouponCodeHasProducerMapBuilder
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_discount_coupon_code_has_product' 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.stDiscountPlugin.lib.model.map
|
||||
*/
|
||||
class DiscountCouponCodeHasProductMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stDiscountPlugin.lib.model.map.DiscountCouponCodeHasProductMapBuilder';
|
||||
|
||||
/**
|
||||
* 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_discount_coupon_code_has_product');
|
||||
$tMap->setPhpName('DiscountCouponCodeHasProduct');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('DISCOUNT_COUPON_CODE_ID', 'DiscountCouponCodeId', 'int' , CreoleTypes::INTEGER, 'st_discount_coupon_code', 'ID', true, null);
|
||||
|
||||
$tMap->addForeignPrimaryKey('PRODUCT_ID', 'ProductId', 'int' , CreoleTypes::INTEGER, 'st_product', 'ID', true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // DiscountCouponCodeHasProductMapBuilder
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_discount_coupon_code' 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.stDiscountPlugin.lib.model.map
|
||||
*/
|
||||
class DiscountCouponCodeMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stDiscountPlugin.lib.model.map.DiscountCouponCodeMapBuilder';
|
||||
|
||||
/**
|
||||
* 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_discount_coupon_code');
|
||||
$tMap->setPhpName('DiscountCouponCode');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addForeignKey('SF_GUARD_USER_ID', 'SfGuardUserId', 'int', CreoleTypes::INTEGER, 'sf_guard_user', 'ID', false, null);
|
||||
|
||||
$tMap->addForeignKey('ORDER_ID', 'OrderId', 'int', CreoleTypes::INTEGER, 'st_order', 'ID', false, null);
|
||||
|
||||
$tMap->addColumn('CODE', 'Code', 'string', CreoleTypes::VARCHAR, true, 16);
|
||||
|
||||
$tMap->addColumn('USED', 'Used', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addColumn('VALID_USAGE', 'ValidUsage', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addColumn('ALLOW_ALL_PRODUCTS', 'AllowAllProducts', 'boolean', CreoleTypes::BOOLEAN, false, null);
|
||||
|
||||
$tMap->addColumn('VALID_FROM', 'ValidFrom', 'int', CreoleTypes::TIMESTAMP, false, null);
|
||||
|
||||
$tMap->addColumn('VALID_TO', 'ValidTo', 'int', CreoleTypes::TIMESTAMP, false, null);
|
||||
|
||||
$tMap->addColumn('DISCOUNT', 'Discount', 'double', CreoleTypes::DECIMAL, true, 3);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // DiscountCouponCodeMapBuilder
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_discount_has_category' 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.stDiscountPlugin.lib.model.map
|
||||
*/
|
||||
class DiscountHasCategoryMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stDiscountPlugin.lib.model.map.DiscountHasCategoryMapBuilder';
|
||||
|
||||
/**
|
||||
* 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_discount_has_category');
|
||||
$tMap->setPhpName('DiscountHasCategory');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('DISCOUNT_ID', 'DiscountId', 'int' , CreoleTypes::INTEGER, 'st_discount', 'ID', true, null);
|
||||
|
||||
$tMap->addForeignPrimaryKey('CATEGORY_ID', 'CategoryId', 'int' , CreoleTypes::INTEGER, 'st_category', 'ID', true, null);
|
||||
|
||||
$tMap->addColumn('IS_OPT', 'IsOpt', 'boolean', CreoleTypes::BOOLEAN, true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // DiscountHasCategoryMapBuilder
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_discount_has_producer' 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.stDiscountPlugin.lib.model.map
|
||||
*/
|
||||
class DiscountHasProducerMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stDiscountPlugin.lib.model.map.DiscountHasProducerMapBuilder';
|
||||
|
||||
/**
|
||||
* 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_discount_has_producer');
|
||||
$tMap->setPhpName('DiscountHasProducer');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('DISCOUNT_ID', 'DiscountId', 'int' , CreoleTypes::INTEGER, 'st_discount', 'ID', true, null);
|
||||
|
||||
$tMap->addForeignPrimaryKey('PRODUCER_ID', 'ProducerId', 'int' , CreoleTypes::INTEGER, 'st_producer', 'ID', true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // DiscountHasProducerMapBuilder
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_discount_has_product' 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.stDiscountPlugin.lib.model.map
|
||||
*/
|
||||
class DiscountHasProductMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stDiscountPlugin.lib.model.map.DiscountHasProductMapBuilder';
|
||||
|
||||
/**
|
||||
* 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_discount_has_product');
|
||||
$tMap->setPhpName('DiscountHasProduct');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('DISCOUNT_ID', 'DiscountId', 'int' , CreoleTypes::INTEGER, 'st_discount', 'ID', true, null);
|
||||
|
||||
$tMap->addForeignPrimaryKey('PRODUCT_ID', 'ProductId', 'int' , CreoleTypes::INTEGER, 'st_product', 'ID', true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // DiscountHasProductMapBuilder
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_discount' 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.stDiscountPlugin.lib.model.map
|
||||
*/
|
||||
class DiscountMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stDiscountPlugin.lib.model.map.DiscountMapBuilder';
|
||||
|
||||
/**
|
||||
* 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_discount');
|
||||
$tMap->setPhpName('Discount');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addColumn('TYPE', 'Type', 'string', CreoleTypes::VARCHAR, true, 1);
|
||||
|
||||
$tMap->addColumn('PRICE_TYPE', 'PriceType', 'string', CreoleTypes::VARCHAR, true, 1);
|
||||
|
||||
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, true, 64);
|
||||
|
||||
$tMap->addColumn('VALUE', 'Value', 'double', CreoleTypes::DECIMAL, false, 8);
|
||||
|
||||
$tMap->addColumn('WHOLESALE_VALUE', 'WholesaleValue', 'double', CreoleTypes::DECIMAL, false, 8);
|
||||
|
||||
$tMap->addColumn('CONDITIONS', 'Conditions', 'array', CreoleTypes::VARCHAR, false, 4096);
|
||||
|
||||
$tMap->addColumn('PRIORITY', 'Priority', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addColumn('ACTIVE', 'Active', 'boolean', CreoleTypes::BOOLEAN, true, null);
|
||||
|
||||
$tMap->addColumn('ALL_PRODUCTS', 'AllProducts', 'boolean', CreoleTypes::BOOLEAN, true, null);
|
||||
|
||||
$tMap->addColumn('ALL_CLIENTS', 'AllClients', 'boolean', CreoleTypes::BOOLEAN, true, null);
|
||||
|
||||
$tMap->addColumn('ALLOW_ANONYMOUS_CLIENTS', 'AllowAnonymousClients', 'boolean', CreoleTypes::BOOLEAN, true, null);
|
||||
|
||||
$tMap->addColumn('AUTO_ACTIVE', 'AutoActive', 'boolean', CreoleTypes::BOOLEAN, true, null);
|
||||
|
||||
$tMap->addForeignKey('PRODUCT_ID', 'ProductId', 'int', CreoleTypes::INTEGER, 'st_product', 'ID', false, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // DiscountMapBuilder
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_discount_range' 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.stDiscountPlugin.lib.model.map
|
||||
*/
|
||||
class DiscountRangeMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stDiscountPlugin.lib.model.map.DiscountRangeMapBuilder';
|
||||
|
||||
/**
|
||||
* 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_discount_range');
|
||||
$tMap->setPhpName('DiscountRange');
|
||||
|
||||
$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('DISCOUNT_ID', 'DiscountId', 'int', CreoleTypes::INTEGER, 'st_discount', 'ID', true, null);
|
||||
|
||||
$tMap->addColumn('TOTAL_VALUE', 'TotalValue', 'double', CreoleTypes::DOUBLE, true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // DiscountRangeMapBuilder
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_discount_user' 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.stDiscountPlugin.lib.model.map
|
||||
*/
|
||||
class DiscountUserMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stDiscountPlugin.lib.model.map.DiscountUserMapBuilder';
|
||||
|
||||
/**
|
||||
* 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_discount_user');
|
||||
$tMap->setPhpName('DiscountUser');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addForeignKey('SF_GUARD_USER_ID', 'SfGuardUserId', 'int', CreoleTypes::INTEGER, 'sf_guard_user', 'ID', true, null);
|
||||
|
||||
$tMap->addColumn('DISCOUNT', 'Discount', 'double', CreoleTypes::DOUBLE, false, null);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // DiscountUserMapBuilder
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_user_has_discount' 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.stDiscountPlugin.lib.model.map
|
||||
*/
|
||||
class UserHasDiscountMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stDiscountPlugin.lib.model.map.UserHasDiscountMapBuilder';
|
||||
|
||||
/**
|
||||
* 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_user_has_discount');
|
||||
$tMap->setPhpName('UserHasDiscount');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addForeignPrimaryKey('SF_GUARD_USER_ID', 'SfGuardUserId', 'int' , CreoleTypes::INTEGER, 'sf_guard_user', 'ID', true, null);
|
||||
|
||||
$tMap->addForeignPrimaryKey('DISCOUNT_ID', 'DiscountId', 'int' , CreoleTypes::INTEGER, 'st_discount', 'ID', true, null);
|
||||
|
||||
$tMap->addColumn('AUTO', 'Auto', 'boolean', CreoleTypes::BOOLEAN, true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // UserHasDiscountMapBuilder
|
||||
2873
plugins/stDiscountPlugin/lib/model/om/BaseDiscount.php
Normal file
2873
plugins/stDiscountPlugin/lib/model/om/BaseDiscount.php
Normal file
File diff suppressed because it is too large
Load Diff
2649
plugins/stDiscountPlugin/lib/model/om/BaseDiscountCouponCode.php
Normal file
2649
plugins/stDiscountPlugin/lib/model/om/BaseDiscountCouponCode.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,846 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_discount_coupon_code_has_category' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseDiscountCouponCodeHasCategory extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the discount_coupon_code_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $discount_coupon_code_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the category_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $category_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the is_opt field.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $is_opt = false;
|
||||
|
||||
/**
|
||||
* @var DiscountCouponCode
|
||||
*/
|
||||
protected $aDiscountCouponCode;
|
||||
|
||||
/**
|
||||
* @var Category
|
||||
*/
|
||||
protected $aCategory;
|
||||
|
||||
/**
|
||||
* 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 [discount_coupon_code_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDiscountCouponCodeId()
|
||||
{
|
||||
|
||||
return $this->discount_coupon_code_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [category_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCategoryId()
|
||||
{
|
||||
|
||||
return $this->category_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [is_opt] column value.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIsOpt()
|
||||
{
|
||||
|
||||
return $this->is_opt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [discount_coupon_code_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDiscountCouponCodeId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->discount_coupon_code_id !== $v) {
|
||||
$this->discount_coupon_code_id = $v;
|
||||
$this->modifiedColumns[] = DiscountCouponCodeHasCategoryPeer::DISCOUNT_COUPON_CODE_ID;
|
||||
}
|
||||
|
||||
if ($this->aDiscountCouponCode !== null && $this->aDiscountCouponCode->getId() !== $v) {
|
||||
$this->aDiscountCouponCode = null;
|
||||
}
|
||||
|
||||
} // setDiscountCouponCodeId()
|
||||
|
||||
/**
|
||||
* Set the value of [category_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setCategoryId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->category_id !== $v) {
|
||||
$this->category_id = $v;
|
||||
$this->modifiedColumns[] = DiscountCouponCodeHasCategoryPeer::CATEGORY_ID;
|
||||
}
|
||||
|
||||
if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
|
||||
$this->aCategory = null;
|
||||
}
|
||||
|
||||
} // setCategoryId()
|
||||
|
||||
/**
|
||||
* Set the value of [is_opt] column.
|
||||
*
|
||||
* @param boolean $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setIsOpt($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_bool($v)) {
|
||||
$v = (bool) $v;
|
||||
}
|
||||
|
||||
if ($this->is_opt !== $v || $v === false) {
|
||||
$this->is_opt = $v;
|
||||
$this->modifiedColumns[] = DiscountCouponCodeHasCategoryPeer::IS_OPT;
|
||||
}
|
||||
|
||||
} // setIsOpt()
|
||||
|
||||
/**
|
||||
* 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('DiscountCouponCodeHasCategory.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasCategory.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->discount_coupon_code_id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->category_id = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->is_opt = $rs->getBoolean($startcol + 2);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('DiscountCouponCodeHasCategory.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasCategory.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 3)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 3; // 3 = DiscountCouponCodeHasCategoryPeer::NUM_COLUMNS - DiscountCouponCodeHasCategoryPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating DiscountCouponCodeHasCategory 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('DiscountCouponCodeHasCategory.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasCategory.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountCouponCodeHasCategory:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountCouponCodeHasCategory:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountCouponCodeHasCategoryPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
DiscountCouponCodeHasCategoryPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('DiscountCouponCodeHasCategory.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasCategory.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountCouponCodeHasCategory:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountCouponCodeHasCategory: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('DiscountCouponCodeHasCategory.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasCategory.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountCouponCodeHasCategory:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountCouponCodeHasCategoryPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('DiscountCouponCodeHasCategory.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasCategory.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountCouponCodeHasCategory: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->aDiscountCouponCode !== null) {
|
||||
if ($this->aDiscountCouponCode->isModified()) {
|
||||
$affectedRows += $this->aDiscountCouponCode->save($con);
|
||||
}
|
||||
$this->setDiscountCouponCode($this->aDiscountCouponCode);
|
||||
}
|
||||
|
||||
if ($this->aCategory !== null) {
|
||||
if ($this->aCategory->isModified() || $this->aCategory->getCurrentCategoryI18n()->isModified()) {
|
||||
$affectedRows += $this->aCategory->save($con);
|
||||
}
|
||||
$this->setCategory($this->aCategory);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = DiscountCouponCodeHasCategoryPeer::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 += DiscountCouponCodeHasCategoryPeer::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->aDiscountCouponCode !== null) {
|
||||
if (!$this->aDiscountCouponCode->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aDiscountCouponCode->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->aCategory !== null) {
|
||||
if (!$this->aCategory->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = DiscountCouponCodeHasCategoryPeer::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 = DiscountCouponCodeHasCategoryPeer::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->getDiscountCouponCodeId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getCategoryId();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getIsOpt();
|
||||
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 = DiscountCouponCodeHasCategoryPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getDiscountCouponCodeId(),
|
||||
$keys[1] => $this->getCategoryId(),
|
||||
$keys[2] => $this->getIsOpt(),
|
||||
);
|
||||
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 = DiscountCouponCodeHasCategoryPeer::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->setDiscountCouponCodeId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setCategoryId($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setIsOpt($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 = DiscountCouponCodeHasCategoryPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setDiscountCouponCodeId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setIsOpt($arr[$keys[2]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(DiscountCouponCodeHasCategoryPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(DiscountCouponCodeHasCategoryPeer::DISCOUNT_COUPON_CODE_ID)) $criteria->add(DiscountCouponCodeHasCategoryPeer::DISCOUNT_COUPON_CODE_ID, $this->discount_coupon_code_id);
|
||||
if ($this->isColumnModified(DiscountCouponCodeHasCategoryPeer::CATEGORY_ID)) $criteria->add(DiscountCouponCodeHasCategoryPeer::CATEGORY_ID, $this->category_id);
|
||||
if ($this->isColumnModified(DiscountCouponCodeHasCategoryPeer::IS_OPT)) $criteria->add(DiscountCouponCodeHasCategoryPeer::IS_OPT, $this->is_opt);
|
||||
|
||||
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(DiscountCouponCodeHasCategoryPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(DiscountCouponCodeHasCategoryPeer::DISCOUNT_COUPON_CODE_ID, $this->discount_coupon_code_id);
|
||||
$criteria->add(DiscountCouponCodeHasCategoryPeer::CATEGORY_ID, $this->category_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->getDiscountCouponCodeId(), $this->getCategoryId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(DiscountCouponCodeHasCategoryPeer::translateFieldName('discount_coupon_code_id', BasePeer::TYPE_FIELDNAME, $keyType), DiscountCouponCodeHasCategoryPeer::translateFieldName('category_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->setDiscountCouponCodeId($keys[0]);
|
||||
|
||||
$this->setCategoryId($keys[1]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of DiscountCouponCodeHasCategory (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->setIsOpt($this->is_opt);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setDiscountCouponCodeId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
$copyObj->setCategoryId(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 DiscountCouponCodeHasCategory 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 'DiscountCouponCodeHasCategoryPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a DiscountCouponCode object.
|
||||
*
|
||||
* @param DiscountCouponCode $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setDiscountCouponCode($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setDiscountCouponCodeId(NULL);
|
||||
} else {
|
||||
$this->setDiscountCouponCodeId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aDiscountCouponCode = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated DiscountCouponCode object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return DiscountCouponCode The associated DiscountCouponCode object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getDiscountCouponCode($con = null)
|
||||
{
|
||||
if ($this->aDiscountCouponCode === null && ($this->discount_coupon_code_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aDiscountCouponCode = DiscountCouponCodePeer::retrieveByPK($this->discount_coupon_code_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 = DiscountCouponCodePeer::retrieveByPK($this->discount_coupon_code_id, $con);
|
||||
$obj->addDiscountCouponCodes($this);
|
||||
*/
|
||||
}
|
||||
return $this->aDiscountCouponCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Category object.
|
||||
*
|
||||
* @param Category $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setCategory($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setCategoryId(NULL);
|
||||
} else {
|
||||
$this->setCategoryId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aCategory = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Category object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Category The associated Category object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getCategory($con = null)
|
||||
{
|
||||
if ($this->aCategory === null && ($this->category_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aCategory = CategoryPeer::retrieveByPK($this->category_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 = CategoryPeer::retrieveByPK($this->category_id, $con);
|
||||
$obj->addCategorys($this);
|
||||
*/
|
||||
}
|
||||
return $this->aCategory;
|
||||
}
|
||||
|
||||
|
||||
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, 'DiscountCouponCodeHasCategory.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseDiscountCouponCodeHasCategory:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseDiscountCouponCodeHasCategory::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseDiscountCouponCodeHasCategory
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,795 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_discount_coupon_code_has_producer' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseDiscountCouponCodeHasProducer extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the discount_coupon_code_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $discount_coupon_code_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the producer_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $producer_id;
|
||||
|
||||
/**
|
||||
* @var DiscountCouponCode
|
||||
*/
|
||||
protected $aDiscountCouponCode;
|
||||
|
||||
/**
|
||||
* @var Producer
|
||||
*/
|
||||
protected $aProducer;
|
||||
|
||||
/**
|
||||
* 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 [discount_coupon_code_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDiscountCouponCodeId()
|
||||
{
|
||||
|
||||
return $this->discount_coupon_code_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [producer_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getProducerId()
|
||||
{
|
||||
|
||||
return $this->producer_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [discount_coupon_code_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDiscountCouponCodeId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->discount_coupon_code_id !== $v) {
|
||||
$this->discount_coupon_code_id = $v;
|
||||
$this->modifiedColumns[] = DiscountCouponCodeHasProducerPeer::DISCOUNT_COUPON_CODE_ID;
|
||||
}
|
||||
|
||||
if ($this->aDiscountCouponCode !== null && $this->aDiscountCouponCode->getId() !== $v) {
|
||||
$this->aDiscountCouponCode = null;
|
||||
}
|
||||
|
||||
} // setDiscountCouponCodeId()
|
||||
|
||||
/**
|
||||
* Set the value of [producer_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setProducerId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->producer_id !== $v) {
|
||||
$this->producer_id = $v;
|
||||
$this->modifiedColumns[] = DiscountCouponCodeHasProducerPeer::PRODUCER_ID;
|
||||
}
|
||||
|
||||
if ($this->aProducer !== null && $this->aProducer->getId() !== $v) {
|
||||
$this->aProducer = null;
|
||||
}
|
||||
|
||||
} // setProducerId()
|
||||
|
||||
/**
|
||||
* 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('DiscountCouponCodeHasProducer.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasProducer.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->discount_coupon_code_id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->producer_id = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('DiscountCouponCodeHasProducer.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasProducer.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 2)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 2; // 2 = DiscountCouponCodeHasProducerPeer::NUM_COLUMNS - DiscountCouponCodeHasProducerPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating DiscountCouponCodeHasProducer 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('DiscountCouponCodeHasProducer.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasProducer.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountCouponCodeHasProducer:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountCouponCodeHasProducer:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountCouponCodeHasProducerPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
DiscountCouponCodeHasProducerPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('DiscountCouponCodeHasProducer.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasProducer.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountCouponCodeHasProducer:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountCouponCodeHasProducer: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('DiscountCouponCodeHasProducer.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasProducer.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountCouponCodeHasProducer:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountCouponCodeHasProducerPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('DiscountCouponCodeHasProducer.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasProducer.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountCouponCodeHasProducer: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->aDiscountCouponCode !== null) {
|
||||
if ($this->aDiscountCouponCode->isModified()) {
|
||||
$affectedRows += $this->aDiscountCouponCode->save($con);
|
||||
}
|
||||
$this->setDiscountCouponCode($this->aDiscountCouponCode);
|
||||
}
|
||||
|
||||
if ($this->aProducer !== null) {
|
||||
if ($this->aProducer->isModified() || $this->aProducer->getCurrentProducerI18n()->isModified()) {
|
||||
$affectedRows += $this->aProducer->save($con);
|
||||
}
|
||||
$this->setProducer($this->aProducer);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = DiscountCouponCodeHasProducerPeer::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 += DiscountCouponCodeHasProducerPeer::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->aDiscountCouponCode !== null) {
|
||||
if (!$this->aDiscountCouponCode->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aDiscountCouponCode->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->aProducer !== null) {
|
||||
if (!$this->aProducer->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aProducer->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = DiscountCouponCodeHasProducerPeer::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 = DiscountCouponCodeHasProducerPeer::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->getDiscountCouponCodeId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getProducerId();
|
||||
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 = DiscountCouponCodeHasProducerPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getDiscountCouponCodeId(),
|
||||
$keys[1] => $this->getProducerId(),
|
||||
);
|
||||
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 = DiscountCouponCodeHasProducerPeer::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->setDiscountCouponCodeId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setProducerId($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 = DiscountCouponCodeHasProducerPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setDiscountCouponCodeId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setProducerId($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(DiscountCouponCodeHasProducerPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(DiscountCouponCodeHasProducerPeer::DISCOUNT_COUPON_CODE_ID)) $criteria->add(DiscountCouponCodeHasProducerPeer::DISCOUNT_COUPON_CODE_ID, $this->discount_coupon_code_id);
|
||||
if ($this->isColumnModified(DiscountCouponCodeHasProducerPeer::PRODUCER_ID)) $criteria->add(DiscountCouponCodeHasProducerPeer::PRODUCER_ID, $this->producer_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(DiscountCouponCodeHasProducerPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(DiscountCouponCodeHasProducerPeer::DISCOUNT_COUPON_CODE_ID, $this->discount_coupon_code_id);
|
||||
$criteria->add(DiscountCouponCodeHasProducerPeer::PRODUCER_ID, $this->producer_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->getDiscountCouponCodeId(), $this->getProducerId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(DiscountCouponCodeHasProducerPeer::translateFieldName('discount_coupon_code_id', BasePeer::TYPE_FIELDNAME, $keyType), DiscountCouponCodeHasProducerPeer::translateFieldName('producer_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->setDiscountCouponCodeId($keys[0]);
|
||||
|
||||
$this->setProducerId($keys[1]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of DiscountCouponCodeHasProducer (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->setNew(true);
|
||||
|
||||
$copyObj->setDiscountCouponCodeId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
$copyObj->setProducerId(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 DiscountCouponCodeHasProducer 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 'DiscountCouponCodeHasProducerPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a DiscountCouponCode object.
|
||||
*
|
||||
* @param DiscountCouponCode $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setDiscountCouponCode($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setDiscountCouponCodeId(NULL);
|
||||
} else {
|
||||
$this->setDiscountCouponCodeId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aDiscountCouponCode = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated DiscountCouponCode object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return DiscountCouponCode The associated DiscountCouponCode object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getDiscountCouponCode($con = null)
|
||||
{
|
||||
if ($this->aDiscountCouponCode === null && ($this->discount_coupon_code_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aDiscountCouponCode = DiscountCouponCodePeer::retrieveByPK($this->discount_coupon_code_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 = DiscountCouponCodePeer::retrieveByPK($this->discount_coupon_code_id, $con);
|
||||
$obj->addDiscountCouponCodes($this);
|
||||
*/
|
||||
}
|
||||
return $this->aDiscountCouponCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Producer object.
|
||||
*
|
||||
* @param Producer $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setProducer($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setProducerId(NULL);
|
||||
} else {
|
||||
$this->setProducerId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aProducer = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Producer object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Producer The associated Producer object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getProducer($con = null)
|
||||
{
|
||||
if ($this->aProducer === null && ($this->producer_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aProducer = ProducerPeer::retrieveByPK($this->producer_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 = ProducerPeer::retrieveByPK($this->producer_id, $con);
|
||||
$obj->addProducers($this);
|
||||
*/
|
||||
}
|
||||
return $this->aProducer;
|
||||
}
|
||||
|
||||
|
||||
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, 'DiscountCouponCodeHasProducer.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseDiscountCouponCodeHasProducer:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseDiscountCouponCodeHasProducer::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseDiscountCouponCodeHasProducer
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,795 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_discount_coupon_code_has_product' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseDiscountCouponCodeHasProduct extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the discount_coupon_code_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $discount_coupon_code_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the product_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $product_id;
|
||||
|
||||
/**
|
||||
* @var DiscountCouponCode
|
||||
*/
|
||||
protected $aDiscountCouponCode;
|
||||
|
||||
/**
|
||||
* @var Product
|
||||
*/
|
||||
protected $aProduct;
|
||||
|
||||
/**
|
||||
* 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 [discount_coupon_code_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDiscountCouponCodeId()
|
||||
{
|
||||
|
||||
return $this->discount_coupon_code_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [product_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getProductId()
|
||||
{
|
||||
|
||||
return $this->product_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [discount_coupon_code_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDiscountCouponCodeId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->discount_coupon_code_id !== $v) {
|
||||
$this->discount_coupon_code_id = $v;
|
||||
$this->modifiedColumns[] = DiscountCouponCodeHasProductPeer::DISCOUNT_COUPON_CODE_ID;
|
||||
}
|
||||
|
||||
if ($this->aDiscountCouponCode !== null && $this->aDiscountCouponCode->getId() !== $v) {
|
||||
$this->aDiscountCouponCode = null;
|
||||
}
|
||||
|
||||
} // setDiscountCouponCodeId()
|
||||
|
||||
/**
|
||||
* Set the value of [product_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setProductId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->product_id !== $v) {
|
||||
$this->product_id = $v;
|
||||
$this->modifiedColumns[] = DiscountCouponCodeHasProductPeer::PRODUCT_ID;
|
||||
}
|
||||
|
||||
if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
|
||||
$this->aProduct = null;
|
||||
}
|
||||
|
||||
} // setProductId()
|
||||
|
||||
/**
|
||||
* 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('DiscountCouponCodeHasProduct.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasProduct.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->discount_coupon_code_id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->product_id = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('DiscountCouponCodeHasProduct.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasProduct.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 2)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 2; // 2 = DiscountCouponCodeHasProductPeer::NUM_COLUMNS - DiscountCouponCodeHasProductPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating DiscountCouponCodeHasProduct 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('DiscountCouponCodeHasProduct.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasProduct.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountCouponCodeHasProduct:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountCouponCodeHasProduct:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountCouponCodeHasProductPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
DiscountCouponCodeHasProductPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('DiscountCouponCodeHasProduct.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasProduct.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountCouponCodeHasProduct:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountCouponCodeHasProduct: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('DiscountCouponCodeHasProduct.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasProduct.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountCouponCodeHasProduct:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountCouponCodeHasProductPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('DiscountCouponCodeHasProduct.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountCouponCodeHasProduct.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountCouponCodeHasProduct: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->aDiscountCouponCode !== null) {
|
||||
if ($this->aDiscountCouponCode->isModified()) {
|
||||
$affectedRows += $this->aDiscountCouponCode->save($con);
|
||||
}
|
||||
$this->setDiscountCouponCode($this->aDiscountCouponCode);
|
||||
}
|
||||
|
||||
if ($this->aProduct !== null) {
|
||||
if ($this->aProduct->isModified() || $this->aProduct->getCurrentProductI18n()->isModified()) {
|
||||
$affectedRows += $this->aProduct->save($con);
|
||||
}
|
||||
$this->setProduct($this->aProduct);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = DiscountCouponCodeHasProductPeer::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 += DiscountCouponCodeHasProductPeer::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->aDiscountCouponCode !== null) {
|
||||
if (!$this->aDiscountCouponCode->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aDiscountCouponCode->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->aProduct !== null) {
|
||||
if (!$this->aProduct->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = DiscountCouponCodeHasProductPeer::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 = DiscountCouponCodeHasProductPeer::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->getDiscountCouponCodeId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getProductId();
|
||||
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 = DiscountCouponCodeHasProductPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getDiscountCouponCodeId(),
|
||||
$keys[1] => $this->getProductId(),
|
||||
);
|
||||
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 = DiscountCouponCodeHasProductPeer::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->setDiscountCouponCodeId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setProductId($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 = DiscountCouponCodeHasProductPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setDiscountCouponCodeId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setProductId($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(DiscountCouponCodeHasProductPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(DiscountCouponCodeHasProductPeer::DISCOUNT_COUPON_CODE_ID)) $criteria->add(DiscountCouponCodeHasProductPeer::DISCOUNT_COUPON_CODE_ID, $this->discount_coupon_code_id);
|
||||
if ($this->isColumnModified(DiscountCouponCodeHasProductPeer::PRODUCT_ID)) $criteria->add(DiscountCouponCodeHasProductPeer::PRODUCT_ID, $this->product_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(DiscountCouponCodeHasProductPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(DiscountCouponCodeHasProductPeer::DISCOUNT_COUPON_CODE_ID, $this->discount_coupon_code_id);
|
||||
$criteria->add(DiscountCouponCodeHasProductPeer::PRODUCT_ID, $this->product_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->getDiscountCouponCodeId(), $this->getProductId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(DiscountCouponCodeHasProductPeer::translateFieldName('discount_coupon_code_id', BasePeer::TYPE_FIELDNAME, $keyType), DiscountCouponCodeHasProductPeer::translateFieldName('product_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->setDiscountCouponCodeId($keys[0]);
|
||||
|
||||
$this->setProductId($keys[1]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of DiscountCouponCodeHasProduct (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->setNew(true);
|
||||
|
||||
$copyObj->setDiscountCouponCodeId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
$copyObj->setProductId(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 DiscountCouponCodeHasProduct 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 'DiscountCouponCodeHasProductPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a DiscountCouponCode object.
|
||||
*
|
||||
* @param DiscountCouponCode $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setDiscountCouponCode($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setDiscountCouponCodeId(NULL);
|
||||
} else {
|
||||
$this->setDiscountCouponCodeId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aDiscountCouponCode = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated DiscountCouponCode object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return DiscountCouponCode The associated DiscountCouponCode object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getDiscountCouponCode($con = null)
|
||||
{
|
||||
if ($this->aDiscountCouponCode === null && ($this->discount_coupon_code_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aDiscountCouponCode = DiscountCouponCodePeer::retrieveByPK($this->discount_coupon_code_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 = DiscountCouponCodePeer::retrieveByPK($this->discount_coupon_code_id, $con);
|
||||
$obj->addDiscountCouponCodes($this);
|
||||
*/
|
||||
}
|
||||
return $this->aDiscountCouponCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Product object.
|
||||
*
|
||||
* @param Product $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setProduct($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setProductId(NULL);
|
||||
} else {
|
||||
$this->setProductId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aProduct = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Product object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Product The associated Product object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getProduct($con = null)
|
||||
{
|
||||
if ($this->aProduct === null && ($this->product_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aProduct = ProductPeer::retrieveByPK($this->product_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 = ProductPeer::retrieveByPK($this->product_id, $con);
|
||||
$obj->addProducts($this);
|
||||
*/
|
||||
}
|
||||
return $this->aProduct;
|
||||
}
|
||||
|
||||
|
||||
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, 'DiscountCouponCodeHasProduct.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseDiscountCouponCodeHasProduct:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseDiscountCouponCodeHasProduct::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseDiscountCouponCodeHasProduct
|
||||
File diff suppressed because it is too large
Load Diff
1299
plugins/stDiscountPlugin/lib/model/om/BaseDiscountCouponCodePeer.php
Normal file
1299
plugins/stDiscountPlugin/lib/model/om/BaseDiscountCouponCodePeer.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,846 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_discount_has_category' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseDiscountHasCategory extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the discount_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $discount_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the category_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $category_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the is_opt field.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $is_opt = false;
|
||||
|
||||
/**
|
||||
* @var Discount
|
||||
*/
|
||||
protected $aDiscount;
|
||||
|
||||
/**
|
||||
* @var Category
|
||||
*/
|
||||
protected $aCategory;
|
||||
|
||||
/**
|
||||
* 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 [discount_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDiscountId()
|
||||
{
|
||||
|
||||
return $this->discount_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [category_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCategoryId()
|
||||
{
|
||||
|
||||
return $this->category_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [is_opt] column value.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIsOpt()
|
||||
{
|
||||
|
||||
return $this->is_opt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [discount_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDiscountId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->discount_id !== $v) {
|
||||
$this->discount_id = $v;
|
||||
$this->modifiedColumns[] = DiscountHasCategoryPeer::DISCOUNT_ID;
|
||||
}
|
||||
|
||||
if ($this->aDiscount !== null && $this->aDiscount->getId() !== $v) {
|
||||
$this->aDiscount = null;
|
||||
}
|
||||
|
||||
} // setDiscountId()
|
||||
|
||||
/**
|
||||
* Set the value of [category_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setCategoryId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->category_id !== $v) {
|
||||
$this->category_id = $v;
|
||||
$this->modifiedColumns[] = DiscountHasCategoryPeer::CATEGORY_ID;
|
||||
}
|
||||
|
||||
if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
|
||||
$this->aCategory = null;
|
||||
}
|
||||
|
||||
} // setCategoryId()
|
||||
|
||||
/**
|
||||
* Set the value of [is_opt] column.
|
||||
*
|
||||
* @param boolean $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setIsOpt($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_bool($v)) {
|
||||
$v = (bool) $v;
|
||||
}
|
||||
|
||||
if ($this->is_opt !== $v || $v === false) {
|
||||
$this->is_opt = $v;
|
||||
$this->modifiedColumns[] = DiscountHasCategoryPeer::IS_OPT;
|
||||
}
|
||||
|
||||
} // setIsOpt()
|
||||
|
||||
/**
|
||||
* 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('DiscountHasCategory.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasCategory.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->discount_id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->category_id = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->is_opt = $rs->getBoolean($startcol + 2);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('DiscountHasCategory.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasCategory.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 3)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 3; // 3 = DiscountHasCategoryPeer::NUM_COLUMNS - DiscountHasCategoryPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating DiscountHasCategory 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('DiscountHasCategory.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasCategory.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountHasCategory:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountHasCategory:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountHasCategoryPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
DiscountHasCategoryPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('DiscountHasCategory.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasCategory.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountHasCategory:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountHasCategory: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('DiscountHasCategory.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasCategory.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountHasCategory:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountHasCategoryPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('DiscountHasCategory.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasCategory.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountHasCategory: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->aDiscount !== null) {
|
||||
if ($this->aDiscount->isModified()) {
|
||||
$affectedRows += $this->aDiscount->save($con);
|
||||
}
|
||||
$this->setDiscount($this->aDiscount);
|
||||
}
|
||||
|
||||
if ($this->aCategory !== null) {
|
||||
if ($this->aCategory->isModified() || $this->aCategory->getCurrentCategoryI18n()->isModified()) {
|
||||
$affectedRows += $this->aCategory->save($con);
|
||||
}
|
||||
$this->setCategory($this->aCategory);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = DiscountHasCategoryPeer::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 += DiscountHasCategoryPeer::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->aDiscount !== null) {
|
||||
if (!$this->aDiscount->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aDiscount->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->aCategory !== null) {
|
||||
if (!$this->aCategory->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = DiscountHasCategoryPeer::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 = DiscountHasCategoryPeer::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->getDiscountId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getCategoryId();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getIsOpt();
|
||||
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 = DiscountHasCategoryPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getDiscountId(),
|
||||
$keys[1] => $this->getCategoryId(),
|
||||
$keys[2] => $this->getIsOpt(),
|
||||
);
|
||||
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 = DiscountHasCategoryPeer::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->setDiscountId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setCategoryId($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setIsOpt($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 = DiscountHasCategoryPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setDiscountId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setIsOpt($arr[$keys[2]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(DiscountHasCategoryPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(DiscountHasCategoryPeer::DISCOUNT_ID)) $criteria->add(DiscountHasCategoryPeer::DISCOUNT_ID, $this->discount_id);
|
||||
if ($this->isColumnModified(DiscountHasCategoryPeer::CATEGORY_ID)) $criteria->add(DiscountHasCategoryPeer::CATEGORY_ID, $this->category_id);
|
||||
if ($this->isColumnModified(DiscountHasCategoryPeer::IS_OPT)) $criteria->add(DiscountHasCategoryPeer::IS_OPT, $this->is_opt);
|
||||
|
||||
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(DiscountHasCategoryPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(DiscountHasCategoryPeer::DISCOUNT_ID, $this->discount_id);
|
||||
$criteria->add(DiscountHasCategoryPeer::CATEGORY_ID, $this->category_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->getDiscountId(), $this->getCategoryId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(DiscountHasCategoryPeer::translateFieldName('discount_id', BasePeer::TYPE_FIELDNAME, $keyType), DiscountHasCategoryPeer::translateFieldName('category_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->setDiscountId($keys[0]);
|
||||
|
||||
$this->setCategoryId($keys[1]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of DiscountHasCategory (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->setIsOpt($this->is_opt);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setDiscountId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
$copyObj->setCategoryId(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 DiscountHasCategory 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 'DiscountHasCategoryPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Discount object.
|
||||
*
|
||||
* @param Discount $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setDiscount($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setDiscountId(NULL);
|
||||
} else {
|
||||
$this->setDiscountId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aDiscount = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Discount object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Discount The associated Discount object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getDiscount($con = null)
|
||||
{
|
||||
if ($this->aDiscount === null && ($this->discount_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aDiscount = DiscountPeer::retrieveByPK($this->discount_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 = DiscountPeer::retrieveByPK($this->discount_id, $con);
|
||||
$obj->addDiscounts($this);
|
||||
*/
|
||||
}
|
||||
return $this->aDiscount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Category object.
|
||||
*
|
||||
* @param Category $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setCategory($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setCategoryId(NULL);
|
||||
} else {
|
||||
$this->setCategoryId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aCategory = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Category object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Category The associated Category object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getCategory($con = null)
|
||||
{
|
||||
if ($this->aCategory === null && ($this->category_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aCategory = CategoryPeer::retrieveByPK($this->category_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 = CategoryPeer::retrieveByPK($this->category_id, $con);
|
||||
$obj->addCategorys($this);
|
||||
*/
|
||||
}
|
||||
return $this->aCategory;
|
||||
}
|
||||
|
||||
|
||||
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, 'DiscountHasCategory.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseDiscountHasCategory:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseDiscountHasCategory::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseDiscountHasCategory
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,795 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_discount_has_producer' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseDiscountHasProducer extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the discount_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $discount_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the producer_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $producer_id;
|
||||
|
||||
/**
|
||||
* @var Discount
|
||||
*/
|
||||
protected $aDiscount;
|
||||
|
||||
/**
|
||||
* @var Producer
|
||||
*/
|
||||
protected $aProducer;
|
||||
|
||||
/**
|
||||
* 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 [discount_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDiscountId()
|
||||
{
|
||||
|
||||
return $this->discount_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [producer_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getProducerId()
|
||||
{
|
||||
|
||||
return $this->producer_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [discount_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDiscountId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->discount_id !== $v) {
|
||||
$this->discount_id = $v;
|
||||
$this->modifiedColumns[] = DiscountHasProducerPeer::DISCOUNT_ID;
|
||||
}
|
||||
|
||||
if ($this->aDiscount !== null && $this->aDiscount->getId() !== $v) {
|
||||
$this->aDiscount = null;
|
||||
}
|
||||
|
||||
} // setDiscountId()
|
||||
|
||||
/**
|
||||
* Set the value of [producer_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setProducerId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->producer_id !== $v) {
|
||||
$this->producer_id = $v;
|
||||
$this->modifiedColumns[] = DiscountHasProducerPeer::PRODUCER_ID;
|
||||
}
|
||||
|
||||
if ($this->aProducer !== null && $this->aProducer->getId() !== $v) {
|
||||
$this->aProducer = null;
|
||||
}
|
||||
|
||||
} // setProducerId()
|
||||
|
||||
/**
|
||||
* 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('DiscountHasProducer.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasProducer.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->discount_id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->producer_id = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('DiscountHasProducer.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasProducer.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 2)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 2; // 2 = DiscountHasProducerPeer::NUM_COLUMNS - DiscountHasProducerPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating DiscountHasProducer 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('DiscountHasProducer.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasProducer.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountHasProducer:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountHasProducer:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountHasProducerPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
DiscountHasProducerPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('DiscountHasProducer.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasProducer.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountHasProducer:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountHasProducer: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('DiscountHasProducer.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasProducer.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountHasProducer:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountHasProducerPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('DiscountHasProducer.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasProducer.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountHasProducer: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->aDiscount !== null) {
|
||||
if ($this->aDiscount->isModified()) {
|
||||
$affectedRows += $this->aDiscount->save($con);
|
||||
}
|
||||
$this->setDiscount($this->aDiscount);
|
||||
}
|
||||
|
||||
if ($this->aProducer !== null) {
|
||||
if ($this->aProducer->isModified() || $this->aProducer->getCurrentProducerI18n()->isModified()) {
|
||||
$affectedRows += $this->aProducer->save($con);
|
||||
}
|
||||
$this->setProducer($this->aProducer);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = DiscountHasProducerPeer::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 += DiscountHasProducerPeer::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->aDiscount !== null) {
|
||||
if (!$this->aDiscount->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aDiscount->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->aProducer !== null) {
|
||||
if (!$this->aProducer->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aProducer->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = DiscountHasProducerPeer::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 = DiscountHasProducerPeer::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->getDiscountId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getProducerId();
|
||||
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 = DiscountHasProducerPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getDiscountId(),
|
||||
$keys[1] => $this->getProducerId(),
|
||||
);
|
||||
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 = DiscountHasProducerPeer::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->setDiscountId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setProducerId($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 = DiscountHasProducerPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setDiscountId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setProducerId($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(DiscountHasProducerPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(DiscountHasProducerPeer::DISCOUNT_ID)) $criteria->add(DiscountHasProducerPeer::DISCOUNT_ID, $this->discount_id);
|
||||
if ($this->isColumnModified(DiscountHasProducerPeer::PRODUCER_ID)) $criteria->add(DiscountHasProducerPeer::PRODUCER_ID, $this->producer_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(DiscountHasProducerPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(DiscountHasProducerPeer::DISCOUNT_ID, $this->discount_id);
|
||||
$criteria->add(DiscountHasProducerPeer::PRODUCER_ID, $this->producer_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->getDiscountId(), $this->getProducerId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(DiscountHasProducerPeer::translateFieldName('discount_id', BasePeer::TYPE_FIELDNAME, $keyType), DiscountHasProducerPeer::translateFieldName('producer_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->setDiscountId($keys[0]);
|
||||
|
||||
$this->setProducerId($keys[1]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of DiscountHasProducer (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->setNew(true);
|
||||
|
||||
$copyObj->setDiscountId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
$copyObj->setProducerId(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 DiscountHasProducer 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 'DiscountHasProducerPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Discount object.
|
||||
*
|
||||
* @param Discount $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setDiscount($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setDiscountId(NULL);
|
||||
} else {
|
||||
$this->setDiscountId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aDiscount = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Discount object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Discount The associated Discount object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getDiscount($con = null)
|
||||
{
|
||||
if ($this->aDiscount === null && ($this->discount_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aDiscount = DiscountPeer::retrieveByPK($this->discount_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 = DiscountPeer::retrieveByPK($this->discount_id, $con);
|
||||
$obj->addDiscounts($this);
|
||||
*/
|
||||
}
|
||||
return $this->aDiscount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Producer object.
|
||||
*
|
||||
* @param Producer $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setProducer($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setProducerId(NULL);
|
||||
} else {
|
||||
$this->setProducerId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aProducer = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Producer object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Producer The associated Producer object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getProducer($con = null)
|
||||
{
|
||||
if ($this->aProducer === null && ($this->producer_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aProducer = ProducerPeer::retrieveByPK($this->producer_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 = ProducerPeer::retrieveByPK($this->producer_id, $con);
|
||||
$obj->addProducers($this);
|
||||
*/
|
||||
}
|
||||
return $this->aProducer;
|
||||
}
|
||||
|
||||
|
||||
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, 'DiscountHasProducer.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseDiscountHasProducer:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseDiscountHasProducer::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseDiscountHasProducer
|
||||
File diff suppressed because it is too large
Load Diff
795
plugins/stDiscountPlugin/lib/model/om/BaseDiscountHasProduct.php
Normal file
795
plugins/stDiscountPlugin/lib/model/om/BaseDiscountHasProduct.php
Normal file
@@ -0,0 +1,795 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_discount_has_product' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseDiscountHasProduct extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the discount_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $discount_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the product_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $product_id;
|
||||
|
||||
/**
|
||||
* @var Discount
|
||||
*/
|
||||
protected $aDiscount;
|
||||
|
||||
/**
|
||||
* @var Product
|
||||
*/
|
||||
protected $aProduct;
|
||||
|
||||
/**
|
||||
* 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 [discount_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDiscountId()
|
||||
{
|
||||
|
||||
return $this->discount_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [product_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getProductId()
|
||||
{
|
||||
|
||||
return $this->product_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [discount_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDiscountId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->discount_id !== $v) {
|
||||
$this->discount_id = $v;
|
||||
$this->modifiedColumns[] = DiscountHasProductPeer::DISCOUNT_ID;
|
||||
}
|
||||
|
||||
if ($this->aDiscount !== null && $this->aDiscount->getId() !== $v) {
|
||||
$this->aDiscount = null;
|
||||
}
|
||||
|
||||
} // setDiscountId()
|
||||
|
||||
/**
|
||||
* Set the value of [product_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setProductId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->product_id !== $v) {
|
||||
$this->product_id = $v;
|
||||
$this->modifiedColumns[] = DiscountHasProductPeer::PRODUCT_ID;
|
||||
}
|
||||
|
||||
if ($this->aProduct !== null && $this->aProduct->getId() !== $v) {
|
||||
$this->aProduct = null;
|
||||
}
|
||||
|
||||
} // setProductId()
|
||||
|
||||
/**
|
||||
* 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('DiscountHasProduct.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasProduct.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->discount_id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->product_id = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('DiscountHasProduct.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasProduct.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 2)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 2; // 2 = DiscountHasProductPeer::NUM_COLUMNS - DiscountHasProductPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating DiscountHasProduct 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('DiscountHasProduct.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasProduct.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountHasProduct:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountHasProduct:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountHasProductPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
DiscountHasProductPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('DiscountHasProduct.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasProduct.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountHasProduct:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountHasProduct: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('DiscountHasProduct.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasProduct.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountHasProduct:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountHasProductPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('DiscountHasProduct.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountHasProduct.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountHasProduct: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->aDiscount !== null) {
|
||||
if ($this->aDiscount->isModified()) {
|
||||
$affectedRows += $this->aDiscount->save($con);
|
||||
}
|
||||
$this->setDiscount($this->aDiscount);
|
||||
}
|
||||
|
||||
if ($this->aProduct !== null) {
|
||||
if ($this->aProduct->isModified() || $this->aProduct->getCurrentProductI18n()->isModified()) {
|
||||
$affectedRows += $this->aProduct->save($con);
|
||||
}
|
||||
$this->setProduct($this->aProduct);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = DiscountHasProductPeer::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 += DiscountHasProductPeer::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->aDiscount !== null) {
|
||||
if (!$this->aDiscount->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aDiscount->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->aProduct !== null) {
|
||||
if (!$this->aProduct->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = DiscountHasProductPeer::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 = DiscountHasProductPeer::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->getDiscountId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getProductId();
|
||||
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 = DiscountHasProductPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getDiscountId(),
|
||||
$keys[1] => $this->getProductId(),
|
||||
);
|
||||
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 = DiscountHasProductPeer::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->setDiscountId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setProductId($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 = DiscountHasProductPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setDiscountId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setProductId($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(DiscountHasProductPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(DiscountHasProductPeer::DISCOUNT_ID)) $criteria->add(DiscountHasProductPeer::DISCOUNT_ID, $this->discount_id);
|
||||
if ($this->isColumnModified(DiscountHasProductPeer::PRODUCT_ID)) $criteria->add(DiscountHasProductPeer::PRODUCT_ID, $this->product_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(DiscountHasProductPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(DiscountHasProductPeer::DISCOUNT_ID, $this->discount_id);
|
||||
$criteria->add(DiscountHasProductPeer::PRODUCT_ID, $this->product_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->getDiscountId(), $this->getProductId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(DiscountHasProductPeer::translateFieldName('discount_id', BasePeer::TYPE_FIELDNAME, $keyType), DiscountHasProductPeer::translateFieldName('product_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->setDiscountId($keys[0]);
|
||||
|
||||
$this->setProductId($keys[1]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of DiscountHasProduct (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->setNew(true);
|
||||
|
||||
$copyObj->setDiscountId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
$copyObj->setProductId(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 DiscountHasProduct 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 'DiscountHasProductPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Discount object.
|
||||
*
|
||||
* @param Discount $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setDiscount($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setDiscountId(NULL);
|
||||
} else {
|
||||
$this->setDiscountId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aDiscount = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Discount object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Discount The associated Discount object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getDiscount($con = null)
|
||||
{
|
||||
if ($this->aDiscount === null && ($this->discount_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aDiscount = DiscountPeer::retrieveByPK($this->discount_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 = DiscountPeer::retrieveByPK($this->discount_id, $con);
|
||||
$obj->addDiscounts($this);
|
||||
*/
|
||||
}
|
||||
return $this->aDiscount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Product object.
|
||||
*
|
||||
* @param Product $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setProduct($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setProductId(NULL);
|
||||
} else {
|
||||
$this->setProductId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aProduct = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Product object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Product The associated Product object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getProduct($con = null)
|
||||
{
|
||||
if ($this->aProduct === null && ($this->product_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aProduct = ProductPeer::retrieveByPK($this->product_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 = ProductPeer::retrieveByPK($this->product_id, $con);
|
||||
$obj->addProducts($this);
|
||||
*/
|
||||
}
|
||||
return $this->aProduct;
|
||||
}
|
||||
|
||||
|
||||
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, 'DiscountHasProduct.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseDiscountHasProduct:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseDiscountHasProduct::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseDiscountHasProduct
|
||||
1170
plugins/stDiscountPlugin/lib/model/om/BaseDiscountHasProductPeer.php
Normal file
1170
plugins/stDiscountPlugin/lib/model/om/BaseDiscountHasProductPeer.php
Normal file
File diff suppressed because it is too large
Load Diff
990
plugins/stDiscountPlugin/lib/model/om/BaseDiscountPeer.php
Normal file
990
plugins/stDiscountPlugin/lib/model/om/BaseDiscountPeer.php
Normal file
@@ -0,0 +1,990 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'st_discount' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseDiscountPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'st_discount';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.stDiscountPlugin.lib.model.Discount';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 14;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'st_discount.ID';
|
||||
|
||||
/** the column name for the TYPE field */
|
||||
const TYPE = 'st_discount.TYPE';
|
||||
|
||||
/** the column name for the PRICE_TYPE field */
|
||||
const PRICE_TYPE = 'st_discount.PRICE_TYPE';
|
||||
|
||||
/** the column name for the NAME field */
|
||||
const NAME = 'st_discount.NAME';
|
||||
|
||||
/** the column name for the VALUE field */
|
||||
const VALUE = 'st_discount.VALUE';
|
||||
|
||||
/** the column name for the WHOLESALE_VALUE field */
|
||||
const WHOLESALE_VALUE = 'st_discount.WHOLESALE_VALUE';
|
||||
|
||||
/** the column name for the CONDITIONS field */
|
||||
const CONDITIONS = 'st_discount.CONDITIONS';
|
||||
|
||||
/** the column name for the PRIORITY field */
|
||||
const PRIORITY = 'st_discount.PRIORITY';
|
||||
|
||||
/** the column name for the ACTIVE field */
|
||||
const ACTIVE = 'st_discount.ACTIVE';
|
||||
|
||||
/** the column name for the ALL_PRODUCTS field */
|
||||
const ALL_PRODUCTS = 'st_discount.ALL_PRODUCTS';
|
||||
|
||||
/** the column name for the ALL_CLIENTS field */
|
||||
const ALL_CLIENTS = 'st_discount.ALL_CLIENTS';
|
||||
|
||||
/** the column name for the ALLOW_ANONYMOUS_CLIENTS field */
|
||||
const ALLOW_ANONYMOUS_CLIENTS = 'st_discount.ALLOW_ANONYMOUS_CLIENTS';
|
||||
|
||||
/** the column name for the AUTO_ACTIVE field */
|
||||
const AUTO_ACTIVE = 'st_discount.AUTO_ACTIVE';
|
||||
|
||||
/** the column name for the PRODUCT_ID field */
|
||||
const PRODUCT_ID = 'st_discount.PRODUCT_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 ('Id', 'Type', 'PriceType', 'Name', 'Value', 'WholesaleValue', 'Conditions', 'Priority', 'Active', 'AllProducts', 'AllClients', 'AllowAnonymousClients', 'AutoActive', 'ProductId', ),
|
||||
BasePeer::TYPE_COLNAME => array (DiscountPeer::ID, DiscountPeer::TYPE, DiscountPeer::PRICE_TYPE, DiscountPeer::NAME, DiscountPeer::VALUE, DiscountPeer::WHOLESALE_VALUE, DiscountPeer::CONDITIONS, DiscountPeer::PRIORITY, DiscountPeer::ACTIVE, DiscountPeer::ALL_PRODUCTS, DiscountPeer::ALL_CLIENTS, DiscountPeer::ALLOW_ANONYMOUS_CLIENTS, DiscountPeer::AUTO_ACTIVE, DiscountPeer::PRODUCT_ID, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'type', 'price_type', 'name', 'value', 'wholesale_value', 'conditions', 'priority', 'active', 'all_products', 'all_clients', 'allow_anonymous_clients', 'auto_active', 'product_id', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Type' => 1, 'PriceType' => 2, 'Name' => 3, 'Value' => 4, 'WholesaleValue' => 5, 'Conditions' => 6, 'Priority' => 7, 'Active' => 8, 'AllProducts' => 9, 'AllClients' => 10, 'AllowAnonymousClients' => 11, 'AutoActive' => 12, 'ProductId' => 13, ),
|
||||
BasePeer::TYPE_COLNAME => array (DiscountPeer::ID => 0, DiscountPeer::TYPE => 1, DiscountPeer::PRICE_TYPE => 2, DiscountPeer::NAME => 3, DiscountPeer::VALUE => 4, DiscountPeer::WHOLESALE_VALUE => 5, DiscountPeer::CONDITIONS => 6, DiscountPeer::PRIORITY => 7, DiscountPeer::ACTIVE => 8, DiscountPeer::ALL_PRODUCTS => 9, DiscountPeer::ALL_CLIENTS => 10, DiscountPeer::ALLOW_ANONYMOUS_CLIENTS => 11, DiscountPeer::AUTO_ACTIVE => 12, DiscountPeer::PRODUCT_ID => 13, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'type' => 1, 'price_type' => 2, 'name' => 3, 'value' => 4, 'wholesale_value' => 5, 'conditions' => 6, 'priority' => 7, 'active' => 8, 'all_products' => 9, 'all_clients' => 10, 'allow_anonymous_clients' => 11, 'auto_active' => 12, 'product_id' => 13, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, )
|
||||
);
|
||||
|
||||
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.stDiscountPlugin.lib.model.map.DiscountMapBuilder');
|
||||
}
|
||||
/**
|
||||
* 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 = DiscountPeer::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. DiscountPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(DiscountPeer::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(DiscountPeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(DiscountPeer::TYPE);
|
||||
|
||||
$criteria->addSelectColumn(DiscountPeer::PRICE_TYPE);
|
||||
|
||||
$criteria->addSelectColumn(DiscountPeer::NAME);
|
||||
|
||||
$criteria->addSelectColumn(DiscountPeer::VALUE);
|
||||
|
||||
$criteria->addSelectColumn(DiscountPeer::WHOLESALE_VALUE);
|
||||
|
||||
$criteria->addSelectColumn(DiscountPeer::CONDITIONS);
|
||||
|
||||
$criteria->addSelectColumn(DiscountPeer::PRIORITY);
|
||||
|
||||
$criteria->addSelectColumn(DiscountPeer::ACTIVE);
|
||||
|
||||
$criteria->addSelectColumn(DiscountPeer::ALL_PRODUCTS);
|
||||
|
||||
$criteria->addSelectColumn(DiscountPeer::ALL_CLIENTS);
|
||||
|
||||
$criteria->addSelectColumn(DiscountPeer::ALLOW_ANONYMOUS_CLIENTS);
|
||||
|
||||
$criteria->addSelectColumn(DiscountPeer::AUTO_ACTIVE);
|
||||
|
||||
$criteria->addSelectColumn(DiscountPeer::PRODUCT_ID);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('DiscountPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'DiscountPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(st_discount.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT st_discount.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(DiscountPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(DiscountPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = DiscountPeer::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 Discount
|
||||
* @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 = DiscountPeer::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 Discount[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return DiscountPeer::populateObjects(DiscountPeer::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;
|
||||
DiscountPeer::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 = DiscountPeer::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(DiscountPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(DiscountPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(DiscountPeer::PRODUCT_ID, ProductPeer::ID, Criteria::LEFT_JOIN);
|
||||
|
||||
$rs = DiscountPeer::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 Discount objects pre-filled with their Product objects.
|
||||
*
|
||||
* @return Discount[] Array of Discount 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);
|
||||
}
|
||||
|
||||
DiscountPeer::addSelectColumns($c);
|
||||
|
||||
ProductPeer::addSelectColumns($c);
|
||||
|
||||
$c->addJoin(DiscountPeer::PRODUCT_ID, ProductPeer::ID, Criteria::LEFT_JOIN);
|
||||
$rs = DiscountPeer::doSelectRs($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$obj1 = new Discount();
|
||||
$startcol = $obj1->hydrate($rs);
|
||||
if ($obj1->getProductId())
|
||||
{
|
||||
|
||||
$obj2 = new Product();
|
||||
$obj2->hydrate($rs, $startcol);
|
||||
$obj2->addDiscount($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(DiscountPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(DiscountPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(DiscountPeer::PRODUCT_ID, ProductPeer::ID, Criteria::LEFT_JOIN);
|
||||
|
||||
$rs = DiscountPeer::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 Discount objects pre-filled with all related objects.
|
||||
*
|
||||
* @return Discount[]
|
||||
* @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);
|
||||
}
|
||||
|
||||
DiscountPeer::addSelectColumns($c);
|
||||
$startcol2 = (DiscountPeer::NUM_COLUMNS - DiscountPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
|
||||
|
||||
ProductPeer::addSelectColumns($c);
|
||||
$startcol3 = $startcol2 + ProductPeer::NUM_COLUMNS;
|
||||
|
||||
$c->addJoin(DiscountPeer::PRODUCT_ID, ProductPeer::ID, Criteria::LEFT_JOIN);
|
||||
|
||||
$rs = BasePeer::doSelect($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$omClass = DiscountPeer::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->addDiscount($obj1); // CHECKME
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newObject) {
|
||||
$obj2->initDiscounts();
|
||||
$obj2->addDiscount($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 DiscountPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a Discount or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or Discount 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('BaseDiscountPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseDiscountPeer', $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 Discount object
|
||||
}
|
||||
|
||||
$criteria->remove(DiscountPeer::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('BaseDiscountPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseDiscountPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a Discount or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or Discount 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('BaseDiscountPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseDiscountPeer', $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(DiscountPeer::ID);
|
||||
$selectCriteria->add(DiscountPeer::ID, $criteria->remove(DiscountPeer::ID), $comparison);
|
||||
|
||||
} else { // $values is Discount 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('BaseDiscountPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseDiscountPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the st_discount 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 += DiscountPeer::doOnDeleteCascade(new Criteria(), $con);
|
||||
DiscountPeer::doOnDeleteSetNull(new Criteria(), $con);
|
||||
$affectedRows += BasePeer::doDeleteAll(DiscountPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a Discount or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or Discount 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(DiscountPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof Discount) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(DiscountPeer::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 += DiscountPeer::doOnDeleteCascade($criteria, $con);DiscountPeer::doOnDeleteSetNull($criteria, $con);
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a method for emulating ON DELETE CASCADE for DBs that don't support this
|
||||
* feature (like MySQL or SQLite).
|
||||
*
|
||||
* This method is not very speedy because it must perform a query first to get
|
||||
* the implicated records and then perform the deletes by calling those Peer classes.
|
||||
*
|
||||
* This method should be used within a transaction if possible.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param Connection $con
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
protected static function doOnDeleteCascade(Criteria $criteria, Connection $con)
|
||||
{
|
||||
// initialize var to track total num of affected rows
|
||||
$affectedRows = 0;
|
||||
|
||||
// first find the objects that are implicated by the $criteria
|
||||
$objects = DiscountPeer::doSelect($criteria, $con);
|
||||
foreach($objects as $obj) {
|
||||
|
||||
|
||||
// delete related UserHasDiscount objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(UserHasDiscountPeer::DISCOUNT_ID, $obj->getId());
|
||||
$affectedRows += UserHasDiscountPeer::doDelete($c, $con);
|
||||
|
||||
// delete related DiscountHasProduct objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(DiscountHasProductPeer::DISCOUNT_ID, $obj->getId());
|
||||
$affectedRows += DiscountHasProductPeer::doDelete($c, $con);
|
||||
|
||||
// delete related DiscountRange objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(DiscountRangePeer::DISCOUNT_ID, $obj->getId());
|
||||
$affectedRows += DiscountRangePeer::doDelete($c, $con);
|
||||
|
||||
// delete related DiscountHasProducer objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(DiscountHasProducerPeer::DISCOUNT_ID, $obj->getId());
|
||||
$affectedRows += DiscountHasProducerPeer::doDelete($c, $con);
|
||||
|
||||
// delete related DiscountHasCategory objects
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(DiscountHasCategoryPeer::DISCOUNT_ID, $obj->getId());
|
||||
$affectedRows += DiscountHasCategoryPeer::doDelete($c, $con);
|
||||
}
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a method for emulating ON DELETE SET NULL DBs that don't support this
|
||||
* feature (like MySQL or SQLite).
|
||||
*
|
||||
* This method is not very speedy because it must perform a query first to get
|
||||
* the implicated records and then perform the deletes by calling those Peer classes.
|
||||
*
|
||||
* This method should be used within a transaction if possible.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
*/
|
||||
protected static function doOnDeleteSetNull(Criteria $criteria, Connection $con)
|
||||
{
|
||||
|
||||
// first find the objects that are implicated by the $criteria
|
||||
$objects = DiscountPeer::doSelect($criteria, $con);
|
||||
foreach($objects as $obj) {
|
||||
|
||||
// set fkey col in related Order rows to NULL
|
||||
$selectCriteria = new Criteria(DiscountPeer::DATABASE_NAME);
|
||||
$updateValues = new Criteria(DiscountPeer::DATABASE_NAME);
|
||||
$selectCriteria->add(OrderPeer::DISCOUNT_ID, $obj->getId());
|
||||
$updateValues->add(OrderPeer::DISCOUNT_ID, null);
|
||||
|
||||
BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given Discount 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 Discount $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(Discount $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(DiscountPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(DiscountPeer::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(DiscountPeer::DATABASE_NAME, DiscountPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = DiscountPeer::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 Discount
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(DiscountPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(DiscountPeer::ID, $pk);
|
||||
|
||||
|
||||
$v = DiscountPeer::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 Discount[]
|
||||
*/
|
||||
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(DiscountPeer::ID, $pks, Criteria::IN);
|
||||
$objs = DiscountPeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BaseDiscountPeer
|
||||
|
||||
// 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 {
|
||||
BaseDiscountPeer::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.stDiscountPlugin.lib.model.map.DiscountMapBuilder');
|
||||
}
|
||||
932
plugins/stDiscountPlugin/lib/model/om/BaseDiscountRange.php
Normal file
932
plugins/stDiscountPlugin/lib/model/om/BaseDiscountRange.php
Normal file
@@ -0,0 +1,932 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_discount_range' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseDiscountRange extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
* @var int
|
||||
*/
|
||||
protected $created_at;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the updated_at field.
|
||||
* @var int
|
||||
*/
|
||||
protected $updated_at;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the discount_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $discount_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the total_value field.
|
||||
* @var double
|
||||
*/
|
||||
protected $total_value = 0.0;
|
||||
|
||||
/**
|
||||
* @var Discount
|
||||
*/
|
||||
protected $aDiscount;
|
||||
|
||||
/**
|
||||
* 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 [optionally formatted] [updated_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 getUpdatedAt($format = 'Y-m-d H:i:s')
|
||||
{
|
||||
|
||||
if ($this->updated_at === null || $this->updated_at === '') {
|
||||
return null;
|
||||
} elseif (!is_int($this->updated_at)) {
|
||||
// a non-timestamp value was set externally, so we convert it
|
||||
$ts = strtotime($this->updated_at);
|
||||
if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
|
||||
throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
|
||||
}
|
||||
} else {
|
||||
$ts = $this->updated_at;
|
||||
}
|
||||
if ($format === null) {
|
||||
return $ts;
|
||||
} elseif (strpos($format, '%') !== false) {
|
||||
return strftime($format, $ts);
|
||||
} else {
|
||||
return date($format, $ts);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [discount_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDiscountId()
|
||||
{
|
||||
|
||||
return $this->discount_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [total_value] column value.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public function getTotalValue()
|
||||
{
|
||||
|
||||
return $this->total_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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[] = DiscountRangePeer::CREATED_AT;
|
||||
}
|
||||
|
||||
} // setCreatedAt()
|
||||
|
||||
/**
|
||||
* Set the value of [updated_at] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setUpdatedAt($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 [updated_at] from input: " . var_export($v, true));
|
||||
}
|
||||
} else {
|
||||
$ts = $v;
|
||||
}
|
||||
if ($this->updated_at !== $ts) {
|
||||
$this->updated_at = $ts;
|
||||
$this->modifiedColumns[] = DiscountRangePeer::UPDATED_AT;
|
||||
}
|
||||
|
||||
} // setUpdatedAt()
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->id !== $v) {
|
||||
$this->id = $v;
|
||||
$this->modifiedColumns[] = DiscountRangePeer::ID;
|
||||
}
|
||||
|
||||
} // setId()
|
||||
|
||||
/**
|
||||
* Set the value of [discount_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDiscountId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->discount_id !== $v) {
|
||||
$this->discount_id = $v;
|
||||
$this->modifiedColumns[] = DiscountRangePeer::DISCOUNT_ID;
|
||||
}
|
||||
|
||||
if ($this->aDiscount !== null && $this->aDiscount->getId() !== $v) {
|
||||
$this->aDiscount = null;
|
||||
}
|
||||
|
||||
} // setDiscountId()
|
||||
|
||||
/**
|
||||
* Set the value of [total_value] column.
|
||||
*
|
||||
* @param double $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setTotalValue($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_float($v) && is_numeric($v)) {
|
||||
$v = (float) $v;
|
||||
}
|
||||
|
||||
if ($this->total_value !== $v || $v === 0.0) {
|
||||
$this->total_value = $v;
|
||||
$this->modifiedColumns[] = DiscountRangePeer::TOTAL_VALUE;
|
||||
}
|
||||
|
||||
} // setTotalValue()
|
||||
|
||||
/**
|
||||
* 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('DiscountRange.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountRange.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->created_at = $rs->getTimestamp($startcol + 0, null);
|
||||
|
||||
$this->updated_at = $rs->getTimestamp($startcol + 1, null);
|
||||
|
||||
$this->id = $rs->getInt($startcol + 2);
|
||||
|
||||
$this->discount_id = $rs->getInt($startcol + 3);
|
||||
|
||||
$this->total_value = $rs->getFloat($startcol + 4);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('DiscountRange.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountRange.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 5)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 5; // 5 = DiscountRangePeer::NUM_COLUMNS - DiscountRangePeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating DiscountRange 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('DiscountRange.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountRange.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountRange:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountRange:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountRangePeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
DiscountRangePeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('DiscountRange.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountRange.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountRange:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountRange: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('DiscountRange.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountRange.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountRange:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($this->isNew() && !$this->isColumnModified(DiscountRangePeer::CREATED_AT))
|
||||
{
|
||||
$this->setCreatedAt(time());
|
||||
}
|
||||
|
||||
if ($this->isModified() && !$this->isColumnModified(DiscountRangePeer::UPDATED_AT))
|
||||
{
|
||||
$this->setUpdatedAt(time());
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountRangePeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('DiscountRange.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountRange.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountRange: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->aDiscount !== null) {
|
||||
if ($this->aDiscount->isModified()) {
|
||||
$affectedRows += $this->aDiscount->save($con);
|
||||
}
|
||||
$this->setDiscount($this->aDiscount);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = DiscountRangePeer::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->setId($pk); //[IMV] update autoincrement primary key
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += DiscountRangePeer::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->aDiscount !== null) {
|
||||
if (!$this->aDiscount->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aDiscount->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = DiscountRangePeer::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 = DiscountRangePeer::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->getUpdatedAt();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getId();
|
||||
break;
|
||||
case 3:
|
||||
return $this->getDiscountId();
|
||||
break;
|
||||
case 4:
|
||||
return $this->getTotalValue();
|
||||
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 = DiscountRangePeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getCreatedAt(),
|
||||
$keys[1] => $this->getUpdatedAt(),
|
||||
$keys[2] => $this->getId(),
|
||||
$keys[3] => $this->getDiscountId(),
|
||||
$keys[4] => $this->getTotalValue(),
|
||||
);
|
||||
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 = DiscountRangePeer::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->setUpdatedAt($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setId($value);
|
||||
break;
|
||||
case 3:
|
||||
$this->setDiscountId($value);
|
||||
break;
|
||||
case 4:
|
||||
$this->setTotalValue($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 = DiscountRangePeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setCreatedAt($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setUpdatedAt($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setId($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setDiscountId($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setTotalValue($arr[$keys[4]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(DiscountRangePeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(DiscountRangePeer::CREATED_AT)) $criteria->add(DiscountRangePeer::CREATED_AT, $this->created_at);
|
||||
if ($this->isColumnModified(DiscountRangePeer::UPDATED_AT)) $criteria->add(DiscountRangePeer::UPDATED_AT, $this->updated_at);
|
||||
if ($this->isColumnModified(DiscountRangePeer::ID)) $criteria->add(DiscountRangePeer::ID, $this->id);
|
||||
if ($this->isColumnModified(DiscountRangePeer::DISCOUNT_ID)) $criteria->add(DiscountRangePeer::DISCOUNT_ID, $this->discount_id);
|
||||
if ($this->isColumnModified(DiscountRangePeer::TOTAL_VALUE)) $criteria->add(DiscountRangePeer::TOTAL_VALUE, $this->total_value);
|
||||
|
||||
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(DiscountRangePeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(DiscountRangePeer::ID, $this->id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for this object (row).
|
||||
* @return int
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(DiscountRangePeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method to set the primary key (id column).
|
||||
*
|
||||
* @param int $key Primary key.
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($key)
|
||||
{
|
||||
$this->setId($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 DiscountRange (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->setUpdatedAt($this->updated_at);
|
||||
|
||||
$copyObj->setDiscountId($this->discount_id);
|
||||
|
||||
$copyObj->setTotalValue($this->total_value);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setId(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 DiscountRange 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 'DiscountRangePeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Discount object.
|
||||
*
|
||||
* @param Discount $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setDiscount($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setDiscountId(NULL);
|
||||
} else {
|
||||
$this->setDiscountId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aDiscount = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Discount object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Discount The associated Discount object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getDiscount($con = null)
|
||||
{
|
||||
if ($this->aDiscount === null && ($this->discount_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aDiscount = DiscountPeer::retrieveByPK($this->discount_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 = DiscountPeer::retrieveByPK($this->discount_id, $con);
|
||||
$obj->addDiscounts($this);
|
||||
*/
|
||||
}
|
||||
return $this->aDiscount;
|
||||
}
|
||||
|
||||
|
||||
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, 'DiscountRange.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseDiscountRange:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseDiscountRange::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseDiscountRange
|
||||
856
plugins/stDiscountPlugin/lib/model/om/BaseDiscountRangePeer.php
Normal file
856
plugins/stDiscountPlugin/lib/model/om/BaseDiscountRangePeer.php
Normal file
@@ -0,0 +1,856 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'st_discount_range' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseDiscountRangePeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'st_discount_range';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.stDiscountPlugin.lib.model.DiscountRange';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 5;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the CREATED_AT field */
|
||||
const CREATED_AT = 'st_discount_range.CREATED_AT';
|
||||
|
||||
/** the column name for the UPDATED_AT field */
|
||||
const UPDATED_AT = 'st_discount_range.UPDATED_AT';
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'st_discount_range.ID';
|
||||
|
||||
/** the column name for the DISCOUNT_ID field */
|
||||
const DISCOUNT_ID = 'st_discount_range.DISCOUNT_ID';
|
||||
|
||||
/** the column name for the TOTAL_VALUE field */
|
||||
const TOTAL_VALUE = 'st_discount_range.TOTAL_VALUE';
|
||||
|
||||
/** 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', 'DiscountId', 'TotalValue', ),
|
||||
BasePeer::TYPE_COLNAME => array (DiscountRangePeer::CREATED_AT, DiscountRangePeer::UPDATED_AT, DiscountRangePeer::ID, DiscountRangePeer::DISCOUNT_ID, DiscountRangePeer::TOTAL_VALUE, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('created_at', 'updated_at', 'id', 'discount_id', 'total_value', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('CreatedAt' => 0, 'UpdatedAt' => 1, 'Id' => 2, 'DiscountId' => 3, 'TotalValue' => 4, ),
|
||||
BasePeer::TYPE_COLNAME => array (DiscountRangePeer::CREATED_AT => 0, DiscountRangePeer::UPDATED_AT => 1, DiscountRangePeer::ID => 2, DiscountRangePeer::DISCOUNT_ID => 3, DiscountRangePeer::TOTAL_VALUE => 4, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('created_at' => 0, 'updated_at' => 1, 'id' => 2, 'discount_id' => 3, 'total_value' => 4, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.stDiscountPlugin.lib.model.map.DiscountRangeMapBuilder');
|
||||
}
|
||||
/**
|
||||
* 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 = DiscountRangePeer::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. DiscountRangePeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(DiscountRangePeer::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(DiscountRangePeer::CREATED_AT);
|
||||
|
||||
$criteria->addSelectColumn(DiscountRangePeer::UPDATED_AT);
|
||||
|
||||
$criteria->addSelectColumn(DiscountRangePeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(DiscountRangePeer::DISCOUNT_ID);
|
||||
|
||||
$criteria->addSelectColumn(DiscountRangePeer::TOTAL_VALUE);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('DiscountRangePeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'DiscountRangePeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(st_discount_range.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT st_discount_range.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(DiscountRangePeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(DiscountRangePeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = DiscountRangePeer::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 DiscountRange
|
||||
* @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 = DiscountRangePeer::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 DiscountRange[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return DiscountRangePeer::populateObjects(DiscountRangePeer::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;
|
||||
DiscountRangePeer::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 = DiscountRangePeer::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 Discount 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 doCountJoinDiscount(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(DiscountRangePeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(DiscountRangePeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(DiscountRangePeer::DISCOUNT_ID, DiscountPeer::ID);
|
||||
|
||||
$rs = DiscountRangePeer::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 DiscountRange objects pre-filled with their Discount objects.
|
||||
*
|
||||
* @return DiscountRange[] Array of DiscountRange objects.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinDiscount(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);
|
||||
}
|
||||
|
||||
DiscountRangePeer::addSelectColumns($c);
|
||||
|
||||
DiscountPeer::addSelectColumns($c);
|
||||
|
||||
$c->addJoin(DiscountRangePeer::DISCOUNT_ID, DiscountPeer::ID);
|
||||
$rs = DiscountRangePeer::doSelectRs($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$obj1 = new DiscountRange();
|
||||
$startcol = $obj1->hydrate($rs);
|
||||
if ($obj1->getDiscountId())
|
||||
{
|
||||
|
||||
$obj2 = new Discount();
|
||||
$obj2->hydrate($rs, $startcol);
|
||||
$obj2->addDiscountRange($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(DiscountRangePeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(DiscountRangePeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(DiscountRangePeer::DISCOUNT_ID, DiscountPeer::ID);
|
||||
|
||||
$rs = DiscountRangePeer::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 DiscountRange objects pre-filled with all related objects.
|
||||
*
|
||||
* @return DiscountRange[]
|
||||
* @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);
|
||||
}
|
||||
|
||||
DiscountRangePeer::addSelectColumns($c);
|
||||
$startcol2 = (DiscountRangePeer::NUM_COLUMNS - DiscountRangePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
|
||||
|
||||
DiscountPeer::addSelectColumns($c);
|
||||
$startcol3 = $startcol2 + DiscountPeer::NUM_COLUMNS;
|
||||
|
||||
$c->addJoin(DiscountRangePeer::DISCOUNT_ID, DiscountPeer::ID);
|
||||
|
||||
$rs = BasePeer::doSelect($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$omClass = DiscountRangePeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj1 = new $cls();
|
||||
$obj1->hydrate($rs);
|
||||
|
||||
|
||||
// Add objects for joined Discount rows
|
||||
|
||||
$omClass = DiscountPeer::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->getDiscount(); // CHECKME
|
||||
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
|
||||
$newObject = false;
|
||||
$temp_obj2->addDiscountRange($obj1); // CHECKME
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newObject) {
|
||||
$obj2->initDiscountRanges();
|
||||
$obj2->addDiscountRange($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 DiscountRangePeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a DiscountRange or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or DiscountRange 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('BaseDiscountRangePeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseDiscountRangePeer', $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 DiscountRange object
|
||||
}
|
||||
|
||||
$criteria->remove(DiscountRangePeer::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('BaseDiscountRangePeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseDiscountRangePeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a DiscountRange or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or DiscountRange 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('BaseDiscountRangePeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseDiscountRangePeer', $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(DiscountRangePeer::ID);
|
||||
$selectCriteria->add(DiscountRangePeer::ID, $criteria->remove(DiscountRangePeer::ID), $comparison);
|
||||
|
||||
} else { // $values is DiscountRange 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('BaseDiscountRangePeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseDiscountRangePeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the st_discount_range 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(DiscountRangePeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a DiscountRange or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or DiscountRange 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(DiscountRangePeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof DiscountRange) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(DiscountRangePeer::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 DiscountRange 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 DiscountRange $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(DiscountRange $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(DiscountRangePeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(DiscountRangePeer::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(DiscountRangePeer::DATABASE_NAME, DiscountRangePeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = DiscountRangePeer::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 DiscountRange
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(DiscountRangePeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(DiscountRangePeer::ID, $pk);
|
||||
|
||||
|
||||
$v = DiscountRangePeer::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 DiscountRange[]
|
||||
*/
|
||||
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(DiscountRangePeer::ID, $pks, Criteria::IN);
|
||||
$objs = DiscountRangePeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BaseDiscountRangePeer
|
||||
|
||||
// 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 {
|
||||
BaseDiscountRangePeer::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.stDiscountPlugin.lib.model.map.DiscountRangeMapBuilder');
|
||||
}
|
||||
772
plugins/stDiscountPlugin/lib/model/om/BaseDiscountUser.php
Normal file
772
plugins/stDiscountPlugin/lib/model/om/BaseDiscountUser.php
Normal file
@@ -0,0 +1,772 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_discount_user' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseDiscountUser extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the sf_guard_user_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $sf_guard_user_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the discount field.
|
||||
* @var double
|
||||
*/
|
||||
protected $discount = 0.0;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var sfGuardUser
|
||||
*/
|
||||
protected $asfGuardUser;
|
||||
|
||||
/**
|
||||
* 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 [sf_guard_user_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSfGuardUserId()
|
||||
{
|
||||
|
||||
return $this->sf_guard_user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [discount] column value.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public function getDiscount()
|
||||
{
|
||||
|
||||
return $this->discount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [sf_guard_user_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setSfGuardUserId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->sf_guard_user_id !== $v) {
|
||||
$this->sf_guard_user_id = $v;
|
||||
$this->modifiedColumns[] = DiscountUserPeer::SF_GUARD_USER_ID;
|
||||
}
|
||||
|
||||
if ($this->asfGuardUser !== null && $this->asfGuardUser->getId() !== $v) {
|
||||
$this->asfGuardUser = null;
|
||||
}
|
||||
|
||||
} // setSfGuardUserId()
|
||||
|
||||
/**
|
||||
* Set the value of [discount] column.
|
||||
*
|
||||
* @param double $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDiscount($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_float($v) && is_numeric($v)) {
|
||||
$v = (float) $v;
|
||||
}
|
||||
|
||||
if ($this->discount !== $v || $v === 0.0) {
|
||||
$this->discount = $v;
|
||||
$this->modifiedColumns[] = DiscountUserPeer::DISCOUNT;
|
||||
}
|
||||
|
||||
} // setDiscount()
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->id !== $v) {
|
||||
$this->id = $v;
|
||||
$this->modifiedColumns[] = DiscountUserPeer::ID;
|
||||
}
|
||||
|
||||
} // setId()
|
||||
|
||||
/**
|
||||
* 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('DiscountUser.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountUser.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->sf_guard_user_id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->discount = $rs->getFloat($startcol + 1);
|
||||
|
||||
$this->id = $rs->getInt($startcol + 2);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('DiscountUser.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DiscountUser.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 3)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 3; // 3 = DiscountUserPeer::NUM_COLUMNS - DiscountUserPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating DiscountUser 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('DiscountUser.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountUser.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountUser:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountUser:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountUserPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
DiscountUserPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('DiscountUser.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountUser.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseDiscountUser:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseDiscountUser: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('DiscountUser.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountUser.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountUser:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(DiscountUserPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('DiscountUser.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'DiscountUser.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseDiscountUser: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->asfGuardUser !== null) {
|
||||
if ($this->asfGuardUser->isModified()) {
|
||||
$affectedRows += $this->asfGuardUser->save($con);
|
||||
}
|
||||
$this->setsfGuardUser($this->asfGuardUser);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = DiscountUserPeer::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->setId($pk); //[IMV] update autoincrement primary key
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += DiscountUserPeer::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->asfGuardUser !== null) {
|
||||
if (!$this->asfGuardUser->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->asfGuardUser->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = DiscountUserPeer::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 = DiscountUserPeer::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->getSfGuardUserId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getDiscount();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getId();
|
||||
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 = DiscountUserPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getSfGuardUserId(),
|
||||
$keys[1] => $this->getDiscount(),
|
||||
$keys[2] => $this->getId(),
|
||||
);
|
||||
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 = DiscountUserPeer::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->setSfGuardUserId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setDiscount($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setId($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 = DiscountUserPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setSfGuardUserId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setDiscount($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setId($arr[$keys[2]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(DiscountUserPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(DiscountUserPeer::SF_GUARD_USER_ID)) $criteria->add(DiscountUserPeer::SF_GUARD_USER_ID, $this->sf_guard_user_id);
|
||||
if ($this->isColumnModified(DiscountUserPeer::DISCOUNT)) $criteria->add(DiscountUserPeer::DISCOUNT, $this->discount);
|
||||
if ($this->isColumnModified(DiscountUserPeer::ID)) $criteria->add(DiscountUserPeer::ID, $this->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(DiscountUserPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(DiscountUserPeer::ID, $this->id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for this object (row).
|
||||
* @return int
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(DiscountUserPeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method to set the primary key (id column).
|
||||
*
|
||||
* @param int $key Primary key.
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($key)
|
||||
{
|
||||
$this->setId($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 DiscountUser (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->setSfGuardUserId($this->sf_guard_user_id);
|
||||
|
||||
$copyObj->setDiscount($this->discount);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setId(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 DiscountUser 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 'DiscountUserPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a sfGuardUser object.
|
||||
*
|
||||
* @param sfGuardUser $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setsfGuardUser($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setSfGuardUserId(NULL);
|
||||
} else {
|
||||
$this->setSfGuardUserId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->asfGuardUser = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated sfGuardUser object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return sfGuardUser The associated sfGuardUser object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getsfGuardUser($con = null)
|
||||
{
|
||||
if ($this->asfGuardUser === null && ($this->sf_guard_user_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->asfGuardUser = sfGuardUserPeer::retrieveByPK($this->sf_guard_user_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 = sfGuardUserPeer::retrieveByPK($this->sf_guard_user_id, $con);
|
||||
$obj->addsfGuardUsers($this);
|
||||
*/
|
||||
}
|
||||
return $this->asfGuardUser;
|
||||
}
|
||||
|
||||
|
||||
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, 'DiscountUser.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseDiscountUser:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseDiscountUser::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseDiscountUser
|
||||
846
plugins/stDiscountPlugin/lib/model/om/BaseDiscountUserPeer.php
Normal file
846
plugins/stDiscountPlugin/lib/model/om/BaseDiscountUserPeer.php
Normal file
@@ -0,0 +1,846 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'st_discount_user' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseDiscountUserPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'st_discount_user';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.stDiscountPlugin.lib.model.DiscountUser';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 3;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the SF_GUARD_USER_ID field */
|
||||
const SF_GUARD_USER_ID = 'st_discount_user.SF_GUARD_USER_ID';
|
||||
|
||||
/** the column name for the DISCOUNT field */
|
||||
const DISCOUNT = 'st_discount_user.DISCOUNT';
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'st_discount_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 ('SfGuardUserId', 'Discount', 'Id', ),
|
||||
BasePeer::TYPE_COLNAME => array (DiscountUserPeer::SF_GUARD_USER_ID, DiscountUserPeer::DISCOUNT, DiscountUserPeer::ID, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('sf_guard_user_id', 'discount', 'id', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('SfGuardUserId' => 0, 'Discount' => 1, 'Id' => 2, ),
|
||||
BasePeer::TYPE_COLNAME => array (DiscountUserPeer::SF_GUARD_USER_ID => 0, DiscountUserPeer::DISCOUNT => 1, DiscountUserPeer::ID => 2, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('sf_guard_user_id' => 0, 'discount' => 1, 'id' => 2, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.stDiscountPlugin.lib.model.map.DiscountUserMapBuilder');
|
||||
}
|
||||
/**
|
||||
* 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 = DiscountUserPeer::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. DiscountUserPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(DiscountUserPeer::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(DiscountUserPeer::SF_GUARD_USER_ID);
|
||||
|
||||
$criteria->addSelectColumn(DiscountUserPeer::DISCOUNT);
|
||||
|
||||
$criteria->addSelectColumn(DiscountUserPeer::ID);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('DiscountUserPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'DiscountUserPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(st_discount_user.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT st_discount_user.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(DiscountUserPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(DiscountUserPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = DiscountUserPeer::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 DiscountUser
|
||||
* @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 = DiscountUserPeer::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 DiscountUser[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return DiscountUserPeer::populateObjects(DiscountUserPeer::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;
|
||||
DiscountUserPeer::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 = DiscountUserPeer::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 sfGuardUser 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 doCountJoinsfGuardUser(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(DiscountUserPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(DiscountUserPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(DiscountUserPeer::SF_GUARD_USER_ID, sfGuardUserPeer::ID);
|
||||
|
||||
$rs = DiscountUserPeer::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 DiscountUser objects pre-filled with their sfGuardUser objects.
|
||||
*
|
||||
* @return DiscountUser[] Array of DiscountUser objects.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinsfGuardUser(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);
|
||||
}
|
||||
|
||||
DiscountUserPeer::addSelectColumns($c);
|
||||
|
||||
sfGuardUserPeer::addSelectColumns($c);
|
||||
|
||||
$c->addJoin(DiscountUserPeer::SF_GUARD_USER_ID, sfGuardUserPeer::ID);
|
||||
$rs = DiscountUserPeer::doSelectRs($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$obj1 = new DiscountUser();
|
||||
$startcol = $obj1->hydrate($rs);
|
||||
if ($obj1->getSfGuardUserId())
|
||||
{
|
||||
|
||||
$obj2 = new sfGuardUser();
|
||||
$obj2->hydrate($rs, $startcol);
|
||||
$obj2->addDiscountUser($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(DiscountUserPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(DiscountUserPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(DiscountUserPeer::SF_GUARD_USER_ID, sfGuardUserPeer::ID);
|
||||
|
||||
$rs = DiscountUserPeer::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 DiscountUser objects pre-filled with all related objects.
|
||||
*
|
||||
* @return DiscountUser[]
|
||||
* @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);
|
||||
}
|
||||
|
||||
DiscountUserPeer::addSelectColumns($c);
|
||||
$startcol2 = (DiscountUserPeer::NUM_COLUMNS - DiscountUserPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
|
||||
|
||||
sfGuardUserPeer::addSelectColumns($c);
|
||||
$startcol3 = $startcol2 + sfGuardUserPeer::NUM_COLUMNS;
|
||||
|
||||
$c->addJoin(DiscountUserPeer::SF_GUARD_USER_ID, sfGuardUserPeer::ID);
|
||||
|
||||
$rs = BasePeer::doSelect($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$omClass = DiscountUserPeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj1 = new $cls();
|
||||
$obj1->hydrate($rs);
|
||||
|
||||
|
||||
// Add objects for joined sfGuardUser rows
|
||||
|
||||
$omClass = sfGuardUserPeer::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->getsfGuardUser(); // CHECKME
|
||||
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
|
||||
$newObject = false;
|
||||
$temp_obj2->addDiscountUser($obj1); // CHECKME
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newObject) {
|
||||
$obj2->initDiscountUsers();
|
||||
$obj2->addDiscountUser($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 DiscountUserPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a DiscountUser or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or DiscountUser 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('BaseDiscountUserPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseDiscountUserPeer', $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 DiscountUser object
|
||||
}
|
||||
|
||||
$criteria->remove(DiscountUserPeer::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('BaseDiscountUserPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseDiscountUserPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a DiscountUser or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or DiscountUser 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('BaseDiscountUserPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseDiscountUserPeer', $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(DiscountUserPeer::ID);
|
||||
$selectCriteria->add(DiscountUserPeer::ID, $criteria->remove(DiscountUserPeer::ID), $comparison);
|
||||
|
||||
} else { // $values is DiscountUser 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('BaseDiscountUserPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseDiscountUserPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the st_discount_user 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(DiscountUserPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a DiscountUser or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or DiscountUser 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(DiscountUserPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof DiscountUser) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(DiscountUserPeer::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 DiscountUser 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 DiscountUser $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(DiscountUser $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(DiscountUserPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(DiscountUserPeer::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(DiscountUserPeer::DATABASE_NAME, DiscountUserPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = DiscountUserPeer::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 DiscountUser
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(DiscountUserPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(DiscountUserPeer::ID, $pk);
|
||||
|
||||
|
||||
$v = DiscountUserPeer::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 DiscountUser[]
|
||||
*/
|
||||
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(DiscountUserPeer::ID, $pks, Criteria::IN);
|
||||
$objs = DiscountUserPeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BaseDiscountUserPeer
|
||||
|
||||
// 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 {
|
||||
BaseDiscountUserPeer::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.stDiscountPlugin.lib.model.map.DiscountUserMapBuilder');
|
||||
}
|
||||
846
plugins/stDiscountPlugin/lib/model/om/BaseUserHasDiscount.php
Normal file
846
plugins/stDiscountPlugin/lib/model/om/BaseUserHasDiscount.php
Normal file
@@ -0,0 +1,846 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'st_user_has_discount' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stDiscountPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseUserHasDiscount extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
protected static $dispatcher = null;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the sf_guard_user_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $sf_guard_user_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the discount_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $discount_id;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the auto field.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $auto = false;
|
||||
|
||||
/**
|
||||
* @var sfGuardUser
|
||||
*/
|
||||
protected $asfGuardUser;
|
||||
|
||||
/**
|
||||
* @var Discount
|
||||
*/
|
||||
protected $aDiscount;
|
||||
|
||||
/**
|
||||
* 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 [sf_guard_user_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSfGuardUserId()
|
||||
{
|
||||
|
||||
return $this->sf_guard_user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [discount_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDiscountId()
|
||||
{
|
||||
|
||||
return $this->discount_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [auto] column value.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getAuto()
|
||||
{
|
||||
|
||||
return $this->auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [sf_guard_user_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setSfGuardUserId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->sf_guard_user_id !== $v) {
|
||||
$this->sf_guard_user_id = $v;
|
||||
$this->modifiedColumns[] = UserHasDiscountPeer::SF_GUARD_USER_ID;
|
||||
}
|
||||
|
||||
if ($this->asfGuardUser !== null && $this->asfGuardUser->getId() !== $v) {
|
||||
$this->asfGuardUser = null;
|
||||
}
|
||||
|
||||
} // setSfGuardUserId()
|
||||
|
||||
/**
|
||||
* Set the value of [discount_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setDiscountId($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->discount_id !== $v) {
|
||||
$this->discount_id = $v;
|
||||
$this->modifiedColumns[] = UserHasDiscountPeer::DISCOUNT_ID;
|
||||
}
|
||||
|
||||
if ($this->aDiscount !== null && $this->aDiscount->getId() !== $v) {
|
||||
$this->aDiscount = null;
|
||||
}
|
||||
|
||||
} // setDiscountId()
|
||||
|
||||
/**
|
||||
* Set the value of [auto] column.
|
||||
*
|
||||
* @param boolean $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setAuto($v)
|
||||
{
|
||||
|
||||
if ($v !== null && !is_bool($v)) {
|
||||
$v = (bool) $v;
|
||||
}
|
||||
|
||||
if ($this->auto !== $v || $v === false) {
|
||||
$this->auto = $v;
|
||||
$this->modifiedColumns[] = UserHasDiscountPeer::AUTO;
|
||||
}
|
||||
|
||||
} // setAuto()
|
||||
|
||||
/**
|
||||
* 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('UserHasDiscount.preHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'UserHasDiscount.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
|
||||
$startcol = $event['startcol'];
|
||||
}
|
||||
|
||||
$this->sf_guard_user_id = $rs->getInt($startcol + 0);
|
||||
|
||||
$this->discount_id = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->auto = $rs->getBoolean($startcol + 2);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
if ($this->getDispatcher()->getListeners('UserHasDiscount.postHydrate')) {
|
||||
$event = $this->getDispatcher()->notify(new sfEvent($this, 'UserHasDiscount.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 3)));
|
||||
return $event['startcol'];
|
||||
}
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 3; // 3 = UserHasDiscountPeer::NUM_COLUMNS - UserHasDiscountPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating UserHasDiscount 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('UserHasDiscount.preDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'UserHasDiscount.preDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseUserHasDiscount:delete:pre'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseUserHasDiscount:delete:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, $this, $con);
|
||||
if ($ret)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(UserHasDiscountPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
UserHasDiscountPeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($this->getDispatcher()->getListeners('UserHasDiscount.postDelete')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'UserHasDiscount.postDelete', array('con' => $con)));
|
||||
}
|
||||
|
||||
if (sfMixer::hasCallables('BaseUserHasDiscount:delete:post'))
|
||||
{
|
||||
foreach (sfMixer::getCallables('BaseUserHasDiscount: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('UserHasDiscount.preSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'UserHasDiscount.preSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseUserHasDiscount:save:pre') as $callable)
|
||||
{
|
||||
$affectedRows = call_user_func($callable, $this, $con);
|
||||
if (is_int($affectedRows))
|
||||
{
|
||||
return $affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(UserHasDiscountPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
|
||||
if (!$this->alreadyInSave) {
|
||||
if ($this->getDispatcher()->getListeners('UserHasDiscount.postSave')) {
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'UserHasDiscount.postSave', array('con' => $con)));
|
||||
}
|
||||
|
||||
foreach (sfMixer::getCallables('BaseUserHasDiscount: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->asfGuardUser !== null) {
|
||||
if ($this->asfGuardUser->isModified()) {
|
||||
$affectedRows += $this->asfGuardUser->save($con);
|
||||
}
|
||||
$this->setsfGuardUser($this->asfGuardUser);
|
||||
}
|
||||
|
||||
if ($this->aDiscount !== null) {
|
||||
if ($this->aDiscount->isModified()) {
|
||||
$affectedRows += $this->aDiscount->save($con);
|
||||
}
|
||||
$this->setDiscount($this->aDiscount);
|
||||
}
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = UserHasDiscountPeer::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 += UserHasDiscountPeer::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->asfGuardUser !== null) {
|
||||
if (!$this->asfGuardUser->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->asfGuardUser->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->aDiscount !== null) {
|
||||
if (!$this->aDiscount->validate($columns)) {
|
||||
$failureMap = array_merge($failureMap, $this->aDiscount->getValidationFailures());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (($retval = UserHasDiscountPeer::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 = UserHasDiscountPeer::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->getSfGuardUserId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getDiscountId();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getAuto();
|
||||
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 = UserHasDiscountPeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getSfGuardUserId(),
|
||||
$keys[1] => $this->getDiscountId(),
|
||||
$keys[2] => $this->getAuto(),
|
||||
);
|
||||
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 = UserHasDiscountPeer::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->setSfGuardUserId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setDiscountId($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setAuto($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 = UserHasDiscountPeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setSfGuardUserId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setDiscountId($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setAuto($arr[$keys[2]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(UserHasDiscountPeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(UserHasDiscountPeer::SF_GUARD_USER_ID)) $criteria->add(UserHasDiscountPeer::SF_GUARD_USER_ID, $this->sf_guard_user_id);
|
||||
if ($this->isColumnModified(UserHasDiscountPeer::DISCOUNT_ID)) $criteria->add(UserHasDiscountPeer::DISCOUNT_ID, $this->discount_id);
|
||||
if ($this->isColumnModified(UserHasDiscountPeer::AUTO)) $criteria->add(UserHasDiscountPeer::AUTO, $this->auto);
|
||||
|
||||
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(UserHasDiscountPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(UserHasDiscountPeer::SF_GUARD_USER_ID, $this->sf_guard_user_id);
|
||||
$criteria->add(UserHasDiscountPeer::DISCOUNT_ID, $this->discount_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->getSfGuardUserId(), $this->getDiscountId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [composite] primary key fields
|
||||
*
|
||||
* @param string $keyType
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
return array(UserHasDiscountPeer::translateFieldName('sf_guard_user_id', BasePeer::TYPE_FIELDNAME, $keyType), UserHasDiscountPeer::translateFieldName('discount_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->setSfGuardUserId($keys[0]);
|
||||
|
||||
$this->setDiscountId($keys[1]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of UserHasDiscount (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->setAuto($this->auto);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setSfGuardUserId(NULL); // this is a pkey column, so set to default value
|
||||
|
||||
$copyObj->setDiscountId(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 UserHasDiscount 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 'UserHasDiscountPeer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a sfGuardUser object.
|
||||
*
|
||||
* @param sfGuardUser $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setsfGuardUser($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setSfGuardUserId(NULL);
|
||||
} else {
|
||||
$this->setSfGuardUserId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->asfGuardUser = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated sfGuardUser object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return sfGuardUser The associated sfGuardUser object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getsfGuardUser($con = null)
|
||||
{
|
||||
if ($this->asfGuardUser === null && ($this->sf_guard_user_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->asfGuardUser = sfGuardUserPeer::retrieveByPK($this->sf_guard_user_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 = sfGuardUserPeer::retrieveByPK($this->sf_guard_user_id, $con);
|
||||
$obj->addsfGuardUsers($this);
|
||||
*/
|
||||
}
|
||||
return $this->asfGuardUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares an association between this object and a Discount object.
|
||||
*
|
||||
* @param Discount $v
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function setDiscount($v)
|
||||
{
|
||||
|
||||
|
||||
if ($v === null) {
|
||||
$this->setDiscountId(NULL);
|
||||
} else {
|
||||
$this->setDiscountId($v->getId());
|
||||
}
|
||||
|
||||
|
||||
$this->aDiscount = $v;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the associated Discount object
|
||||
*
|
||||
* @param Connection Optional Connection object.
|
||||
* @return Discount The associated Discount object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getDiscount($con = null)
|
||||
{
|
||||
if ($this->aDiscount === null && ($this->discount_id !== null)) {
|
||||
// include the related Peer class
|
||||
$this->aDiscount = DiscountPeer::retrieveByPK($this->discount_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 = DiscountPeer::retrieveByPK($this->discount_id, $con);
|
||||
$obj->addDiscounts($this);
|
||||
*/
|
||||
}
|
||||
return $this->aDiscount;
|
||||
}
|
||||
|
||||
|
||||
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, 'UserHasDiscount.' . $method, array('arguments' => $arguments, 'method' => $method)));
|
||||
|
||||
if ($event->isProcessed())
|
||||
{
|
||||
return $event->getReturnValue();
|
||||
}
|
||||
|
||||
if (!$callable = sfMixer::getCallable('BaseUserHasDiscount:'.$method))
|
||||
{
|
||||
throw new sfException(sprintf('Call to undefined method BaseUserHasDiscount::%s', $method));
|
||||
}
|
||||
|
||||
array_unshift($arguments, $this);
|
||||
|
||||
return call_user_func_array($callable, $arguments);
|
||||
}
|
||||
|
||||
} // BaseUserHasDiscount
|
||||
1175
plugins/stDiscountPlugin/lib/model/om/BaseUserHasDiscountPeer.php
Normal file
1175
plugins/stDiscountPlugin/lib/model/om/BaseUserHasDiscountPeer.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user