/** * 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->aFkOwner !== null) { if ($this->aFkOwner->isModified() || $this->aFkOwner->isNew()) { $affectedRows += $this->aFkOwner->save($con); } $this->setFkOwner($this->aFkOwner); } if ($this->aCcSubjsRelatedByDbEditedby !== null) { if ($this->aCcSubjsRelatedByDbEditedby->isModified() || $this->aCcSubjsRelatedByDbEditedby->isNew()) { $affectedRows += $this->aCcSubjsRelatedByDbEditedby->save($con); } $this->setCcSubjsRelatedByDbEditedby($this->aCcSubjsRelatedByDbEditedby); } if ($this->aCcMusicDirs !== null) { if ($this->aCcMusicDirs->isModified() || $this->aCcMusicDirs->isNew()) { $affectedRows += $this->aCcMusicDirs->save($con); } $this->setCcMusicDirs($this->aCcMusicDirs); } if ($this->isNew()) { $this->modifiedColumns[] = CcFilesPeer::ID; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $criteria = $this->buildCriteria(); if ($criteria->keyContainsValue(CcFilesPeer::ID)) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcFilesPeer::ID . ')'); } $pk = BasePeer::doInsert($criteria, $con); $affectedRows += 1; $this->setDbId($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += CcFilesPeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } if ($this->collCcShowInstancess !== null) { foreach ($this->collCcShowInstancess as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collCcPlaylistcontentss !== null) { foreach ($this->collCcPlaylistcontentss as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collCcBlockcontentss !== null) { foreach ($this->collCcBlockcontentss as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collCcSchedules !== null) { foreach ($this->collCcSchedules as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } if ($this->collCcPlayoutHistorys !== null) { foreach ($this->collCcPlayoutHistorys as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
public static function addDir($p_path, $p_type) { if (!is_dir($p_path)) { return array("code" => 2, "error" => "'{$p_path}' is not a valid directory."); } $dir = new CcMusicDirs(); $dir->setType($p_type); $p_path = realpath($p_path) . "/"; try { /* isPathValid() checks if path is a substring or a superstring of an * existing dir and if not, throws NestedDirectoryException */ self::isPathValid($p_path); $dir->setDirectory($p_path); $dir->save(); return array("code" => 0); } catch (NestedDirectoryException $nde) { $msg = $nde->getMessage(); return array("code" => 1, "error" => "{$msg}"); } catch (Exception $e) { return array("code" => 1, "error" => "'{$p_path}' is already set as the current storage dir or in the watched folders list"); } }