/** * 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->aLibro !== null) { if ($this->aLibro->isModified() || $this->aLibro->isNew()) { $affectedRows += $this->aLibro->save($con); } $this->setLibro($this->aLibro); } 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; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Libro(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Libro'])) { $model->attributes = $_POST['Libro']; if ($model->save()) { if (file_exists(Yii::getPathOfAlias('webroot') . '/images/portadas/0_BIG.png')) { if (copy(Yii::getPathOfAlias('webroot') . '/images/portadas/0_BIG.png', Yii::getPathOfAlias('webroot') . '/images/portadas/' . $model->IdLibro . '.png')) { } } $this->redirect(array('view', 'id' => $model->IdLibro)); } } $this->render('create', array('model' => $model)); }
/** * 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->aLibro !== null) { if ($this->aLibro->isModified() || $this->aLibro->isNew()) { $affectedRows += $this->aLibro->save($con); } $this->setLibro($this->aLibro); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } if ($this->lista_audiolibrosScheduledForDeletion !== null) { if (!$this->lista_audiolibrosScheduledForDeletion->isEmpty()) { Lista_audiolibroQuery::create()->filterByPrimaryKeys($this->lista_audiolibrosScheduledForDeletion->getPrimaryKeys(false))->delete($con); $this->lista_audiolibrosScheduledForDeletion = null; } } if ($this->collLista_audiolibros !== null) { foreach ($this->collLista_audiolibros as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
echo json_encode(array('msg' => "Libro guardado correctamente", 'idlibro' => $libroObj->getId())); } else { $libroObj = LibroQuery::create()->findOneById($datos->idlibro); $libroObj->setNombre($datos->nombrelibro); //$libroObj->setTexto($datos->texto); $libroObj->save(); file_put_contents(SITE_PATH . "/libros/libro_" . $datos->idlibro . ".txt", $datos->texto); echo json_encode(array('msg' => "Libro guardado correctamente", 'idlibro' => $datos->idlibro)); } break; case "version": //diff -y -T --suppress-common-lines -a --strip-trailing-cr indexold.php index.php if ($datos->idlibro == "") { $libroObj = new Libro(); $libroObj->setNombre($datos->nombrelibro); $libroObj->save(); $idLibro = $libroObj->getId(); } else { $idLibro = $datos->idlibro; } $libroVersion = new Libro_version(); $libroVersion->setIdlibro($idLibro); $libroVersion->setFecha(date("Y-m-d")); $libroVersion->setHora(date("H:i:s")); $libroVersion->setIdusuario($_SESSION['userid']); $libroVersion->save(); file_put_contents(SITE_PATH . "/libros_version/libro_" . $idLibro . "_" . $libroVersion->getId() . ".txt", base64_decode($datos->texto)); echo json_encode(array('msg' => "Libro guardado correctamente", 'idlibro' => $idLibro)); break; case "marcarActividad": $fecha = date("Y-m-d");