Free shipping restricitions based on Countries and Shipping module
This commit is contained in:
@@ -29,6 +29,10 @@ use Thelia\Model\Coupon as ChildCoupon;
|
||||
use Thelia\Model\CouponCountry as ChildCouponCountry;
|
||||
use Thelia\Model\CouponCountryQuery as ChildCouponCountryQuery;
|
||||
use Thelia\Model\CouponQuery as ChildCouponQuery;
|
||||
use Thelia\Model\OrderCoupon as ChildOrderCoupon;
|
||||
use Thelia\Model\OrderCouponCountry as ChildOrderCouponCountry;
|
||||
use Thelia\Model\OrderCouponCountryQuery as ChildOrderCouponCountryQuery;
|
||||
use Thelia\Model\OrderCouponQuery as ChildOrderCouponQuery;
|
||||
use Thelia\Model\TaxRuleCountry as ChildTaxRuleCountry;
|
||||
use Thelia\Model\TaxRuleCountryQuery as ChildTaxRuleCountryQuery;
|
||||
use Thelia\Model\Map\CountryTableMap;
|
||||
@@ -146,6 +150,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
protected $collCouponCountries;
|
||||
protected $collCouponCountriesPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildOrderCouponCountry[] Collection to store aggregation of ChildOrderCouponCountry objects.
|
||||
*/
|
||||
protected $collOrderCouponCountries;
|
||||
protected $collOrderCouponCountriesPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildCountryI18n[] Collection to store aggregation of ChildCountryI18n objects.
|
||||
*/
|
||||
@@ -157,6 +167,11 @@ abstract class Country implements ActiveRecordInterface
|
||||
*/
|
||||
protected $collCoupons;
|
||||
|
||||
/**
|
||||
* @var ChildOrderCoupon[] Collection to store aggregation of ChildOrderCoupon objects.
|
||||
*/
|
||||
protected $collOrderCoupons;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
@@ -185,6 +200,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
*/
|
||||
protected $couponsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $orderCouponsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
@@ -203,6 +224,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
*/
|
||||
protected $couponCountriesScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $orderCouponCountriesScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
@@ -955,9 +982,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
|
||||
$this->collCouponCountries = null;
|
||||
|
||||
$this->collOrderCouponCountries = null;
|
||||
|
||||
$this->collCountryI18ns = null;
|
||||
|
||||
$this->collCoupons = null;
|
||||
$this->collOrderCoupons = null;
|
||||
} // if (deep)
|
||||
}
|
||||
|
||||
@@ -1130,6 +1160,33 @@ abstract class Country implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->orderCouponsScheduledForDeletion !== null) {
|
||||
if (!$this->orderCouponsScheduledForDeletion->isEmpty()) {
|
||||
$pks = array();
|
||||
$pk = $this->getPrimaryKey();
|
||||
foreach ($this->orderCouponsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
|
||||
$pks[] = array($pk, $remotePk);
|
||||
}
|
||||
|
||||
OrderCouponCountryQuery::create()
|
||||
->filterByPrimaryKeys($pks)
|
||||
->delete($con);
|
||||
$this->orderCouponsScheduledForDeletion = null;
|
||||
}
|
||||
|
||||
foreach ($this->getOrderCoupons() as $orderCoupon) {
|
||||
if ($orderCoupon->isModified()) {
|
||||
$orderCoupon->save($con);
|
||||
}
|
||||
}
|
||||
} elseif ($this->collOrderCoupons) {
|
||||
foreach ($this->collOrderCoupons as $orderCoupon) {
|
||||
if ($orderCoupon->isModified()) {
|
||||
$orderCoupon->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->taxRuleCountriesScheduledForDeletion !== null) {
|
||||
if (!$this->taxRuleCountriesScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\TaxRuleCountryQuery::create()
|
||||
@@ -1181,6 +1238,23 @@ abstract class Country implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->orderCouponCountriesScheduledForDeletion !== null) {
|
||||
if (!$this->orderCouponCountriesScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\OrderCouponCountryQuery::create()
|
||||
->filterByPrimaryKeys($this->orderCouponCountriesScheduledForDeletion->getPrimaryKeys(false))
|
||||
->delete($con);
|
||||
$this->orderCouponCountriesScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->collOrderCouponCountries !== null) {
|
||||
foreach ($this->collOrderCouponCountries as $referrerFK) {
|
||||
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
|
||||
$affectedRows += $referrerFK->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->countryI18nsScheduledForDeletion !== null) {
|
||||
if (!$this->countryI18nsScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\CountryI18nQuery::create()
|
||||
@@ -1435,6 +1509,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
if (null !== $this->collCouponCountries) {
|
||||
$result['CouponCountries'] = $this->collCouponCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collOrderCouponCountries) {
|
||||
$result['OrderCouponCountries'] = $this->collOrderCouponCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collCountryI18ns) {
|
||||
$result['CountryI18ns'] = $this->collCountryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
@@ -1647,6 +1724,12 @@ abstract class Country implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getOrderCouponCountries() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addOrderCouponCountry($relObj->copy($deepCopy));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getCountryI18ns() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addCountryI18n($relObj->copy($deepCopy));
|
||||
@@ -1754,6 +1837,9 @@ abstract class Country implements ActiveRecordInterface
|
||||
if ('CouponCountry' == $relationName) {
|
||||
return $this->initCouponCountries();
|
||||
}
|
||||
if ('OrderCouponCountry' == $relationName) {
|
||||
return $this->initOrderCouponCountries();
|
||||
}
|
||||
if ('CountryI18n' == $relationName) {
|
||||
return $this->initCountryI18ns();
|
||||
}
|
||||
@@ -2544,6 +2630,252 @@ abstract class Country implements ActiveRecordInterface
|
||||
return $this->getCouponCountries($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collOrderCouponCountries collection
|
||||
*
|
||||
* This does not modify the database; however, it will remove any associated objects, causing
|
||||
* them to be refetched by subsequent calls to accessor method.
|
||||
*
|
||||
* @return void
|
||||
* @see addOrderCouponCountries()
|
||||
*/
|
||||
public function clearOrderCouponCountries()
|
||||
{
|
||||
$this->collOrderCouponCountries = null; // important to set this to NULL since that means it is uninitialized
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset is the collOrderCouponCountries collection loaded partially.
|
||||
*/
|
||||
public function resetPartialOrderCouponCountries($v = true)
|
||||
{
|
||||
$this->collOrderCouponCountriesPartial = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collOrderCouponCountries collection.
|
||||
*
|
||||
* By default this just sets the collOrderCouponCountries collection to an empty array (like clearcollOrderCouponCountries());
|
||||
* however, you may wish to override this method in your stub class to provide setting appropriate
|
||||
* to your application -- for example, setting the initial array to the values stored in database.
|
||||
*
|
||||
* @param boolean $overrideExisting If set to true, the method call initializes
|
||||
* the collection even if it is not empty
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initOrderCouponCountries($overrideExisting = true)
|
||||
{
|
||||
if (null !== $this->collOrderCouponCountries && !$overrideExisting) {
|
||||
return;
|
||||
}
|
||||
$this->collOrderCouponCountries = new ObjectCollection();
|
||||
$this->collOrderCouponCountries->setModel('\Thelia\Model\OrderCouponCountry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of ChildOrderCouponCountry objects which contain a foreign key that references this object.
|
||||
*
|
||||
* If the $criteria is not null, it is used to always fetch the results from the database.
|
||||
* Otherwise the results are fetched from the database the first time, then cached.
|
||||
* Next time the same method is called without $criteria, the cached collection is returned.
|
||||
* If this ChildCountry is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @return Collection|ChildOrderCouponCountry[] List of ChildOrderCouponCountry objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getOrderCouponCountries($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collOrderCouponCountriesPartial && !$this->isNew();
|
||||
if (null === $this->collOrderCouponCountries || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collOrderCouponCountries) {
|
||||
// return empty collection
|
||||
$this->initOrderCouponCountries();
|
||||
} else {
|
||||
$collOrderCouponCountries = ChildOrderCouponCountryQuery::create(null, $criteria)
|
||||
->filterByCountry($this)
|
||||
->find($con);
|
||||
|
||||
if (null !== $criteria) {
|
||||
if (false !== $this->collOrderCouponCountriesPartial && count($collOrderCouponCountries)) {
|
||||
$this->initOrderCouponCountries(false);
|
||||
|
||||
foreach ($collOrderCouponCountries as $obj) {
|
||||
if (false == $this->collOrderCouponCountries->contains($obj)) {
|
||||
$this->collOrderCouponCountries->append($obj);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collOrderCouponCountriesPartial = true;
|
||||
}
|
||||
|
||||
reset($collOrderCouponCountries);
|
||||
|
||||
return $collOrderCouponCountries;
|
||||
}
|
||||
|
||||
if ($partial && $this->collOrderCouponCountries) {
|
||||
foreach ($this->collOrderCouponCountries as $obj) {
|
||||
if ($obj->isNew()) {
|
||||
$collOrderCouponCountries[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->collOrderCouponCountries = $collOrderCouponCountries;
|
||||
$this->collOrderCouponCountriesPartial = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collOrderCouponCountries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of OrderCouponCountry objects related by a one-to-many relationship
|
||||
* to the current object.
|
||||
* It will also schedule objects for deletion based on a diff between old objects (aka persisted)
|
||||
* and new objects from the given Propel collection.
|
||||
*
|
||||
* @param Collection $orderCouponCountries A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildCountry The current object (for fluent API support)
|
||||
*/
|
||||
public function setOrderCouponCountries(Collection $orderCouponCountries, ConnectionInterface $con = null)
|
||||
{
|
||||
$orderCouponCountriesToDelete = $this->getOrderCouponCountries(new Criteria(), $con)->diff($orderCouponCountries);
|
||||
|
||||
|
||||
//since at least one column in the foreign key is at the same time a PK
|
||||
//we can not just set a PK to NULL in the lines below. We have to store
|
||||
//a backup of all values, so we are able to manipulate these items based on the onDelete value later.
|
||||
$this->orderCouponCountriesScheduledForDeletion = clone $orderCouponCountriesToDelete;
|
||||
|
||||
foreach ($orderCouponCountriesToDelete as $orderCouponCountryRemoved) {
|
||||
$orderCouponCountryRemoved->setCountry(null);
|
||||
}
|
||||
|
||||
$this->collOrderCouponCountries = null;
|
||||
foreach ($orderCouponCountries as $orderCouponCountry) {
|
||||
$this->addOrderCouponCountry($orderCouponCountry);
|
||||
}
|
||||
|
||||
$this->collOrderCouponCountries = $orderCouponCountries;
|
||||
$this->collOrderCouponCountriesPartial = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of related OrderCouponCountry objects.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct
|
||||
* @param ConnectionInterface $con
|
||||
* @return int Count of related OrderCouponCountry objects.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function countOrderCouponCountries(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collOrderCouponCountriesPartial && !$this->isNew();
|
||||
if (null === $this->collOrderCouponCountries || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collOrderCouponCountries) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($partial && !$criteria) {
|
||||
return count($this->getOrderCouponCountries());
|
||||
}
|
||||
|
||||
$query = ChildOrderCouponCountryQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByCountry($this)
|
||||
->count($con);
|
||||
}
|
||||
|
||||
return count($this->collOrderCouponCountries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to associate a ChildOrderCouponCountry object to this object
|
||||
* through the ChildOrderCouponCountry foreign key attribute.
|
||||
*
|
||||
* @param ChildOrderCouponCountry $l ChildOrderCouponCountry
|
||||
* @return \Thelia\Model\Country The current object (for fluent API support)
|
||||
*/
|
||||
public function addOrderCouponCountry(ChildOrderCouponCountry $l)
|
||||
{
|
||||
if ($this->collOrderCouponCountries === null) {
|
||||
$this->initOrderCouponCountries();
|
||||
$this->collOrderCouponCountriesPartial = true;
|
||||
}
|
||||
|
||||
if (!in_array($l, $this->collOrderCouponCountries->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddOrderCouponCountry($l);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderCouponCountry $orderCouponCountry The orderCouponCountry object to add.
|
||||
*/
|
||||
protected function doAddOrderCouponCountry($orderCouponCountry)
|
||||
{
|
||||
$this->collOrderCouponCountries[]= $orderCouponCountry;
|
||||
$orderCouponCountry->setCountry($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderCouponCountry $orderCouponCountry The orderCouponCountry object to remove.
|
||||
* @return ChildCountry The current object (for fluent API support)
|
||||
*/
|
||||
public function removeOrderCouponCountry($orderCouponCountry)
|
||||
{
|
||||
if ($this->getOrderCouponCountries()->contains($orderCouponCountry)) {
|
||||
$this->collOrderCouponCountries->remove($this->collOrderCouponCountries->search($orderCouponCountry));
|
||||
if (null === $this->orderCouponCountriesScheduledForDeletion) {
|
||||
$this->orderCouponCountriesScheduledForDeletion = clone $this->collOrderCouponCountries;
|
||||
$this->orderCouponCountriesScheduledForDeletion->clear();
|
||||
}
|
||||
$this->orderCouponCountriesScheduledForDeletion[]= clone $orderCouponCountry;
|
||||
$orderCouponCountry->setCountry(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Country is new, it will return
|
||||
* an empty collection; or if this Country has previously
|
||||
* been saved, it will retrieve related OrderCouponCountries from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Country.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildOrderCouponCountry[] List of ChildOrderCouponCountry objects
|
||||
*/
|
||||
public function getOrderCouponCountriesJoinOrderCoupon($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildOrderCouponCountryQuery::create(null, $criteria);
|
||||
$query->joinWith('OrderCoupon', $joinBehavior);
|
||||
|
||||
return $this->getOrderCouponCountries($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collCountryI18ns collection
|
||||
*
|
||||
@@ -2952,6 +3284,189 @@ abstract class Country implements ActiveRecordInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collOrderCoupons collection
|
||||
*
|
||||
* This does not modify the database; however, it will remove any associated objects, causing
|
||||
* them to be refetched by subsequent calls to accessor method.
|
||||
*
|
||||
* @return void
|
||||
* @see addOrderCoupons()
|
||||
*/
|
||||
public function clearOrderCoupons()
|
||||
{
|
||||
$this->collOrderCoupons = null; // important to set this to NULL since that means it is uninitialized
|
||||
$this->collOrderCouponsPartial = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collOrderCoupons collection.
|
||||
*
|
||||
* By default this just sets the collOrderCoupons collection to an empty collection (like clearOrderCoupons());
|
||||
* however, you may wish to override this method in your stub class to provide setting appropriate
|
||||
* to your application -- for example, setting the initial array to the values stored in database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initOrderCoupons()
|
||||
{
|
||||
$this->collOrderCoupons = new ObjectCollection();
|
||||
$this->collOrderCoupons->setModel('\Thelia\Model\OrderCoupon');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a collection of ChildOrderCoupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the order_coupon_country cross-reference table.
|
||||
*
|
||||
* If the $criteria is not null, it is used to always fetch the results from the database.
|
||||
* Otherwise the results are fetched from the database the first time, then cached.
|
||||
* Next time the same method is called without $criteria, the cached collection is returned.
|
||||
* If this ChildCountry is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria Optional query object to filter the query
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
*
|
||||
* @return ObjectCollection|ChildOrderCoupon[] List of ChildOrderCoupon objects
|
||||
*/
|
||||
public function getOrderCoupons($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $this->collOrderCoupons || null !== $criteria) {
|
||||
if ($this->isNew() && null === $this->collOrderCoupons) {
|
||||
// return empty collection
|
||||
$this->initOrderCoupons();
|
||||
} else {
|
||||
$collOrderCoupons = ChildOrderCouponQuery::create(null, $criteria)
|
||||
->filterByCountry($this)
|
||||
->find($con);
|
||||
if (null !== $criteria) {
|
||||
return $collOrderCoupons;
|
||||
}
|
||||
$this->collOrderCoupons = $collOrderCoupons;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collOrderCoupons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of OrderCoupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the order_coupon_country cross-reference table.
|
||||
* It will also schedule objects for deletion based on a diff between old objects (aka persisted)
|
||||
* and new objects from the given Propel collection.
|
||||
*
|
||||
* @param Collection $orderCoupons A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildCountry The current object (for fluent API support)
|
||||
*/
|
||||
public function setOrderCoupons(Collection $orderCoupons, ConnectionInterface $con = null)
|
||||
{
|
||||
$this->clearOrderCoupons();
|
||||
$currentOrderCoupons = $this->getOrderCoupons();
|
||||
|
||||
$this->orderCouponsScheduledForDeletion = $currentOrderCoupons->diff($orderCoupons);
|
||||
|
||||
foreach ($orderCoupons as $orderCoupon) {
|
||||
if (!$currentOrderCoupons->contains($orderCoupon)) {
|
||||
$this->doAddOrderCoupon($orderCoupon);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collOrderCoupons = $orderCoupons;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of ChildOrderCoupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the order_coupon_country cross-reference table.
|
||||
*
|
||||
* @param Criteria $criteria Optional query object to filter the query
|
||||
* @param boolean $distinct Set to true to force count distinct
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
*
|
||||
* @return int the number of related ChildOrderCoupon objects
|
||||
*/
|
||||
public function countOrderCoupons($criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $this->collOrderCoupons || null !== $criteria) {
|
||||
if ($this->isNew() && null === $this->collOrderCoupons) {
|
||||
return 0;
|
||||
} else {
|
||||
$query = ChildOrderCouponQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByCountry($this)
|
||||
->count($con);
|
||||
}
|
||||
} else {
|
||||
return count($this->collOrderCoupons);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate a ChildOrderCoupon object to this object
|
||||
* through the order_coupon_country cross reference table.
|
||||
*
|
||||
* @param ChildOrderCoupon $orderCoupon The ChildOrderCouponCountry object to relate
|
||||
* @return ChildCountry The current object (for fluent API support)
|
||||
*/
|
||||
public function addOrderCoupon(ChildOrderCoupon $orderCoupon)
|
||||
{
|
||||
if ($this->collOrderCoupons === null) {
|
||||
$this->initOrderCoupons();
|
||||
}
|
||||
|
||||
if (!$this->collOrderCoupons->contains($orderCoupon)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddOrderCoupon($orderCoupon);
|
||||
$this->collOrderCoupons[] = $orderCoupon;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderCoupon $orderCoupon The orderCoupon object to add.
|
||||
*/
|
||||
protected function doAddOrderCoupon($orderCoupon)
|
||||
{
|
||||
$orderCouponCountry = new ChildOrderCouponCountry();
|
||||
$orderCouponCountry->setOrderCoupon($orderCoupon);
|
||||
$this->addOrderCouponCountry($orderCouponCountry);
|
||||
// set the back reference to this object directly as using provided method either results
|
||||
// in endless loop or in multiple relations
|
||||
if (!$orderCoupon->getCountries()->contains($this)) {
|
||||
$foreignCollection = $orderCoupon->getCountries();
|
||||
$foreignCollection[] = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a ChildOrderCoupon object to this object
|
||||
* through the order_coupon_country cross reference table.
|
||||
*
|
||||
* @param ChildOrderCoupon $orderCoupon The ChildOrderCouponCountry object to relate
|
||||
* @return ChildCountry The current object (for fluent API support)
|
||||
*/
|
||||
public function removeOrderCoupon(ChildOrderCoupon $orderCoupon)
|
||||
{
|
||||
if ($this->getOrderCoupons()->contains($orderCoupon)) {
|
||||
$this->collOrderCoupons->remove($this->collOrderCoupons->search($orderCoupon));
|
||||
|
||||
if (null === $this->orderCouponsScheduledForDeletion) {
|
||||
$this->orderCouponsScheduledForDeletion = clone $this->collOrderCoupons;
|
||||
$this->orderCouponsScheduledForDeletion->clear();
|
||||
}
|
||||
|
||||
$this->orderCouponsScheduledForDeletion[] = $orderCoupon;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current object and sets all attributes to their default values
|
||||
*/
|
||||
@@ -3001,6 +3516,11 @@ abstract class Country implements ActiveRecordInterface
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collOrderCouponCountries) {
|
||||
foreach ($this->collOrderCouponCountries as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collCountryI18ns) {
|
||||
foreach ($this->collCountryI18ns as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
@@ -3011,6 +3531,11 @@ abstract class Country implements ActiveRecordInterface
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collOrderCoupons) {
|
||||
foreach ($this->collOrderCoupons as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
} // if ($deep)
|
||||
|
||||
// i18n behavior
|
||||
@@ -3020,8 +3545,10 @@ abstract class Country implements ActiveRecordInterface
|
||||
$this->collTaxRuleCountries = null;
|
||||
$this->collAddresses = null;
|
||||
$this->collCouponCountries = null;
|
||||
$this->collOrderCouponCountries = null;
|
||||
$this->collCountryI18ns = null;
|
||||
$this->collCoupons = null;
|
||||
$this->collOrderCoupons = null;
|
||||
$this->aArea = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,10 @@ use Thelia\Model\Map\CountryTableMap;
|
||||
* @method ChildCountryQuery rightJoinCouponCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponCountry relation
|
||||
* @method ChildCountryQuery innerJoinCouponCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponCountry relation
|
||||
*
|
||||
* @method ChildCountryQuery leftJoinOrderCouponCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderCouponCountry relation
|
||||
* @method ChildCountryQuery rightJoinOrderCouponCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderCouponCountry relation
|
||||
* @method ChildCountryQuery innerJoinOrderCouponCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderCouponCountry relation
|
||||
*
|
||||
* @method ChildCountryQuery leftJoinCountryI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the CountryI18n relation
|
||||
* @method ChildCountryQuery rightJoinCountryI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CountryI18n relation
|
||||
* @method ChildCountryQuery innerJoinCountryI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the CountryI18n relation
|
||||
@@ -884,6 +888,79 @@ abstract class CountryQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'CouponCountry', '\Thelia\Model\CouponCountryQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\OrderCouponCountry object
|
||||
*
|
||||
* @param \Thelia\Model\OrderCouponCountry|ObjectCollection $orderCouponCountry the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByOrderCouponCountry($orderCouponCountry, $comparison = null)
|
||||
{
|
||||
if ($orderCouponCountry instanceof \Thelia\Model\OrderCouponCountry) {
|
||||
return $this
|
||||
->addUsingAlias(CountryTableMap::ID, $orderCouponCountry->getCountryId(), $comparison);
|
||||
} elseif ($orderCouponCountry instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useOrderCouponCountryQuery()
|
||||
->filterByPrimaryKeys($orderCouponCountry->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByOrderCouponCountry() only accepts arguments of type \Thelia\Model\OrderCouponCountry or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the OrderCouponCountry relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinOrderCouponCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('OrderCouponCountry');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'OrderCouponCountry');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the OrderCouponCountry relation OrderCouponCountry object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\OrderCouponCountryQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useOrderCouponCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinOrderCouponCountry($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'OrderCouponCountry', '\Thelia\Model\OrderCouponCountryQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\CountryI18n object
|
||||
*
|
||||
@@ -974,6 +1051,23 @@ abstract class CountryQuery extends ModelCriteria
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related OrderCoupon object
|
||||
* using the order_coupon_country table as cross reference
|
||||
*
|
||||
* @param OrderCoupon $orderCoupon the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByOrderCoupon($orderCoupon, $comparison = Criteria::EQUAL)
|
||||
{
|
||||
return $this
|
||||
->useOrderCouponCountryQuery()
|
||||
->filterByOrderCoupon($orderCoupon, $comparison)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
|
||||
@@ -30,6 +30,10 @@ use Thelia\Model\ModuleImage as ChildModuleImage;
|
||||
use Thelia\Model\ModuleImageQuery as ChildModuleImageQuery;
|
||||
use Thelia\Model\ModuleQuery as ChildModuleQuery;
|
||||
use Thelia\Model\Order as ChildOrder;
|
||||
use Thelia\Model\OrderCoupon as ChildOrderCoupon;
|
||||
use Thelia\Model\OrderCouponModule as ChildOrderCouponModule;
|
||||
use Thelia\Model\OrderCouponModuleQuery as ChildOrderCouponModuleQuery;
|
||||
use Thelia\Model\OrderCouponQuery as ChildOrderCouponQuery;
|
||||
use Thelia\Model\OrderQuery as ChildOrderQuery;
|
||||
use Thelia\Model\ProfileModule as ChildProfileModule;
|
||||
use Thelia\Model\ProfileModuleQuery as ChildProfileModuleQuery;
|
||||
@@ -153,6 +157,12 @@ abstract class Module implements ActiveRecordInterface
|
||||
protected $collCouponModules;
|
||||
protected $collCouponModulesPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildOrderCouponModule[] Collection to store aggregation of ChildOrderCouponModule objects.
|
||||
*/
|
||||
protected $collOrderCouponModules;
|
||||
protected $collOrderCouponModulesPartial;
|
||||
|
||||
/**
|
||||
* @var ObjectCollection|ChildModuleI18n[] Collection to store aggregation of ChildModuleI18n objects.
|
||||
*/
|
||||
@@ -164,6 +174,11 @@ abstract class Module implements ActiveRecordInterface
|
||||
*/
|
||||
protected $collCoupons;
|
||||
|
||||
/**
|
||||
* @var ChildOrderCoupon[] Collection to store aggregation of ChildOrderCoupon objects.
|
||||
*/
|
||||
protected $collOrderCoupons;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
@@ -192,6 +207,12 @@ abstract class Module implements ActiveRecordInterface
|
||||
*/
|
||||
protected $couponsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $orderCouponsScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
@@ -228,6 +249,12 @@ abstract class Module implements ActiveRecordInterface
|
||||
*/
|
||||
protected $couponModulesScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
*/
|
||||
protected $orderCouponModulesScheduledForDeletion = null;
|
||||
|
||||
/**
|
||||
* An array of objects scheduled for deletion.
|
||||
* @var ObjectCollection
|
||||
@@ -913,9 +940,12 @@ abstract class Module implements ActiveRecordInterface
|
||||
|
||||
$this->collCouponModules = null;
|
||||
|
||||
$this->collOrderCouponModules = null;
|
||||
|
||||
$this->collModuleI18ns = null;
|
||||
|
||||
$this->collCoupons = null;
|
||||
$this->collOrderCoupons = null;
|
||||
} // if (deep)
|
||||
}
|
||||
|
||||
@@ -1076,6 +1106,33 @@ abstract class Module implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->orderCouponsScheduledForDeletion !== null) {
|
||||
if (!$this->orderCouponsScheduledForDeletion->isEmpty()) {
|
||||
$pks = array();
|
||||
$pk = $this->getPrimaryKey();
|
||||
foreach ($this->orderCouponsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
|
||||
$pks[] = array($remotePk, $pk);
|
||||
}
|
||||
|
||||
OrderCouponModuleQuery::create()
|
||||
->filterByPrimaryKeys($pks)
|
||||
->delete($con);
|
||||
$this->orderCouponsScheduledForDeletion = null;
|
||||
}
|
||||
|
||||
foreach ($this->getOrderCoupons() as $orderCoupon) {
|
||||
if ($orderCoupon->isModified()) {
|
||||
$orderCoupon->save($con);
|
||||
}
|
||||
}
|
||||
} elseif ($this->collOrderCoupons) {
|
||||
foreach ($this->collOrderCoupons as $orderCoupon) {
|
||||
if ($orderCoupon->isModified()) {
|
||||
$orderCoupon->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->ordersRelatedByPaymentModuleIdScheduledForDeletion !== null) {
|
||||
if (!$this->ordersRelatedByPaymentModuleIdScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\OrderQuery::create()
|
||||
@@ -1178,6 +1235,23 @@ abstract class Module implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->orderCouponModulesScheduledForDeletion !== null) {
|
||||
if (!$this->orderCouponModulesScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\OrderCouponModuleQuery::create()
|
||||
->filterByPrimaryKeys($this->orderCouponModulesScheduledForDeletion->getPrimaryKeys(false))
|
||||
->delete($con);
|
||||
$this->orderCouponModulesScheduledForDeletion = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->collOrderCouponModules !== null) {
|
||||
foreach ($this->collOrderCouponModules as $referrerFK) {
|
||||
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
|
||||
$affectedRows += $referrerFK->save($con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->moduleI18nsScheduledForDeletion !== null) {
|
||||
if (!$this->moduleI18nsScheduledForDeletion->isEmpty()) {
|
||||
\Thelia\Model\ModuleI18nQuery::create()
|
||||
@@ -1428,6 +1502,9 @@ abstract class Module implements ActiveRecordInterface
|
||||
if (null !== $this->collCouponModules) {
|
||||
$result['CouponModules'] = $this->collCouponModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collOrderCouponModules) {
|
||||
$result['OrderCouponModules'] = $this->collOrderCouponModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
if (null !== $this->collModuleI18ns) {
|
||||
$result['ModuleI18ns'] = $this->collModuleI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
|
||||
}
|
||||
@@ -1652,6 +1729,12 @@ abstract class Module implements ActiveRecordInterface
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getOrderCouponModules() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addOrderCouponModule($relObj->copy($deepCopy));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getModuleI18ns() as $relObj) {
|
||||
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||
$copyObj->addModuleI18n($relObj->copy($deepCopy));
|
||||
@@ -1717,6 +1800,9 @@ abstract class Module implements ActiveRecordInterface
|
||||
if ('CouponModule' == $relationName) {
|
||||
return $this->initCouponModules();
|
||||
}
|
||||
if ('OrderCouponModule' == $relationName) {
|
||||
return $this->initOrderCouponModules();
|
||||
}
|
||||
if ('ModuleI18n' == $relationName) {
|
||||
return $this->initModuleI18ns();
|
||||
}
|
||||
@@ -3411,6 +3497,252 @@ abstract class Module implements ActiveRecordInterface
|
||||
return $this->getCouponModules($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collOrderCouponModules collection
|
||||
*
|
||||
* This does not modify the database; however, it will remove any associated objects, causing
|
||||
* them to be refetched by subsequent calls to accessor method.
|
||||
*
|
||||
* @return void
|
||||
* @see addOrderCouponModules()
|
||||
*/
|
||||
public function clearOrderCouponModules()
|
||||
{
|
||||
$this->collOrderCouponModules = null; // important to set this to NULL since that means it is uninitialized
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset is the collOrderCouponModules collection loaded partially.
|
||||
*/
|
||||
public function resetPartialOrderCouponModules($v = true)
|
||||
{
|
||||
$this->collOrderCouponModulesPartial = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collOrderCouponModules collection.
|
||||
*
|
||||
* By default this just sets the collOrderCouponModules collection to an empty array (like clearcollOrderCouponModules());
|
||||
* however, you may wish to override this method in your stub class to provide setting appropriate
|
||||
* to your application -- for example, setting the initial array to the values stored in database.
|
||||
*
|
||||
* @param boolean $overrideExisting If set to true, the method call initializes
|
||||
* the collection even if it is not empty
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initOrderCouponModules($overrideExisting = true)
|
||||
{
|
||||
if (null !== $this->collOrderCouponModules && !$overrideExisting) {
|
||||
return;
|
||||
}
|
||||
$this->collOrderCouponModules = new ObjectCollection();
|
||||
$this->collOrderCouponModules->setModel('\Thelia\Model\OrderCouponModule');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of ChildOrderCouponModule objects which contain a foreign key that references this object.
|
||||
*
|
||||
* If the $criteria is not null, it is used to always fetch the results from the database.
|
||||
* Otherwise the results are fetched from the database the first time, then cached.
|
||||
* Next time the same method is called without $criteria, the cached collection is returned.
|
||||
* If this ChildModule is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @return Collection|ChildOrderCouponModule[] List of ChildOrderCouponModule objects
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function getOrderCouponModules($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collOrderCouponModulesPartial && !$this->isNew();
|
||||
if (null === $this->collOrderCouponModules || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collOrderCouponModules) {
|
||||
// return empty collection
|
||||
$this->initOrderCouponModules();
|
||||
} else {
|
||||
$collOrderCouponModules = ChildOrderCouponModuleQuery::create(null, $criteria)
|
||||
->filterByModule($this)
|
||||
->find($con);
|
||||
|
||||
if (null !== $criteria) {
|
||||
if (false !== $this->collOrderCouponModulesPartial && count($collOrderCouponModules)) {
|
||||
$this->initOrderCouponModules(false);
|
||||
|
||||
foreach ($collOrderCouponModules as $obj) {
|
||||
if (false == $this->collOrderCouponModules->contains($obj)) {
|
||||
$this->collOrderCouponModules->append($obj);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collOrderCouponModulesPartial = true;
|
||||
}
|
||||
|
||||
reset($collOrderCouponModules);
|
||||
|
||||
return $collOrderCouponModules;
|
||||
}
|
||||
|
||||
if ($partial && $this->collOrderCouponModules) {
|
||||
foreach ($this->collOrderCouponModules as $obj) {
|
||||
if ($obj->isNew()) {
|
||||
$collOrderCouponModules[] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->collOrderCouponModules = $collOrderCouponModules;
|
||||
$this->collOrderCouponModulesPartial = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collOrderCouponModules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of OrderCouponModule objects related by a one-to-many relationship
|
||||
* to the current object.
|
||||
* It will also schedule objects for deletion based on a diff between old objects (aka persisted)
|
||||
* and new objects from the given Propel collection.
|
||||
*
|
||||
* @param Collection $orderCouponModules A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildModule The current object (for fluent API support)
|
||||
*/
|
||||
public function setOrderCouponModules(Collection $orderCouponModules, ConnectionInterface $con = null)
|
||||
{
|
||||
$orderCouponModulesToDelete = $this->getOrderCouponModules(new Criteria(), $con)->diff($orderCouponModules);
|
||||
|
||||
|
||||
//since at least one column in the foreign key is at the same time a PK
|
||||
//we can not just set a PK to NULL in the lines below. We have to store
|
||||
//a backup of all values, so we are able to manipulate these items based on the onDelete value later.
|
||||
$this->orderCouponModulesScheduledForDeletion = clone $orderCouponModulesToDelete;
|
||||
|
||||
foreach ($orderCouponModulesToDelete as $orderCouponModuleRemoved) {
|
||||
$orderCouponModuleRemoved->setModule(null);
|
||||
}
|
||||
|
||||
$this->collOrderCouponModules = null;
|
||||
foreach ($orderCouponModules as $orderCouponModule) {
|
||||
$this->addOrderCouponModule($orderCouponModule);
|
||||
}
|
||||
|
||||
$this->collOrderCouponModules = $orderCouponModules;
|
||||
$this->collOrderCouponModulesPartial = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of related OrderCouponModule objects.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct
|
||||
* @param ConnectionInterface $con
|
||||
* @return int Count of related OrderCouponModule objects.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function countOrderCouponModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
$partial = $this->collOrderCouponModulesPartial && !$this->isNew();
|
||||
if (null === $this->collOrderCouponModules || null !== $criteria || $partial) {
|
||||
if ($this->isNew() && null === $this->collOrderCouponModules) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($partial && !$criteria) {
|
||||
return count($this->getOrderCouponModules());
|
||||
}
|
||||
|
||||
$query = ChildOrderCouponModuleQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByModule($this)
|
||||
->count($con);
|
||||
}
|
||||
|
||||
return count($this->collOrderCouponModules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called to associate a ChildOrderCouponModule object to this object
|
||||
* through the ChildOrderCouponModule foreign key attribute.
|
||||
*
|
||||
* @param ChildOrderCouponModule $l ChildOrderCouponModule
|
||||
* @return \Thelia\Model\Module The current object (for fluent API support)
|
||||
*/
|
||||
public function addOrderCouponModule(ChildOrderCouponModule $l)
|
||||
{
|
||||
if ($this->collOrderCouponModules === null) {
|
||||
$this->initOrderCouponModules();
|
||||
$this->collOrderCouponModulesPartial = true;
|
||||
}
|
||||
|
||||
if (!in_array($l, $this->collOrderCouponModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddOrderCouponModule($l);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderCouponModule $orderCouponModule The orderCouponModule object to add.
|
||||
*/
|
||||
protected function doAddOrderCouponModule($orderCouponModule)
|
||||
{
|
||||
$this->collOrderCouponModules[]= $orderCouponModule;
|
||||
$orderCouponModule->setModule($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderCouponModule $orderCouponModule The orderCouponModule object to remove.
|
||||
* @return ChildModule The current object (for fluent API support)
|
||||
*/
|
||||
public function removeOrderCouponModule($orderCouponModule)
|
||||
{
|
||||
if ($this->getOrderCouponModules()->contains($orderCouponModule)) {
|
||||
$this->collOrderCouponModules->remove($this->collOrderCouponModules->search($orderCouponModule));
|
||||
if (null === $this->orderCouponModulesScheduledForDeletion) {
|
||||
$this->orderCouponModulesScheduledForDeletion = clone $this->collOrderCouponModules;
|
||||
$this->orderCouponModulesScheduledForDeletion->clear();
|
||||
}
|
||||
$this->orderCouponModulesScheduledForDeletion[]= clone $orderCouponModule;
|
||||
$orderCouponModule->setModule(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If this collection has already been initialized with
|
||||
* an identical criteria, it returns the collection.
|
||||
* Otherwise if this Module is new, it will return
|
||||
* an empty collection; or if this Module has previously
|
||||
* been saved, it will retrieve related OrderCouponModules from storage.
|
||||
*
|
||||
* This method is protected by default in order to keep the public
|
||||
* api reasonable. You can provide public methods for those you
|
||||
* actually need in Module.
|
||||
*
|
||||
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||
* @param ConnectionInterface $con optional connection object
|
||||
* @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
|
||||
* @return Collection|ChildOrderCouponModule[] List of ChildOrderCouponModule objects
|
||||
*/
|
||||
public function getOrderCouponModulesJoinOrderCoupon($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
|
||||
{
|
||||
$query = ChildOrderCouponModuleQuery::create(null, $criteria);
|
||||
$query->joinWith('OrderCoupon', $joinBehavior);
|
||||
|
||||
return $this->getOrderCouponModules($query, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collModuleI18ns collection
|
||||
*
|
||||
@@ -3819,6 +4151,189 @@ abstract class Module implements ActiveRecordInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out the collOrderCoupons collection
|
||||
*
|
||||
* This does not modify the database; however, it will remove any associated objects, causing
|
||||
* them to be refetched by subsequent calls to accessor method.
|
||||
*
|
||||
* @return void
|
||||
* @see addOrderCoupons()
|
||||
*/
|
||||
public function clearOrderCoupons()
|
||||
{
|
||||
$this->collOrderCoupons = null; // important to set this to NULL since that means it is uninitialized
|
||||
$this->collOrderCouponsPartial = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the collOrderCoupons collection.
|
||||
*
|
||||
* By default this just sets the collOrderCoupons collection to an empty collection (like clearOrderCoupons());
|
||||
* however, you may wish to override this method in your stub class to provide setting appropriate
|
||||
* to your application -- for example, setting the initial array to the values stored in database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initOrderCoupons()
|
||||
{
|
||||
$this->collOrderCoupons = new ObjectCollection();
|
||||
$this->collOrderCoupons->setModel('\Thelia\Model\OrderCoupon');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a collection of ChildOrderCoupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the order_coupon_module cross-reference table.
|
||||
*
|
||||
* If the $criteria is not null, it is used to always fetch the results from the database.
|
||||
* Otherwise the results are fetched from the database the first time, then cached.
|
||||
* Next time the same method is called without $criteria, the cached collection is returned.
|
||||
* If this ChildModule is new, it will return
|
||||
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||
*
|
||||
* @param Criteria $criteria Optional query object to filter the query
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
*
|
||||
* @return ObjectCollection|ChildOrderCoupon[] List of ChildOrderCoupon objects
|
||||
*/
|
||||
public function getOrderCoupons($criteria = null, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $this->collOrderCoupons || null !== $criteria) {
|
||||
if ($this->isNew() && null === $this->collOrderCoupons) {
|
||||
// return empty collection
|
||||
$this->initOrderCoupons();
|
||||
} else {
|
||||
$collOrderCoupons = ChildOrderCouponQuery::create(null, $criteria)
|
||||
->filterByModule($this)
|
||||
->find($con);
|
||||
if (null !== $criteria) {
|
||||
return $collOrderCoupons;
|
||||
}
|
||||
$this->collOrderCoupons = $collOrderCoupons;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->collOrderCoupons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a collection of OrderCoupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the order_coupon_module cross-reference table.
|
||||
* It will also schedule objects for deletion based on a diff between old objects (aka persisted)
|
||||
* and new objects from the given Propel collection.
|
||||
*
|
||||
* @param Collection $orderCoupons A Propel collection.
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
* @return ChildModule The current object (for fluent API support)
|
||||
*/
|
||||
public function setOrderCoupons(Collection $orderCoupons, ConnectionInterface $con = null)
|
||||
{
|
||||
$this->clearOrderCoupons();
|
||||
$currentOrderCoupons = $this->getOrderCoupons();
|
||||
|
||||
$this->orderCouponsScheduledForDeletion = $currentOrderCoupons->diff($orderCoupons);
|
||||
|
||||
foreach ($orderCoupons as $orderCoupon) {
|
||||
if (!$currentOrderCoupons->contains($orderCoupon)) {
|
||||
$this->doAddOrderCoupon($orderCoupon);
|
||||
}
|
||||
}
|
||||
|
||||
$this->collOrderCoupons = $orderCoupons;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of ChildOrderCoupon objects related by a many-to-many relationship
|
||||
* to the current object by way of the order_coupon_module cross-reference table.
|
||||
*
|
||||
* @param Criteria $criteria Optional query object to filter the query
|
||||
* @param boolean $distinct Set to true to force count distinct
|
||||
* @param ConnectionInterface $con Optional connection object
|
||||
*
|
||||
* @return int the number of related ChildOrderCoupon objects
|
||||
*/
|
||||
public function countOrderCoupons($criteria = null, $distinct = false, ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $this->collOrderCoupons || null !== $criteria) {
|
||||
if ($this->isNew() && null === $this->collOrderCoupons) {
|
||||
return 0;
|
||||
} else {
|
||||
$query = ChildOrderCouponQuery::create(null, $criteria);
|
||||
if ($distinct) {
|
||||
$query->distinct();
|
||||
}
|
||||
|
||||
return $query
|
||||
->filterByModule($this)
|
||||
->count($con);
|
||||
}
|
||||
} else {
|
||||
return count($this->collOrderCoupons);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate a ChildOrderCoupon object to this object
|
||||
* through the order_coupon_module cross reference table.
|
||||
*
|
||||
* @param ChildOrderCoupon $orderCoupon The ChildOrderCouponModule object to relate
|
||||
* @return ChildModule The current object (for fluent API support)
|
||||
*/
|
||||
public function addOrderCoupon(ChildOrderCoupon $orderCoupon)
|
||||
{
|
||||
if ($this->collOrderCoupons === null) {
|
||||
$this->initOrderCoupons();
|
||||
}
|
||||
|
||||
if (!$this->collOrderCoupons->contains($orderCoupon)) { // only add it if the **same** object is not already associated
|
||||
$this->doAddOrderCoupon($orderCoupon);
|
||||
$this->collOrderCoupons[] = $orderCoupon;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderCoupon $orderCoupon The orderCoupon object to add.
|
||||
*/
|
||||
protected function doAddOrderCoupon($orderCoupon)
|
||||
{
|
||||
$orderCouponModule = new ChildOrderCouponModule();
|
||||
$orderCouponModule->setOrderCoupon($orderCoupon);
|
||||
$this->addOrderCouponModule($orderCouponModule);
|
||||
// set the back reference to this object directly as using provided method either results
|
||||
// in endless loop or in multiple relations
|
||||
if (!$orderCoupon->getModules()->contains($this)) {
|
||||
$foreignCollection = $orderCoupon->getModules();
|
||||
$foreignCollection[] = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a ChildOrderCoupon object to this object
|
||||
* through the order_coupon_module cross reference table.
|
||||
*
|
||||
* @param ChildOrderCoupon $orderCoupon The ChildOrderCouponModule object to relate
|
||||
* @return ChildModule The current object (for fluent API support)
|
||||
*/
|
||||
public function removeOrderCoupon(ChildOrderCoupon $orderCoupon)
|
||||
{
|
||||
if ($this->getOrderCoupons()->contains($orderCoupon)) {
|
||||
$this->collOrderCoupons->remove($this->collOrderCoupons->search($orderCoupon));
|
||||
|
||||
if (null === $this->orderCouponsScheduledForDeletion) {
|
||||
$this->orderCouponsScheduledForDeletion = clone $this->collOrderCoupons;
|
||||
$this->orderCouponsScheduledForDeletion->clear();
|
||||
}
|
||||
|
||||
$this->orderCouponsScheduledForDeletion[] = $orderCoupon;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the current object and sets all attributes to their default values
|
||||
*/
|
||||
@@ -3881,6 +4396,11 @@ abstract class Module implements ActiveRecordInterface
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collOrderCouponModules) {
|
||||
foreach ($this->collOrderCouponModules as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collModuleI18ns) {
|
||||
foreach ($this->collModuleI18ns as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
@@ -3891,6 +4411,11 @@ abstract class Module implements ActiveRecordInterface
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
if ($this->collOrderCoupons) {
|
||||
foreach ($this->collOrderCoupons as $o) {
|
||||
$o->clearAllReferences($deep);
|
||||
}
|
||||
}
|
||||
} // if ($deep)
|
||||
|
||||
// i18n behavior
|
||||
@@ -3903,8 +4428,10 @@ abstract class Module implements ActiveRecordInterface
|
||||
$this->collProfileModules = null;
|
||||
$this->collModuleImages = null;
|
||||
$this->collCouponModules = null;
|
||||
$this->collOrderCouponModules = null;
|
||||
$this->collModuleI18ns = null;
|
||||
$this->collCoupons = null;
|
||||
$this->collOrderCoupons = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,6 +68,10 @@ use Thelia\Model\Map\ModuleTableMap;
|
||||
* @method ChildModuleQuery rightJoinCouponModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponModule relation
|
||||
* @method ChildModuleQuery innerJoinCouponModule($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponModule relation
|
||||
*
|
||||
* @method ChildModuleQuery leftJoinOrderCouponModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderCouponModule relation
|
||||
* @method ChildModuleQuery rightJoinOrderCouponModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderCouponModule relation
|
||||
* @method ChildModuleQuery innerJoinOrderCouponModule($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderCouponModule relation
|
||||
*
|
||||
* @method ChildModuleQuery leftJoinModuleI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the ModuleI18n relation
|
||||
* @method ChildModuleQuery rightJoinModuleI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ModuleI18n relation
|
||||
* @method ChildModuleQuery innerJoinModuleI18n($relationAlias = null) Adds a INNER JOIN clause to the query using the ModuleI18n relation
|
||||
@@ -1015,6 +1019,79 @@ abstract class ModuleQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'CouponModule', '\Thelia\Model\CouponModuleQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\OrderCouponModule object
|
||||
*
|
||||
* @param \Thelia\Model\OrderCouponModule|ObjectCollection $orderCouponModule the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByOrderCouponModule($orderCouponModule, $comparison = null)
|
||||
{
|
||||
if ($orderCouponModule instanceof \Thelia\Model\OrderCouponModule) {
|
||||
return $this
|
||||
->addUsingAlias(ModuleTableMap::ID, $orderCouponModule->getModuleId(), $comparison);
|
||||
} elseif ($orderCouponModule instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useOrderCouponModuleQuery()
|
||||
->filterByPrimaryKeys($orderCouponModule->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByOrderCouponModule() only accepts arguments of type \Thelia\Model\OrderCouponModule or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the OrderCouponModule relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinOrderCouponModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('OrderCouponModule');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'OrderCouponModule');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the OrderCouponModule relation OrderCouponModule object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\OrderCouponModuleQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useOrderCouponModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinOrderCouponModule($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'OrderCouponModule', '\Thelia\Model\OrderCouponModuleQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\ModuleI18n object
|
||||
*
|
||||
@@ -1105,6 +1182,23 @@ abstract class ModuleQuery extends ModelCriteria
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related OrderCoupon object
|
||||
* using the order_coupon_module table as cross reference
|
||||
*
|
||||
* @param OrderCoupon $orderCoupon the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByOrderCoupon($orderCoupon, $comparison = Criteria::EQUAL)
|
||||
{
|
||||
return $this
|
||||
->useOrderCouponModuleQuery()
|
||||
->filterByOrderCoupon($orderCoupon, $comparison)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1268
core/lib/Thelia/Model/Base/OrderCouponCountry.php
Normal file
1268
core/lib/Thelia/Model/Base/OrderCouponCountry.php
Normal file
File diff suppressed because it is too large
Load Diff
568
core/lib/Thelia/Model/Base/OrderCouponCountryQuery.php
Normal file
568
core/lib/Thelia/Model/Base/OrderCouponCountryQuery.php
Normal file
@@ -0,0 +1,568 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model\Base;
|
||||
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelJoin;
|
||||
use Propel\Runtime\Collection\Collection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\OrderCouponCountry as ChildOrderCouponCountry;
|
||||
use Thelia\Model\OrderCouponCountryQuery as ChildOrderCouponCountryQuery;
|
||||
use Thelia\Model\Map\OrderCouponCountryTableMap;
|
||||
|
||||
/**
|
||||
* Base class that represents a query for the 'order_coupon_country' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildOrderCouponCountryQuery orderByCouponId($order = Criteria::ASC) Order by the coupon_id column
|
||||
* @method ChildOrderCouponCountryQuery orderByCountryId($order = Criteria::ASC) Order by the country_id column
|
||||
*
|
||||
* @method ChildOrderCouponCountryQuery groupByCouponId() Group by the coupon_id column
|
||||
* @method ChildOrderCouponCountryQuery groupByCountryId() Group by the country_id column
|
||||
*
|
||||
* @method ChildOrderCouponCountryQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildOrderCouponCountryQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildOrderCouponCountryQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildOrderCouponCountryQuery leftJoinCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the Country relation
|
||||
* @method ChildOrderCouponCountryQuery rightJoinCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Country relation
|
||||
* @method ChildOrderCouponCountryQuery innerJoinCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the Country relation
|
||||
*
|
||||
* @method ChildOrderCouponCountryQuery leftJoinOrderCoupon($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderCoupon relation
|
||||
* @method ChildOrderCouponCountryQuery rightJoinOrderCoupon($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderCoupon relation
|
||||
* @method ChildOrderCouponCountryQuery innerJoinOrderCoupon($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderCoupon relation
|
||||
*
|
||||
* @method ChildOrderCouponCountry findOne(ConnectionInterface $con = null) Return the first ChildOrderCouponCountry matching the query
|
||||
* @method ChildOrderCouponCountry findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderCouponCountry matching the query, or a new ChildOrderCouponCountry object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildOrderCouponCountry findOneByCouponId(int $coupon_id) Return the first ChildOrderCouponCountry filtered by the coupon_id column
|
||||
* @method ChildOrderCouponCountry findOneByCountryId(int $country_id) Return the first ChildOrderCouponCountry filtered by the country_id column
|
||||
*
|
||||
* @method array findByCouponId(int $coupon_id) Return ChildOrderCouponCountry objects filtered by the coupon_id column
|
||||
* @method array findByCountryId(int $country_id) Return ChildOrderCouponCountry objects filtered by the country_id column
|
||||
*
|
||||
*/
|
||||
abstract class OrderCouponCountryQuery extends ModelCriteria
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes internal state of \Thelia\Model\Base\OrderCouponCountryQuery object.
|
||||
*
|
||||
* @param string $dbName The database name
|
||||
* @param string $modelName The phpName of a model, e.g. 'Book'
|
||||
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
|
||||
*/
|
||||
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\OrderCouponCountry', $modelAlias = null)
|
||||
{
|
||||
parent::__construct($dbName, $modelName, $modelAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new ChildOrderCouponCountryQuery object.
|
||||
*
|
||||
* @param string $modelAlias The alias of a model in the query
|
||||
* @param Criteria $criteria Optional Criteria to build the query from
|
||||
*
|
||||
* @return ChildOrderCouponCountryQuery
|
||||
*/
|
||||
public static function create($modelAlias = null, $criteria = null)
|
||||
{
|
||||
if ($criteria instanceof \Thelia\Model\OrderCouponCountryQuery) {
|
||||
return $criteria;
|
||||
}
|
||||
$query = new \Thelia\Model\OrderCouponCountryQuery();
|
||||
if (null !== $modelAlias) {
|
||||
$query->setModelAlias($modelAlias);
|
||||
}
|
||||
if ($criteria instanceof Criteria) {
|
||||
$query->mergeWith($criteria);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
* Propel uses the instance pool to skip the database if the object exists.
|
||||
* Go fast if the query is untouched.
|
||||
*
|
||||
* <code>
|
||||
* $obj = $c->findPk(array(12, 34), $con);
|
||||
* </code>
|
||||
*
|
||||
* @param array[$coupon_id, $country_id] $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildOrderCouponCountry|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
public function findPk($key, $con = null)
|
||||
{
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
if ((null !== ($obj = OrderCouponCountryTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
|
||||
// the object is already in the instance pool
|
||||
return $obj;
|
||||
}
|
||||
if ($con === null) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection(OrderCouponCountryTableMap::DATABASE_NAME);
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|
||||
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|
||||
|| $this->map || $this->having || $this->joins) {
|
||||
return $this->findPkComplex($key, $con);
|
||||
} else {
|
||||
return $this->findPkSimple($key, $con);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key using raw SQL to go fast.
|
||||
* Bypass doSelect() and the object formatter by using generated code.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildOrderCouponCountry A model object, or null if the key is not found
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT `COUPON_ID`, `COUNTRY_ID` FROM `order_coupon_country` WHERE `COUPON_ID` = :p0 AND `COUNTRY_ID` = :p1';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
|
||||
$stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
} catch (Exception $e) {
|
||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
|
||||
}
|
||||
$obj = null;
|
||||
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
|
||||
$obj = new ChildOrderCouponCountry();
|
||||
$obj->hydrate($row);
|
||||
OrderCouponCountryTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildOrderCouponCountry|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
protected function findPkComplex($key, $con)
|
||||
{
|
||||
// As the query uses a PK condition, no limit(1) is necessary.
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKey($key)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find objects by primary key
|
||||
* <code>
|
||||
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
|
||||
* </code>
|
||||
* @param array $keys Primary keys to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
|
||||
*/
|
||||
public function findPks($keys, $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKeys($keys)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by primary key
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
*
|
||||
* @return ChildOrderCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
$this->addUsingAlias(OrderCouponCountryTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
|
||||
$this->addUsingAlias(OrderCouponCountryTableMap::COUNTRY_ID, $key[1], Criteria::EQUAL);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a list of primary keys
|
||||
*
|
||||
* @param array $keys The list of primary key to use for the query
|
||||
*
|
||||
* @return ChildOrderCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKeys($keys)
|
||||
{
|
||||
if (empty($keys)) {
|
||||
return $this->add(null, '1<>1', Criteria::CUSTOM);
|
||||
}
|
||||
foreach ($keys as $key) {
|
||||
$cton0 = $this->getNewCriterion(OrderCouponCountryTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
|
||||
$cton1 = $this->getNewCriterion(OrderCouponCountryTableMap::COUNTRY_ID, $key[1], Criteria::EQUAL);
|
||||
$cton0->addAnd($cton1);
|
||||
$this->addOr($cton0);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the coupon_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCouponId(1234); // WHERE coupon_id = 1234
|
||||
* $query->filterByCouponId(array(12, 34)); // WHERE coupon_id IN (12, 34)
|
||||
* $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByOrderCoupon()
|
||||
*
|
||||
* @param mixed $couponId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponId($couponId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($couponId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($couponId['min'])) {
|
||||
$this->addUsingAlias(OrderCouponCountryTableMap::COUPON_ID, $couponId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($couponId['max'])) {
|
||||
$this->addUsingAlias(OrderCouponCountryTableMap::COUPON_ID, $couponId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderCouponCountryTableMap::COUPON_ID, $couponId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the country_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCountryId(1234); // WHERE country_id = 1234
|
||||
* $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
|
||||
* $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByCountry()
|
||||
*
|
||||
* @param mixed $countryId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCountryId($countryId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($countryId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($countryId['min'])) {
|
||||
$this->addUsingAlias(OrderCouponCountryTableMap::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($countryId['max'])) {
|
||||
$this->addUsingAlias(OrderCouponCountryTableMap::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderCouponCountryTableMap::COUNTRY_ID, $countryId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Country object
|
||||
*
|
||||
* @param \Thelia\Model\Country|ObjectCollection $country The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCountry($country, $comparison = null)
|
||||
{
|
||||
if ($country instanceof \Thelia\Model\Country) {
|
||||
return $this
|
||||
->addUsingAlias(OrderCouponCountryTableMap::COUNTRY_ID, $country->getId(), $comparison);
|
||||
} elseif ($country instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(OrderCouponCountryTableMap::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByCountry() only accepts arguments of type \Thelia\Model\Country or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Country relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildOrderCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Country');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Country');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Country relation Country object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\CountryQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinCountry($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\OrderCoupon object
|
||||
*
|
||||
* @param \Thelia\Model\OrderCoupon|ObjectCollection $orderCoupon The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByOrderCoupon($orderCoupon, $comparison = null)
|
||||
{
|
||||
if ($orderCoupon instanceof \Thelia\Model\OrderCoupon) {
|
||||
return $this
|
||||
->addUsingAlias(OrderCouponCountryTableMap::COUPON_ID, $orderCoupon->getId(), $comparison);
|
||||
} elseif ($orderCoupon instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(OrderCouponCountryTableMap::COUPON_ID, $orderCoupon->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByOrderCoupon() only accepts arguments of type \Thelia\Model\OrderCoupon or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the OrderCoupon relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildOrderCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinOrderCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('OrderCoupon');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'OrderCoupon');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the OrderCoupon relation OrderCoupon object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\OrderCouponQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useOrderCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinOrderCoupon($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'OrderCoupon', '\Thelia\Model\OrderCouponQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
* @param ChildOrderCouponCountry $orderCouponCountry Object to remove from the list of results
|
||||
*
|
||||
* @return ChildOrderCouponCountryQuery The current query, for fluid interface
|
||||
*/
|
||||
public function prune($orderCouponCountry = null)
|
||||
{
|
||||
if ($orderCouponCountry) {
|
||||
$this->addCond('pruneCond0', $this->getAliasedColName(OrderCouponCountryTableMap::COUPON_ID), $orderCouponCountry->getCouponId(), Criteria::NOT_EQUAL);
|
||||
$this->addCond('pruneCond1', $this->getAliasedColName(OrderCouponCountryTableMap::COUNTRY_ID), $orderCouponCountry->getCountryId(), Criteria::NOT_EQUAL);
|
||||
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the order_coupon_country table.
|
||||
*
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public function doDeleteAll(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(OrderCouponCountryTableMap::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->beginTransaction();
|
||||
$affectedRows += parent::doDeleteAll($con);
|
||||
// Because this db requires some delete cascade/set null emulation, we have to
|
||||
// clear the cached instance *after* the emulation has happened (since
|
||||
// instances get re-added by the select statement contained therein).
|
||||
OrderCouponCountryTableMap::clearInstancePool();
|
||||
OrderCouponCountryTableMap::clearRelatedInstancePool();
|
||||
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ChildOrderCouponCountry or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ChildOrderCouponCountry object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(OrderCouponCountryTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = $this;
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(OrderCouponCountryTableMap::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->beginTransaction();
|
||||
|
||||
|
||||
OrderCouponCountryTableMap::removeInstanceFromPool($criteria);
|
||||
|
||||
$affectedRows += ModelCriteria::delete($con);
|
||||
OrderCouponCountryTableMap::clearRelatedInstancePool();
|
||||
$con->commit();
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
} // OrderCouponCountryQuery
|
||||
1268
core/lib/Thelia/Model/Base/OrderCouponModule.php
Normal file
1268
core/lib/Thelia/Model/Base/OrderCouponModule.php
Normal file
File diff suppressed because it is too large
Load Diff
568
core/lib/Thelia/Model/Base/OrderCouponModuleQuery.php
Normal file
568
core/lib/Thelia/Model/Base/OrderCouponModuleQuery.php
Normal file
@@ -0,0 +1,568 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Model\Base;
|
||||
|
||||
use \Exception;
|
||||
use \PDO;
|
||||
use Propel\Runtime\Propel;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\ActiveQuery\ModelJoin;
|
||||
use Propel\Runtime\Collection\Collection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\OrderCouponModule as ChildOrderCouponModule;
|
||||
use Thelia\Model\OrderCouponModuleQuery as ChildOrderCouponModuleQuery;
|
||||
use Thelia\Model\Map\OrderCouponModuleTableMap;
|
||||
|
||||
/**
|
||||
* Base class that represents a query for the 'order_coupon_module' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @method ChildOrderCouponModuleQuery orderByCouponId($order = Criteria::ASC) Order by the coupon_id column
|
||||
* @method ChildOrderCouponModuleQuery orderByModuleId($order = Criteria::ASC) Order by the module_id column
|
||||
*
|
||||
* @method ChildOrderCouponModuleQuery groupByCouponId() Group by the coupon_id column
|
||||
* @method ChildOrderCouponModuleQuery groupByModuleId() Group by the module_id column
|
||||
*
|
||||
* @method ChildOrderCouponModuleQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method ChildOrderCouponModuleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
* @method ChildOrderCouponModuleQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||
*
|
||||
* @method ChildOrderCouponModuleQuery leftJoinOrderCoupon($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderCoupon relation
|
||||
* @method ChildOrderCouponModuleQuery rightJoinOrderCoupon($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderCoupon relation
|
||||
* @method ChildOrderCouponModuleQuery innerJoinOrderCoupon($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderCoupon relation
|
||||
*
|
||||
* @method ChildOrderCouponModuleQuery leftJoinModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the Module relation
|
||||
* @method ChildOrderCouponModuleQuery rightJoinModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Module relation
|
||||
* @method ChildOrderCouponModuleQuery innerJoinModule($relationAlias = null) Adds a INNER JOIN clause to the query using the Module relation
|
||||
*
|
||||
* @method ChildOrderCouponModule findOne(ConnectionInterface $con = null) Return the first ChildOrderCouponModule matching the query
|
||||
* @method ChildOrderCouponModule findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderCouponModule matching the query, or a new ChildOrderCouponModule object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildOrderCouponModule findOneByCouponId(int $coupon_id) Return the first ChildOrderCouponModule filtered by the coupon_id column
|
||||
* @method ChildOrderCouponModule findOneByModuleId(int $module_id) Return the first ChildOrderCouponModule filtered by the module_id column
|
||||
*
|
||||
* @method array findByCouponId(int $coupon_id) Return ChildOrderCouponModule objects filtered by the coupon_id column
|
||||
* @method array findByModuleId(int $module_id) Return ChildOrderCouponModule objects filtered by the module_id column
|
||||
*
|
||||
*/
|
||||
abstract class OrderCouponModuleQuery extends ModelCriteria
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes internal state of \Thelia\Model\Base\OrderCouponModuleQuery object.
|
||||
*
|
||||
* @param string $dbName The database name
|
||||
* @param string $modelName The phpName of a model, e.g. 'Book'
|
||||
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
|
||||
*/
|
||||
public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\OrderCouponModule', $modelAlias = null)
|
||||
{
|
||||
parent::__construct($dbName, $modelName, $modelAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new ChildOrderCouponModuleQuery object.
|
||||
*
|
||||
* @param string $modelAlias The alias of a model in the query
|
||||
* @param Criteria $criteria Optional Criteria to build the query from
|
||||
*
|
||||
* @return ChildOrderCouponModuleQuery
|
||||
*/
|
||||
public static function create($modelAlias = null, $criteria = null)
|
||||
{
|
||||
if ($criteria instanceof \Thelia\Model\OrderCouponModuleQuery) {
|
||||
return $criteria;
|
||||
}
|
||||
$query = new \Thelia\Model\OrderCouponModuleQuery();
|
||||
if (null !== $modelAlias) {
|
||||
$query->setModelAlias($modelAlias);
|
||||
}
|
||||
if ($criteria instanceof Criteria) {
|
||||
$query->mergeWith($criteria);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
* Propel uses the instance pool to skip the database if the object exists.
|
||||
* Go fast if the query is untouched.
|
||||
*
|
||||
* <code>
|
||||
* $obj = $c->findPk(array(12, 34), $con);
|
||||
* </code>
|
||||
*
|
||||
* @param array[$coupon_id, $module_id] $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ChildOrderCouponModule|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
public function findPk($key, $con = null)
|
||||
{
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
if ((null !== ($obj = OrderCouponModuleTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) {
|
||||
// the object is already in the instance pool
|
||||
return $obj;
|
||||
}
|
||||
if ($con === null) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection(OrderCouponModuleTableMap::DATABASE_NAME);
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
if ($this->formatter || $this->modelAlias || $this->with || $this->select
|
||||
|| $this->selectColumns || $this->asColumns || $this->selectModifiers
|
||||
|| $this->map || $this->having || $this->joins) {
|
||||
return $this->findPkComplex($key, $con);
|
||||
} else {
|
||||
return $this->findPkSimple($key, $con);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key using raw SQL to go fast.
|
||||
* Bypass doSelect() and the object formatter by using generated code.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildOrderCouponModule A model object, or null if the key is not found
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT `COUPON_ID`, `MODULE_ID` FROM `order_coupon_module` WHERE `COUPON_ID` = :p0 AND `MODULE_ID` = :p1';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
|
||||
$stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
} catch (Exception $e) {
|
||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
|
||||
}
|
||||
$obj = null;
|
||||
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
|
||||
$obj = new ChildOrderCouponModule();
|
||||
$obj->hydrate($row);
|
||||
OrderCouponModuleTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find object by primary key.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return ChildOrderCouponModule|array|mixed the result, formatted by the current formatter
|
||||
*/
|
||||
protected function findPkComplex($key, $con)
|
||||
{
|
||||
// As the query uses a PK condition, no limit(1) is necessary.
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKey($key)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find objects by primary key
|
||||
* <code>
|
||||
* $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
|
||||
* </code>
|
||||
* @param array $keys Primary keys to use for the query
|
||||
* @param ConnectionInterface $con an optional connection object
|
||||
*
|
||||
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
|
||||
*/
|
||||
public function findPks($keys, $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
|
||||
}
|
||||
$this->basePreSelect($con);
|
||||
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||
$dataFetcher = $criteria
|
||||
->filterByPrimaryKeys($keys)
|
||||
->doSelect($con);
|
||||
|
||||
return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by primary key
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
*
|
||||
* @return ChildOrderCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKey($key)
|
||||
{
|
||||
$this->addUsingAlias(OrderCouponModuleTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
|
||||
$this->addUsingAlias(OrderCouponModuleTableMap::MODULE_ID, $key[1], Criteria::EQUAL);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a list of primary keys
|
||||
*
|
||||
* @param array $keys The list of primary key to use for the query
|
||||
*
|
||||
* @return ChildOrderCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPrimaryKeys($keys)
|
||||
{
|
||||
if (empty($keys)) {
|
||||
return $this->add(null, '1<>1', Criteria::CUSTOM);
|
||||
}
|
||||
foreach ($keys as $key) {
|
||||
$cton0 = $this->getNewCriterion(OrderCouponModuleTableMap::COUPON_ID, $key[0], Criteria::EQUAL);
|
||||
$cton1 = $this->getNewCriterion(OrderCouponModuleTableMap::MODULE_ID, $key[1], Criteria::EQUAL);
|
||||
$cton0->addAnd($cton1);
|
||||
$this->addOr($cton0);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the coupon_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByCouponId(1234); // WHERE coupon_id = 1234
|
||||
* $query->filterByCouponId(array(12, 34)); // WHERE coupon_id IN (12, 34)
|
||||
* $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByOrderCoupon()
|
||||
*
|
||||
* @param mixed $couponId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCouponId($couponId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($couponId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($couponId['min'])) {
|
||||
$this->addUsingAlias(OrderCouponModuleTableMap::COUPON_ID, $couponId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($couponId['max'])) {
|
||||
$this->addUsingAlias(OrderCouponModuleTableMap::COUPON_ID, $couponId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderCouponModuleTableMap::COUPON_ID, $couponId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the module_id column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByModuleId(1234); // WHERE module_id = 1234
|
||||
* $query->filterByModuleId(array(12, 34)); // WHERE module_id IN (12, 34)
|
||||
* $query->filterByModuleId(array('min' => 12)); // WHERE module_id > 12
|
||||
* </code>
|
||||
*
|
||||
* @see filterByModule()
|
||||
*
|
||||
* @param mixed $moduleId The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByModuleId($moduleId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($moduleId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($moduleId['min'])) {
|
||||
$this->addUsingAlias(OrderCouponModuleTableMap::MODULE_ID, $moduleId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($moduleId['max'])) {
|
||||
$this->addUsingAlias(OrderCouponModuleTableMap::MODULE_ID, $moduleId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderCouponModuleTableMap::MODULE_ID, $moduleId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\OrderCoupon object
|
||||
*
|
||||
* @param \Thelia\Model\OrderCoupon|ObjectCollection $orderCoupon The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByOrderCoupon($orderCoupon, $comparison = null)
|
||||
{
|
||||
if ($orderCoupon instanceof \Thelia\Model\OrderCoupon) {
|
||||
return $this
|
||||
->addUsingAlias(OrderCouponModuleTableMap::COUPON_ID, $orderCoupon->getId(), $comparison);
|
||||
} elseif ($orderCoupon instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(OrderCouponModuleTableMap::COUPON_ID, $orderCoupon->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByOrderCoupon() only accepts arguments of type \Thelia\Model\OrderCoupon or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the OrderCoupon relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildOrderCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinOrderCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('OrderCoupon');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'OrderCoupon');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the OrderCoupon relation OrderCoupon object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\OrderCouponQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useOrderCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinOrderCoupon($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'OrderCoupon', '\Thelia\Model\OrderCouponQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\Module object
|
||||
*
|
||||
* @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByModule($module, $comparison = null)
|
||||
{
|
||||
if ($module instanceof \Thelia\Model\Module) {
|
||||
return $this
|
||||
->addUsingAlias(OrderCouponModuleTableMap::MODULE_ID, $module->getId(), $comparison);
|
||||
} elseif ($module instanceof ObjectCollection) {
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
|
||||
return $this
|
||||
->addUsingAlias(OrderCouponModuleTableMap::MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison);
|
||||
} else {
|
||||
throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the Module relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildOrderCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('Module');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'Module');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the Module relation Module object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinModule($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
* @param ChildOrderCouponModule $orderCouponModule Object to remove from the list of results
|
||||
*
|
||||
* @return ChildOrderCouponModuleQuery The current query, for fluid interface
|
||||
*/
|
||||
public function prune($orderCouponModule = null)
|
||||
{
|
||||
if ($orderCouponModule) {
|
||||
$this->addCond('pruneCond0', $this->getAliasedColName(OrderCouponModuleTableMap::COUPON_ID), $orderCouponModule->getCouponId(), Criteria::NOT_EQUAL);
|
||||
$this->addCond('pruneCond1', $this->getAliasedColName(OrderCouponModuleTableMap::MODULE_ID), $orderCouponModule->getModuleId(), Criteria::NOT_EQUAL);
|
||||
$this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all rows from the order_coupon_module table.
|
||||
*
|
||||
* @param ConnectionInterface $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public function doDeleteAll(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(OrderCouponModuleTableMap::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->beginTransaction();
|
||||
$affectedRows += parent::doDeleteAll($con);
|
||||
// Because this db requires some delete cascade/set null emulation, we have to
|
||||
// clear the cached instance *after* the emulation has happened (since
|
||||
// instances get re-added by the select statement contained therein).
|
||||
OrderCouponModuleTableMap::clearInstancePool();
|
||||
OrderCouponModuleTableMap::clearRelatedInstancePool();
|
||||
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $affectedRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a DELETE on the database, given a ChildOrderCouponModule or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or ChildOrderCouponModule object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param ConnectionInterface $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 function delete(ConnectionInterface $con = null)
|
||||
{
|
||||
if (null === $con) {
|
||||
$con = Propel::getServiceContainer()->getWriteConnection(OrderCouponModuleTableMap::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = $this;
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(OrderCouponModuleTableMap::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->beginTransaction();
|
||||
|
||||
|
||||
OrderCouponModuleTableMap::removeInstanceFromPool($criteria);
|
||||
|
||||
$affectedRows += ModelCriteria::delete($con);
|
||||
OrderCouponModuleTableMap::clearRelatedInstancePool();
|
||||
$con->commit();
|
||||
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
} // OrderCouponModuleQuery
|
||||
@@ -61,6 +61,14 @@ use Thelia\Model\Map\OrderCouponTableMap;
|
||||
* @method ChildOrderCouponQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation
|
||||
* @method ChildOrderCouponQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation
|
||||
*
|
||||
* @method ChildOrderCouponQuery leftJoinOrderCouponCountry($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderCouponCountry relation
|
||||
* @method ChildOrderCouponQuery rightJoinOrderCouponCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderCouponCountry relation
|
||||
* @method ChildOrderCouponQuery innerJoinOrderCouponCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderCouponCountry relation
|
||||
*
|
||||
* @method ChildOrderCouponQuery leftJoinOrderCouponModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderCouponModule relation
|
||||
* @method ChildOrderCouponQuery rightJoinOrderCouponModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderCouponModule relation
|
||||
* @method ChildOrderCouponQuery innerJoinOrderCouponModule($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderCouponModule relation
|
||||
*
|
||||
* @method ChildOrderCoupon findOne(ConnectionInterface $con = null) Return the first ChildOrderCoupon matching the query
|
||||
* @method ChildOrderCoupon findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderCoupon matching the query, or a new ChildOrderCoupon object populated from the query conditions when no match is found
|
||||
*
|
||||
@@ -856,6 +864,186 @@ abstract class OrderCouponQuery extends ModelCriteria
|
||||
->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\OrderCouponCountry object
|
||||
*
|
||||
* @param \Thelia\Model\OrderCouponCountry|ObjectCollection $orderCouponCountry the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByOrderCouponCountry($orderCouponCountry, $comparison = null)
|
||||
{
|
||||
if ($orderCouponCountry instanceof \Thelia\Model\OrderCouponCountry) {
|
||||
return $this
|
||||
->addUsingAlias(OrderCouponTableMap::ID, $orderCouponCountry->getCouponId(), $comparison);
|
||||
} elseif ($orderCouponCountry instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useOrderCouponCountryQuery()
|
||||
->filterByPrimaryKeys($orderCouponCountry->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByOrderCouponCountry() only accepts arguments of type \Thelia\Model\OrderCouponCountry or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the OrderCouponCountry relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildOrderCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinOrderCouponCountry($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('OrderCouponCountry');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'OrderCouponCountry');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the OrderCouponCountry relation OrderCouponCountry object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\OrderCouponCountryQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useOrderCouponCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinOrderCouponCountry($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'OrderCouponCountry', '\Thelia\Model\OrderCouponCountryQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\OrderCouponModule object
|
||||
*
|
||||
* @param \Thelia\Model\OrderCouponModule|ObjectCollection $orderCouponModule the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByOrderCouponModule($orderCouponModule, $comparison = null)
|
||||
{
|
||||
if ($orderCouponModule instanceof \Thelia\Model\OrderCouponModule) {
|
||||
return $this
|
||||
->addUsingAlias(OrderCouponTableMap::ID, $orderCouponModule->getCouponId(), $comparison);
|
||||
} elseif ($orderCouponModule instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useOrderCouponModuleQuery()
|
||||
->filterByPrimaryKeys($orderCouponModule->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByOrderCouponModule() only accepts arguments of type \Thelia\Model\OrderCouponModule or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the OrderCouponModule relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildOrderCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinOrderCouponModule($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('OrderCouponModule');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'OrderCouponModule');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the OrderCouponModule relation OrderCouponModule object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\OrderCouponModuleQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useOrderCouponModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinOrderCouponModule($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'OrderCouponModule', '\Thelia\Model\OrderCouponModuleQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related Country object
|
||||
* using the order_coupon_country table as cross reference
|
||||
*
|
||||
* @param Country $country the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByCountry($country, $comparison = Criteria::EQUAL)
|
||||
{
|
||||
return $this
|
||||
->useOrderCouponCountryQuery()
|
||||
->filterByCountry($country, $comparison)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related Module object
|
||||
* using the order_coupon_module table as cross reference
|
||||
*
|
||||
* @param Module $module the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderCouponQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByModule($module, $comparison = Criteria::EQUAL)
|
||||
{
|
||||
return $this
|
||||
->useOrderCouponModuleQuery()
|
||||
->filterByModule($module, $comparison)
|
||||
->endUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user