コード例 #1
0
ファイル: Order.php プロジェクト: shirone/thelia
 /**
  * retrieve the last $number versions.
  *
  * @param Integer $number the number of record to return.
  * @return PropelCollection|array \Thelia\Model\OrderVersion[] List of \Thelia\Model\OrderVersion objects
  */
 public function getLastVersions($number = 10, $criteria = null, $con = null)
 {
     $criteria = ChildOrderVersionQuery::create(null, $criteria);
     $criteria->addDescendingOrderByColumn(OrderVersionTableMap::VERSION);
     $criteria->limit($number);
     return $this->getOrderVersions($criteria, $con);
 }
コード例 #2
0
ファイル: OrderVersion.php プロジェクト: shirone/thelia
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      ConnectionInterface $con
  * @return void
  * @throws PropelException
  * @see OrderVersion::setDeleted()
  * @see OrderVersion::isDeleted()
  */
 public function delete(ConnectionInterface $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getServiceContainer()->getWriteConnection(OrderVersionTableMap::DATABASE_NAME);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = ChildOrderVersionQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
コード例 #3
0
ファイル: Customer.php プロジェクト: shirone/thelia
 /**
  * Sets the properties of the current object to the value they had at a specific version
  *
  * @param ChildCustomerVersion $version The version object to use
  * @param ConnectionInterface   $con the connection to use
  * @param array                 $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects.
  *
  * @return ChildCustomer The current object (for fluent API support)
  */
 public function populateFromVersion($version, $con = null, &$loadedObjects = array())
 {
     $loadedObjects['ChildCustomer'][$version->getId()][$version->getVersion()] = $this;
     $this->setId($version->getId());
     $this->setRef($version->getRef());
     $this->setTitleId($version->getTitleId());
     $this->setFirstname($version->getFirstname());
     $this->setLastname($version->getLastname());
     $this->setEmail($version->getEmail());
     $this->setPassword($version->getPassword());
     $this->setAlgo($version->getAlgo());
     $this->setReseller($version->getReseller());
     $this->setLang($version->getLang());
     $this->setSponsor($version->getSponsor());
     $this->setDiscount($version->getDiscount());
     $this->setRememberMeToken($version->getRememberMeToken());
     $this->setRememberMeSerial($version->getRememberMeSerial());
     $this->setCreatedAt($version->getCreatedAt());
     $this->setUpdatedAt($version->getUpdatedAt());
     $this->setVersion($version->getVersion());
     $this->setVersionCreatedAt($version->getVersionCreatedAt());
     $this->setVersionCreatedBy($version->getVersionCreatedBy());
     if ($fkValues = $version->getOrderIds()) {
         $this->clearOrders();
         $fkVersions = $version->getOrderVersions();
         $query = ChildOrderVersionQuery::create();
         foreach ($fkValues as $key => $value) {
             $c1 = $query->getNewCriterion(OrderVersionTableMap::ID, $value);
             $c2 = $query->getNewCriterion(OrderVersionTableMap::VERSION, $fkVersions[$key]);
             $c1->addAnd($c2);
             $query->addOr($c1);
         }
         foreach ($query->find($con) as $relatedVersion) {
             if (isset($loadedObjects['ChildOrder']) && isset($loadedObjects['ChildOrder'][$relatedVersion->getId()]) && isset($loadedObjects['ChildOrder'][$relatedVersion->getId()][$relatedVersion->getVersion()])) {
                 $related = $loadedObjects['ChildOrder'][$relatedVersion->getId()][$relatedVersion->getVersion()];
             } else {
                 $related = new ChildOrder();
                 $related->populateFromVersion($relatedVersion, $con, $loadedObjects);
                 $related->setNew(false);
             }
             $this->addOrder($related);
             $this->collOrdersPartial = false;
         }
     }
     return $this;
 }
コード例 #4
0
 /**
  * Performs an INSERT on the database, given a OrderVersion or Criteria object.
  *
  * @param mixed               $criteria Criteria or OrderVersion object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(OrderVersionTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from OrderVersion object
     }
     // Set the correct dbName
     $query = OrderVersionQuery::create()->mergeWith($criteria);
     try {
         // use transaction because $criteria could contain info
         // for more than one table (I guess, conceivably)
         $con->beginTransaction();
         $pk = $query->doInsert($con);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
     return $pk;
 }