/** * 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aBrandImage !== null) { if ($this->aBrandImage->isModified() || $this->aBrandImage->isNew()) { $affectedRows += $this->aBrandImage->save($con); } $this->setBrandImage($this->aBrandImage); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } $this->alreadyInSave = false; } return $affectedRows; }
/** * 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aBrandImageRelatedByLogoImageId !== null) { if ($this->aBrandImageRelatedByLogoImageId->isModified() || $this->aBrandImageRelatedByLogoImageId->isNew()) { $affectedRows += $this->aBrandImageRelatedByLogoImageId->save($con); } $this->setBrandImageRelatedByLogoImageId($this->aBrandImageRelatedByLogoImageId); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } if ($this->productsScheduledForDeletion !== null) { if (!$this->productsScheduledForDeletion->isEmpty()) { foreach ($this->productsScheduledForDeletion as $product) { // need to save related object because we set the relation to null $product->save($con); } $this->productsScheduledForDeletion = null; } } if ($this->collProducts !== null) { foreach ($this->collProducts as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->brandDocumentsScheduledForDeletion !== null) { if (!$this->brandDocumentsScheduledForDeletion->isEmpty()) { \Thelia\Model\BrandDocumentQuery::create()->filterByPrimaryKeys($this->brandDocumentsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->brandDocumentsScheduledForDeletion = null; } } if ($this->collBrandDocuments !== null) { foreach ($this->collBrandDocuments as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->brandImagesRelatedByBrandIdScheduledForDeletion !== null) { if (!$this->brandImagesRelatedByBrandIdScheduledForDeletion->isEmpty()) { \Thelia\Model\BrandImageQuery::create()->filterByPrimaryKeys($this->brandImagesRelatedByBrandIdScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->brandImagesRelatedByBrandIdScheduledForDeletion = null; } } if ($this->collBrandImagesRelatedByBrandId !== null) { foreach ($this->collBrandImagesRelatedByBrandId as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->brandI18nsScheduledForDeletion !== null) { if (!$this->brandI18nsScheduledForDeletion->isEmpty()) { \Thelia\Model\BrandI18nQuery::create()->filterByPrimaryKeys($this->brandI18nsScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->brandI18nsScheduledForDeletion = null; } } if ($this->collBrandI18ns !== null) { foreach ($this->collBrandI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }