/**
  * 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->aCcFiles !== null) {
             if ($this->aCcFiles->isModified() || $this->aCcFiles->isNew()) {
                 $affectedRows += $this->aCcFiles->save($con);
             }
             $this->setCcFiles($this->aCcFiles);
         }
         if ($this->aCcPlaylist !== null) {
             if ($this->aCcPlaylist->isModified() || $this->aCcPlaylist->isNew()) {
                 $affectedRows += $this->aCcPlaylist->save($con);
             }
             $this->setCcPlaylist($this->aCcPlaylist);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = CcPlaylistcontentsPeer::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(CcPlaylistcontentsPeer::ID)) {
                     throw new PropelException('Cannot insert a value for auto-increment primary key (' . CcPlaylistcontentsPeer::ID . ')');
                 }
                 $pk = BasePeer::doInsert($criteria, $con);
                 $affectedRows += 1;
                 $this->setDbId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += CcPlaylistcontentsPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Exemple #2
0
 /**
  * Create instance of a Playlist object.
  *
  * @param string $p_fname
  * 		Name of the playlist
  * @return Playlist
  */
 public function create($p_fname = NULL)
 {
     $this->name = !empty($p_fname) ? $p_fname : date("H:i:s");
     $this->mtime = new DateTime("now");
     $pl = new CcPlaylist();
     $pl->setDbName($this->name);
     $pl->setDbState("incomplete");
     $pl->setDbMtime($this->mtime);
     $pl->save();
     $this->id = $pl->getDbId();
     $this->setState('ready');
     return $this;
 }