/** * Checks and repairs the internal consistency of the object. * * This method is executed after an already-instantiated object is re-hydrated * from the database. It exists to check any foreign keys to make sure that * the objects related to the current object are correct based on foreign key. * * You can override this method in the stub class, but you should always invoke * the base method from the overridden method (i.e. parent::ensureConsistency()), * in case your model changes. * * @throws PropelException */ public function ensureConsistency() { if ($this->aSale !== null && $this->sale_id !== $this->aSale->getId()) { $this->aSale = null; } if ($this->aCurrency !== null && $this->currency_id !== $this->aCurrency->getId()) { $this->aCurrency = null; } }
/** * Checks and repairs the internal consistency of the object. * * This method is executed after an already-instantiated object is re-hydrated * from the database. It exists to check any foreign keys to make sure that * the objects related to the current object are correct based on foreign key. * * You can override this method in the stub class, but you should always invoke * the base method from the overridden method (i.e. parent::ensureConsistency()), * in case your model changes. * * @throws PropelException */ public function ensureConsistency() { if ($this->aSale !== null && $this->sale_id !== $this->aSale->getId()) { $this->aSale = null; } if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { $this->aProduct = null; } if ($this->aAttributeAv !== null && $this->attribute_av_id !== $this->aAttributeAv->getId()) { $this->aAttributeAv = null; } }
<?php set_include_path(dirname(_FILE_) . '/../'); require_once 'class/Object.class.php'; require_once 'class/Period.class.php'; require_once 'class/Sale.class.php'; /* //Pour créer une vente, on a besoin d'un objet et d'une période $Objet = new Object(2); $Period = new Period(11); echo '<h2>Création</h2>'; $Sale = new Sale(0, $Objet, $Period, 'vente 2'); echo $Sale->getState(); echo $Sale->getId(); echo $Sale->getName(); echo $Sale->getObject()->getName(); echo $Sale->getPeriod()->getDateEnd(); */ echo '<h2>Lecture</h2>'; $Sale = new Sale(1); //echo $Sale->setPeriod(new Period(2)); echo $Sale->setName('toto'); echo $Sale->getState(); echo $Sale->getId(); echo $Sale->getName(); echo $Sale->getObject()->getName(); echo $Sale->getPeriod()->getDateEnd();
/** * ajoute une nouvelle vente en reprennant le nom de la periode pour simplifier * @param int $obj_id * @param int $per_id * @return String $csvResult */ public function addSale($obj_id, $per_id) { $rtn = new ComplexData(); $obj = new Object($obj_id); if ($obj->getState() != 1) { $rtn->addLine(array($obj->getState(), 0)); return $rtn->csvArrays(); } $per = new Period($per_id); if ($per->getState() != 1) { $rtn->addLine(array($per->getState(), 0)); return $rtn->csvArrays(); } $sale = new Sale(0, $obj, $per, $per->getName()); $rtn->addLine(array($sale->getState(), $sale->getId())); return $rtn->csvArrays(); }
/** * Declares an association between this object and a Sale object. * * @param Sale $v * @return ProductHasSale The current object (for fluent API support) * @throws PropelException */ public function setSale(Sale $v = null) { if ($v === null) { $this->setSaleId(NULL); } else { $this->setSaleId($v->getId()); } $this->aSale = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Sale object, it will not be re-added. if ($v !== null) { $v->addProductHasSale($this); } return $this; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Sale $value A Sale object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Sale $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * Checks and repairs the internal consistency of the object. * * This method is executed after an already-instantiated object is re-hydrated * from the database. It exists to check any foreign keys to make sure that * the objects related to the current object are correct based on foreign key. * * You can override this method in the stub class, but you should always invoke * the base method from the overridden method (i.e. parent::ensureConsistency()), * in case your model changes. * * @throws PropelException */ public function ensureConsistency() { if ($this->aSale !== null && $this->id !== $this->aSale->getId()) { $this->aSale = null; } }