/** * Selects a collection of Empresa objects pre-filled with all related objects except Taula1. * * @param Criteria $c * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of Empresa objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptTaula1(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $c = clone $c; // Set the correct dbName if it has not been overridden // $c->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } EmpresaPeer::addSelectColumns($c); $startcol2 = EmpresaPeer::NUM_COLUMNS - EmpresaPeer::NUM_LAZY_LOAD_COLUMNS; ProvinciaPeer::addSelectColumns($c); $startcol3 = $startcol2 + (ProvinciaPeer::NUM_COLUMNS - ProvinciaPeer::NUM_LAZY_LOAD_COLUMNS); UsuarioPeer::addSelectColumns($c); $startcol4 = $startcol3 + (UsuarioPeer::NUM_COLUMNS - UsuarioPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(EmpresaPeer::ID_PROVINCIA), array(ProvinciaPeer::ID_PROVINCIA), $join_behavior); $c->addJoin(array(EmpresaPeer::ID_USUARIO), array(UsuarioPeer::ID_USUARIO), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = EmpresaPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = EmpresaPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://propel.phpdb.org/trac/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $omClass = EmpresaPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); EmpresaPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Provincia rows $key2 = ProvinciaPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = ProvinciaPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = ProvinciaPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); ProvinciaPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Empresa) to the collection in $obj2 (Provincia) $obj2->addEmpresa($obj1); } // if joined row is not null // Add objects for joined Usuario rows $key3 = UsuarioPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = UsuarioPeer::getInstanceFromPool($key3); if (!$obj3) { $omClass = UsuarioPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); UsuarioPeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded // Add the $obj1 (Empresa) to the collection in $obj3 (Usuario) $obj3->addEmpresa($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
public static function doSelectJoinAllExceptTipolocacion(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } LocacionPeer::addSelectColumns($c); $startcol2 = LocacionPeer::NUM_COLUMNS - LocacionPeer::NUM_LAZY_LOAD_COLUMNS; ProvinciaPeer::addSelectColumns($c); $startcol3 = $startcol2 + (ProvinciaPeer::NUM_COLUMNS - ProvinciaPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(LocacionPeer::FK_PROVINCIA_ID), array(ProvinciaPeer::ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = LocacionPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = LocacionPeer::getInstanceFromPool($key1))) { } else { $omClass = LocacionPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); LocacionPeer::addInstanceToPool($obj1, $key1); } $key2 = ProvinciaPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = ProvinciaPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = ProvinciaPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); ProvinciaPeer::addInstanceToPool($obj2, $key2); } $obj2->addLocacion($obj1); } $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * The returned array will contain objects of the default type or * objects that inherit from the default. * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function populateObjects(PDOStatement $stmt) { $results = array(); // set the class once to avoid overhead in the loop $cls = ProvinciaPeer::getOMClass(); $cls = substr('.' . $cls, strrpos('.' . $cls, '.') + 1); // populate the object(s) while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key = ProvinciaPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj = ProvinciaPeer::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://propel.phpdb.org/trac/ticket/509 // $obj->hydrate($row, 0, true); // rehydrate $results[] = $obj; } else { $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; ProvinciaPeer::addInstanceToPool($obj, $key); } // if key exists } $stmt->closeCursor(); return $results; }
/** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. * * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * * @return Provincia A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { $sql = 'SELECT `IDPROVINCIA`, `PROVINCIA` FROM `provincia` WHERE `IDPROVINCIA` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); } $obj = null; if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $obj = new Provincia(); $obj->hydrate($row); ProvinciaPeer::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); return $obj; }
/** * Populates an object of the default type or an object that inherit from the default. * * @param array $row PropelPDO resultset row. * @param int $startcol The 0-based offset for reading from the resultset row. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. * @return array (Provincia object, last column rank) */ public static function populateObject($row, $startcol = 0) { $key = ProvinciaPeer::getPrimaryKeyHashFromRow($row, $startcol); if (null !== ($obj = ProvinciaPeer::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, $startcol, true); // rehydrate $col = $startcol + ProvinciaPeer::NUM_HYDRATE_COLUMNS; } else { $cls = ProvinciaPeer::OM_CLASS; $obj = new $cls(); $col = $obj->hydrate($row, $startcol); ProvinciaPeer::addInstanceToPool($obj, $key); } return array($obj, $col); }
public static function doSelectJoinAllExceptNivelInstruccion(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } ResponsablePeer::addSelectColumns($c); $startcol2 = ResponsablePeer::NUM_COLUMNS - ResponsablePeer::NUM_LAZY_LOAD_COLUMNS; ProvinciaPeer::addSelectColumns($c); $startcol3 = $startcol2 + (ProvinciaPeer::NUM_COLUMNS - ProvinciaPeer::NUM_LAZY_LOAD_COLUMNS); TipodocumentoPeer::addSelectColumns($c); $startcol4 = $startcol3 + (TipodocumentoPeer::NUM_COLUMNS - TipodocumentoPeer::NUM_LAZY_LOAD_COLUMNS); CuentaPeer::addSelectColumns($c); $startcol5 = $startcol4 + (CuentaPeer::NUM_COLUMNS - CuentaPeer::NUM_LAZY_LOAD_COLUMNS); RolResponsablePeer::addSelectColumns($c); $startcol6 = $startcol5 + (RolResponsablePeer::NUM_COLUMNS - RolResponsablePeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(ResponsablePeer::FK_PROVINCIA_ID), array(ProvinciaPeer::ID), $join_behavior); $c->addJoin(array(ResponsablePeer::FK_TIPODOCUMENTO_ID), array(TipodocumentoPeer::ID), $join_behavior); $c->addJoin(array(ResponsablePeer::FK_CUENTA_ID), array(CuentaPeer::ID), $join_behavior); $c->addJoin(array(ResponsablePeer::FK_ROLRESPONSABLE_ID), array(RolResponsablePeer::ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = ResponsablePeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = ResponsablePeer::getInstanceFromPool($key1))) { } else { $omClass = ResponsablePeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); ResponsablePeer::addInstanceToPool($obj1, $key1); } $key2 = ProvinciaPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = ProvinciaPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = ProvinciaPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); ProvinciaPeer::addInstanceToPool($obj2, $key2); } $obj2->addResponsable($obj1); } $key3 = TipodocumentoPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = TipodocumentoPeer::getInstanceFromPool($key3); if (!$obj3) { $omClass = TipodocumentoPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); TipodocumentoPeer::addInstanceToPool($obj3, $key3); } $obj3->addResponsable($obj1); } $key4 = CuentaPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = CuentaPeer::getInstanceFromPool($key4); if (!$obj4) { $omClass = CuentaPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); CuentaPeer::addInstanceToPool($obj4, $key4); } $obj4->addResponsable($obj1); } $key5 = RolResponsablePeer::getPrimaryKeyHashFromRow($row, $startcol5); if ($key5 !== null) { $obj5 = RolResponsablePeer::getInstanceFromPool($key5); if (!$obj5) { $omClass = RolResponsablePeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj5 = new $cls(); $obj5->hydrate($row, $startcol5); RolResponsablePeer::addInstanceToPool($obj5, $key5); } $obj5->addResponsable($obj1); } $results[] = $obj1; } $stmt->closeCursor(); return $results; }
public function save(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("You cannot save an object that has been deleted."); } if ($con === null) { $con = Propel::getConnection(ProvinciaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $affectedRows = $this->doSave($con); $con->commit(); ProvinciaPeer::addInstanceToPool($this); return $affectedRows; } catch (PropelException $e) { $con->rollBack(); throw $e; } }
public static function doSelectJoinAllExceptNiveltipo(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } EstablecimientoPeer::addSelectColumns($c); $startcol2 = EstablecimientoPeer::NUM_COLUMNS - EstablecimientoPeer::NUM_LAZY_LOAD_COLUMNS; DistritoescolarPeer::addSelectColumns($c); $startcol3 = $startcol2 + (DistritoescolarPeer::NUM_COLUMNS - DistritoescolarPeer::NUM_LAZY_LOAD_COLUMNS); OrganizacionPeer::addSelectColumns($c); $startcol4 = $startcol3 + (OrganizacionPeer::NUM_COLUMNS - OrganizacionPeer::NUM_LAZY_LOAD_COLUMNS); ProvinciaPeer::addSelectColumns($c); $startcol5 = $startcol4 + (ProvinciaPeer::NUM_COLUMNS - ProvinciaPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(EstablecimientoPeer::FK_DISTRITOESCOLAR_ID), array(DistritoescolarPeer::ID), $join_behavior); $c->addJoin(array(EstablecimientoPeer::FK_ORGANIZACION_ID), array(OrganizacionPeer::ID), $join_behavior); $c->addJoin(array(EstablecimientoPeer::FK_PROVINCIA_ID), array(ProvinciaPeer::ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = EstablecimientoPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = EstablecimientoPeer::getInstanceFromPool($key1))) { } else { $omClass = EstablecimientoPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); EstablecimientoPeer::addInstanceToPool($obj1, $key1); } $key2 = DistritoescolarPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = DistritoescolarPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = DistritoescolarPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); DistritoescolarPeer::addInstanceToPool($obj2, $key2); } $obj2->addEstablecimiento($obj1); } $key3 = OrganizacionPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = OrganizacionPeer::getInstanceFromPool($key3); if (!$obj3) { $omClass = OrganizacionPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); OrganizacionPeer::addInstanceToPool($obj3, $key3); } $obj3->addEstablecimiento($obj1); } $key4 = ProvinciaPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = ProvinciaPeer::getInstanceFromPool($key4); if (!$obj4) { $omClass = ProvinciaPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); ProvinciaPeer::addInstanceToPool($obj4, $key4); } $obj4->addEstablecimiento($obj1); } $results[] = $obj1; } $stmt->closeCursor(); return $results; }
public static function doSelectJoinAllExceptEstadosalumnos(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } AlumnoPeer::addSelectColumns($c); $startcol2 = AlumnoPeer::NUM_COLUMNS - AlumnoPeer::NUM_LAZY_LOAD_COLUMNS; ProvinciaPeer::addSelectColumns($c); $startcol3 = $startcol2 + (ProvinciaPeer::NUM_COLUMNS - ProvinciaPeer::NUM_LAZY_LOAD_COLUMNS); TipodocumentoPeer::addSelectColumns($c); $startcol4 = $startcol3 + (TipodocumentoPeer::NUM_COLUMNS - TipodocumentoPeer::NUM_LAZY_LOAD_COLUMNS); EstablecimientoPeer::addSelectColumns($c); $startcol5 = $startcol4 + (EstablecimientoPeer::NUM_COLUMNS - EstablecimientoPeer::NUM_LAZY_LOAD_COLUMNS); CuentaPeer::addSelectColumns($c); $startcol6 = $startcol5 + (CuentaPeer::NUM_COLUMNS - CuentaPeer::NUM_LAZY_LOAD_COLUMNS); ConceptobajaPeer::addSelectColumns($c); $startcol7 = $startcol6 + (ConceptobajaPeer::NUM_COLUMNS - ConceptobajaPeer::NUM_LAZY_LOAD_COLUMNS); PaisPeer::addSelectColumns($c); $startcol8 = $startcol7 + (PaisPeer::NUM_COLUMNS - PaisPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(AlumnoPeer::FK_PROVINCIA_ID), array(ProvinciaPeer::ID), $join_behavior); $c->addJoin(array(AlumnoPeer::FK_TIPODOCUMENTO_ID), array(TipodocumentoPeer::ID), $join_behavior); $c->addJoin(array(AlumnoPeer::FK_ESTABLECIMIENTO_ID), array(EstablecimientoPeer::ID), $join_behavior); $c->addJoin(array(AlumnoPeer::FK_CUENTA_ID), array(CuentaPeer::ID), $join_behavior); $c->addJoin(array(AlumnoPeer::FK_CONCEPTOBAJA_ID), array(ConceptobajaPeer::ID), $join_behavior); $c->addJoin(array(AlumnoPeer::FK_PAIS_ID), array(PaisPeer::ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = AlumnoPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = AlumnoPeer::getInstanceFromPool($key1))) { } else { $omClass = AlumnoPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); AlumnoPeer::addInstanceToPool($obj1, $key1); } $key2 = ProvinciaPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = ProvinciaPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = ProvinciaPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); ProvinciaPeer::addInstanceToPool($obj2, $key2); } $obj2->addAlumno($obj1); } $key3 = TipodocumentoPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = TipodocumentoPeer::getInstanceFromPool($key3); if (!$obj3) { $omClass = TipodocumentoPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); TipodocumentoPeer::addInstanceToPool($obj3, $key3); } $obj3->addAlumno($obj1); } $key4 = EstablecimientoPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = EstablecimientoPeer::getInstanceFromPool($key4); if (!$obj4) { $omClass = EstablecimientoPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); EstablecimientoPeer::addInstanceToPool($obj4, $key4); } $obj4->addAlumno($obj1); } $key5 = CuentaPeer::getPrimaryKeyHashFromRow($row, $startcol5); if ($key5 !== null) { $obj5 = CuentaPeer::getInstanceFromPool($key5); if (!$obj5) { $omClass = CuentaPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj5 = new $cls(); $obj5->hydrate($row, $startcol5); CuentaPeer::addInstanceToPool($obj5, $key5); } $obj5->addAlumno($obj1); } $key6 = ConceptobajaPeer::getPrimaryKeyHashFromRow($row, $startcol6); if ($key6 !== null) { $obj6 = ConceptobajaPeer::getInstanceFromPool($key6); if (!$obj6) { $omClass = ConceptobajaPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj6 = new $cls(); $obj6->hydrate($row, $startcol6); ConceptobajaPeer::addInstanceToPool($obj6, $key6); } $obj6->addAlumno($obj1); } $key7 = PaisPeer::getPrimaryKeyHashFromRow($row, $startcol7); if ($key7 !== null) { $obj7 = PaisPeer::getInstanceFromPool($key7); if (!$obj7) { $omClass = PaisPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj7 = new $cls(); $obj7->hydrate($row, $startcol7); PaisPeer::addInstanceToPool($obj7, $key7); } $obj7->addAlumno($obj1); } $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Persists this object to the database. * * If the object is new, it inserts it; otherwise an update is performed. * All modified related objects will also be persisted in the doSave() * method. This method wraps all precipitate database operations in a * single transaction. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see doSave() */ public function save(PropelPDO $con = null) { foreach (sfMixer::getCallables('BaseProvincia:save:pre') as $callable) { $affectedRows = call_user_func($callable, $this, $con); if (is_int($affectedRows)) { return $affectedRows; } } if ($this->isDeleted()) { throw new PropelException("You cannot save an object that has been deleted."); } if ($con === null) { $con = Propel::getConnection(ProvinciaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $affectedRows = $this->doSave($con); $con->commit(); foreach (sfMixer::getCallables('BaseProvincia:save:post') as $callable) { call_user_func($callable, $this, $con, $affectedRows); } ProvinciaPeer::addInstanceToPool($this); return $affectedRows; } catch (PropelException $e) { $con->rollBack(); throw $e; } }
/** * Persists this object to the database. * * If the object is new, it inserts it; otherwise an update is performed. * All modified related objects will also be persisted in the doSave() * method. This method wraps all precipitate database operations in a * single transaction. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see doSave() */ public function save(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("You cannot save an object that has been deleted."); } if ($con === null) { $con = Propel::getConnection(ProvinciaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); $isInsert = $this->isNew(); try { $ret = $this->preSave($con); // symfony_behaviors behavior foreach (sfMixer::getCallables('BaseProvincia:save:pre') as $callable) { if (is_integer($affectedRows = call_user_func($callable, $this, $con))) { $con->commit(); return $affectedRows; } } if ($isInsert) { $ret = $ret && $this->preInsert($con); } else { $ret = $ret && $this->preUpdate($con); } if ($ret) { $affectedRows = $this->doSave($con); if ($isInsert) { $this->postInsert($con); } else { $this->postUpdate($con); } $this->postSave($con); // symfony_behaviors behavior foreach (sfMixer::getCallables('BaseProvincia:save:post') as $callable) { call_user_func($callable, $this, $con, $affectedRows); } ProvinciaPeer::addInstanceToPool($this); } else { $affectedRows = 0; } $con->commit(); return $affectedRows; } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * Selects a collection of Ciudad objects pre-filled with all related objects. * * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of Ciudad objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(self::DATABASE_NAME); } CiudadPeer::addSelectColumns($criteria); $startcol2 = CiudadPeer::NUM_HYDRATE_COLUMNS; ProvinciaPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + ProvinciaPeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(CiudadPeer::ID_PROVINCIA, ProvinciaPeer::IDPROVINCIA, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BaseCiudadPeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = CiudadPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = CiudadPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = CiudadPeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); CiudadPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Provincia rows $key2 = ProvinciaPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = ProvinciaPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = ProvinciaPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); ProvinciaPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (Ciudad) to the collection in $obj2 (Provincia) $obj2->addCiudad($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }