/** * Returns a new GeneroQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return GeneroQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof GeneroQuery) { return $criteria; } $query = new GeneroQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
include_once "../../data/config.php"; //echo "<pre>";print_r(json_decode($_POST['json'])); echo "</pre>"; $datos = json_decode($_POST['json']); //$libros = LibroQuery::create()->find(); //$usuarios = UsuarioQuery::create()->find(); switch ($datos->accion) { case "e": //Edit $generoObj = GeneroQuery::create()->findOneById($datos->id); //echo $generosObj->toArray(); $generoObj->setNombre($datos->nombre); $generoObj->save(); echo json_encode(array('error' => 0, 'msg' => "Genero modificado correctamente")); break; case "d": //Delete $generoObj = GeneroQuery::create()->findOneById($datos->id); //$objTerapia = TerapiasQuery::create()->findOneById($_GET["id"]); if ($generoObj != null) { $generoObj->delete(); } echo json_encode(array('error' => 0, 'msg' => "genero borrado correctamente")); break; case "n": //New $generoObj = new Genero(); $generoObj->setNombre($datos->nombre); $generoObj->save(); echo json_encode(array('error' => 0, 'msg' => "Genero creado correctamente")); break; }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(GeneroPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = GeneroQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
<input type="text" id="nombrelista" id="libro" /> </div> <div class="cont"> <label style="margin-left:10px;">Género: </label> <br /> <select id="generolista" id="libro" > <?php /* include('php/servicio.php'); $sql = "SELECT * FROM genero"; $result= query($sql,0); while($row = mysql_fetch_array($result)) {echo '<option value="'.$row['id'].'">'.$row['nombre'].'</option>'; }*/ //$genero = au $objGeneros = GeneroQuery::create()->find(); foreach ($objGeneros as $pf) { //$obrassociales[] = array('id'=>$pf->getId(),'nombre'=>$pf->getNombre()); echo '<option value="' . $pf->getId() . '">' . $pf->getNombre() . '</option>'; } ?> </select> </div> <div class="cont"> <label style="margin-left:10px;">Privacidad: </label> <br /> <select id="privacidadlista" onchange="preguntosicomparte();"> <option value="0">Privada (sólo yo)</option> <option value="1">Pública</option>
/** * Get the associated Genero object * * @param PropelPDO Optional Connection object. * @return Genero The associated Genero object. * @throws PropelException */ public function getGenero(PropelPDO $con = null) { if ($this->aGenero === null && $this->id_genero !== null) { $this->aGenero = GeneroQuery::create()->findPk($this->id_genero, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aGenero->addListas($this); */ } return $this->aGenero; }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(GeneroPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = GeneroQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // symfony_behaviors behavior foreach (sfMixer::getCallables('BaseGenero:delete:pre') as $callable) { if (call_user_func($callable, $this, $con)) { $con->commit(); return; } } if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); // symfony_behaviors behavior foreach (sfMixer::getCallables('BaseGenero:delete:post') as $callable) { call_user_func($callable, $this, $con); } $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }