/**
  * 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->aAudiolibro !== null) {
             if ($this->aAudiolibro->isModified() || $this->aAudiolibro->isNew()) {
                 $affectedRows += $this->aAudiolibro->save($con);
             }
             $this->setAudiolibro($this->aAudiolibro);
         }
         if ($this->aLista !== null) {
             if ($this->aLista->isModified() || $this->aLista->isNew()) {
                 $affectedRows += $this->aLista->save($con);
             }
             $this->setLista($this->aLista);
         }
         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;
 }
Ejemplo n.º 2
0
     break;
 case "d":
     //Delete
     $audiolibroObj = AudiolibroQuery::create()->findOneBy($_POST["id"]);
     //$objTerapia = TerapiasQuery::create()->findOneById($_GET["id"]);
     if ($audiolibroObj != null) {
         $audiolibroObj->delete();
     }
     echo json_encode(array('error' => 0, 'msg' => "Audiolibro borrado correctamente"));
     break;
 case "n":
     //New
     $audiolibroObj = new Audiolibro();
     $audiolibroObj->setNombre($_POST["nombreaudio"]);
     $audiolibroObj->setIdlibro($_POST["vinculolibro"]);
     $audiolibroObj->save();
     $idLibro = $audiolibroObj->getId();
     // obtenemos los datos del archivo
     $tamano = $_FILES["mp3"]['size'];
     $tipo = $_FILES["mp3"]['type'];
     $archivo = $_FILES["mp3"]['name'];
     //$prefijo = substr(md5(uniqid(rand())),0,6);
     //echo $_FILES['mp3']['tmp_name'];
     //VER!!!
     if ($archivo != "") {
         //$nom=date('Y-m-d H:i:s');
         //$hasharchivo = hash('md5',$nom);
         // $audiolibroObj->setHash($datosaudio->hasharchivo);
         //echo $hasharchivo;
         // guardamos el archivo a la carpeta files
         $destino = "../../uploads/" . $idLibro . '.mp3';