コード例 #1
0
ファイル: BaseRecipe.php プロジェクト: keneanung/gw2spidy
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aDiscipline !== null) {
             if ($this->aDiscipline->isModified() || $this->aDiscipline->isNew()) {
                 $affectedRows += $this->aDiscipline->save($con);
             }
             $this->setDiscipline($this->aDiscipline);
         }
         if ($this->aResultItem !== null) {
             if ($this->aResultItem->isModified() || $this->aResultItem->isNew()) {
                 $affectedRows += $this->aResultItem->save($con);
             }
             $this->setResultItem($this->aResultItem);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->itemsScheduledForDeletion !== null) {
             if (!$this->itemsScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 $pk = $this->getPrimaryKey();
                 foreach ($this->itemsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
                     $pks[] = array($pk, $remotePk);
                 }
                 IngredientQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->itemsScheduledForDeletion = null;
             }
             foreach ($this->getItems() as $item) {
                 if ($item->isModified()) {
                     $item->save($con);
                 }
             }
         }
         if ($this->ingredientsScheduledForDeletion !== null) {
             if (!$this->ingredientsScheduledForDeletion->isEmpty()) {
                 RecipeIngredientQuery::create()->filterByPrimaryKeys($this->ingredientsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->ingredientsScheduledForDeletion = null;
             }
         }
         if ($this->collIngredients !== null) {
             foreach ($this->collIngredients as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
コード例 #2
0
ファイル: BaseItem.php プロジェクト: keneanung/gw2spidy
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aItemType !== null) {
             if ($this->aItemType->isModified() || $this->aItemType->isNew()) {
                 $affectedRows += $this->aItemType->save($con);
             }
             $this->setItemType($this->aItemType);
         }
         if ($this->aItemSubType !== null) {
             if ($this->aItemSubType->isModified() || $this->aItemSubType->isNew()) {
                 $affectedRows += $this->aItemSubType->save($con);
             }
             $this->setItemSubType($this->aItemSubType);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->recipesScheduledForDeletion !== null) {
             if (!$this->recipesScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 $pk = $this->getPrimaryKey();
                 foreach ($this->recipesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
                     $pks[] = array($remotePk, $pk);
                 }
                 IngredientQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->recipesScheduledForDeletion = null;
             }
             foreach ($this->getRecipes() as $recipe) {
                 if ($recipe->isModified()) {
                     $recipe->save($con);
                 }
             }
         }
         if ($this->usersScheduledForDeletion !== null) {
             if (!$this->usersScheduledForDeletion->isEmpty()) {
                 $pks = array();
                 $pk = $this->getPrimaryKey();
                 foreach ($this->usersScheduledForDeletion->getPrimaryKeys(false) as $remotePk) {
                     $pks[] = array($remotePk, $pk);
                 }
                 OnWatchlistQuery::create()->filterByPrimaryKeys($pks)->delete($con);
                 $this->usersScheduledForDeletion = null;
             }
             foreach ($this->getUsers() as $user) {
                 if ($user->isModified()) {
                     $user->save($con);
                 }
             }
         }
         if ($this->resultOfRecipesScheduledForDeletion !== null) {
             if (!$this->resultOfRecipesScheduledForDeletion->isEmpty()) {
                 foreach ($this->resultOfRecipesScheduledForDeletion as $resultOfRecipe) {
                     // need to save related object because we set the relation to null
                     $resultOfRecipe->save($con);
                 }
                 $this->resultOfRecipesScheduledForDeletion = null;
             }
         }
         if ($this->collResultOfRecipes !== null) {
             foreach ($this->collResultOfRecipes as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->ingredientsScheduledForDeletion !== null) {
             if (!$this->ingredientsScheduledForDeletion->isEmpty()) {
                 RecipeIngredientQuery::create()->filterByPrimaryKeys($this->ingredientsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->ingredientsScheduledForDeletion = null;
             }
         }
         if ($this->collIngredients !== null) {
             foreach ($this->collIngredients as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->sellListingsScheduledForDeletion !== null) {
             if (!$this->sellListingsScheduledForDeletion->isEmpty()) {
                 SellListingQuery::create()->filterByPrimaryKeys($this->sellListingsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->sellListingsScheduledForDeletion = null;
             }
         }
         if ($this->collSellListings !== null) {
             foreach ($this->collSellListings as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->buyListingsScheduledForDeletion !== null) {
             if (!$this->buyListingsScheduledForDeletion->isEmpty()) {
                 BuyListingQuery::create()->filterByPrimaryKeys($this->buyListingsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->buyListingsScheduledForDeletion = null;
             }
         }
         if ($this->collBuyListings !== null) {
             foreach ($this->collBuyListings as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->onWatchlistsScheduledForDeletion !== null) {
             if (!$this->onWatchlistsScheduledForDeletion->isEmpty()) {
                 WatchlistQuery::create()->filterByPrimaryKeys($this->onWatchlistsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->onWatchlistsScheduledForDeletion = null;
             }
         }
         if ($this->collOnWatchlists !== null) {
             foreach ($this->collOnWatchlists as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }