/** * Selects a collection of Empleadofacturacion 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 Empleadofacturacion 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(EmpleadofacturacionPeer::DATABASE_NAME); } EmpleadofacturacionPeer::addSelectColumns($criteria); $startcol2 = EmpleadofacturacionPeer::NUM_HYDRATE_COLUMNS; EmpleadoPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + EmpleadoPeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(EmpleadofacturacionPeer::IDEMPLEADO, EmpleadoPeer::IDEMPLEADO, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = EmpleadofacturacionPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = EmpleadofacturacionPeer::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 = EmpleadofacturacionPeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); EmpleadofacturacionPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Empleado rows $key2 = EmpleadoPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = EmpleadoPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = EmpleadoPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); EmpleadoPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (Empleadofacturacion) to the collection in $obj2 (Empleado) $obj2->addEmpleadofacturacion($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * This is a method for emulating ON DELETE CASCADE for DBs that don't support this * feature (like MySQL or SQLite). * * This method is not very speedy because it must perform a query first to get * the implicated records and then perform the deletes by calling those Peer classes. * * This method should be used within a transaction if possible. * * @param Criteria $criteria * @param PropelPDO $con * @return int The number of affected rows (if supported by underlying database driver). */ protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con) { // initialize var to track total num of affected rows $affectedRows = 0; // first find the objects that are implicated by the $criteria $objects = RolPeer::doSelect($criteria, $con); foreach ($objects as $obj) { // delete related Empleado objects $criteria = new Criteria(EmpleadoPeer::DATABASE_NAME); $criteria->add(EmpleadoPeer::IDROL, $obj->getIdrol()); $affectedRows += EmpleadoPeer::doDelete($criteria, $con); // delete related Rolmodulo objects $criteria = new Criteria(RolmoduloPeer::DATABASE_NAME); $criteria->add(RolmoduloPeer::IDROL, $obj->getIdrol()); $affectedRows += RolmoduloPeer::doDelete($criteria, $con); } return $affectedRows; }
/** * 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 Empleado A model object, or null if the key is not found * @throws PropelException */ protected function findPkSimple($key, $con) { $sql = 'SELECT `idempleado`, `idrol`, `empleado_nombre`, `empleado_apellidopaterno`, `empleado_apellidomaterno`, `empleado_nombreusuario`, `empleado_password`, `empleado_email`, `empleado_imagen` FROM `empleado` WHERE `idempleado` = :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 Empleado(); $obj->hydrate($row); EmpleadoPeer::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); return $obj; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's BasePeer::TYPE_PHPNAME * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = EmpleadoPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setIdempleado($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setEmpleadoNombre($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setEmpleadoApellidopaterno($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setEmpleadoApallidomaterno($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setEmpleadoEmail($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setEmpleadoPassword($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setEmpleadoCelular($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setEmpleadoTelefono($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setEmpleadoCalle($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setEmpleadoNumero($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setEmpleadoInterior($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setEmpleadoColonia($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setEmpleadoCodigopostal($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setEmpleadoCiudad($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setEmpleadoEstado($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setEmpleadoNss($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setEmpleadoRfc($arr[$keys[16]]); } if (array_key_exists($keys[17], $arr)) { $this->setEmpleadoIniciocontrato($arr[$keys[17]]); } if (array_key_exists($keys[18], $arr)) { $this->setEmpleadoNombrecontacto($arr[$keys[18]]); } if (array_key_exists($keys[19], $arr)) { $this->setEmpleadoTelefonocontacto($arr[$keys[19]]); } if (array_key_exists($keys[20], $arr)) { $this->setEmpleadoEstatus($arr[$keys[20]]); } if (array_key_exists($keys[21], $arr)) { $this->setEmpleadoRol($arr[$keys[21]]); } if (array_key_exists($keys[22], $arr)) { $this->setEmpleadoFoto($arr[$keys[22]]); } }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = EmpleadoPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setIdEmp($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setApellido($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setNombre($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setUser($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setPass($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setMail($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setIdCiudad($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setIdProv($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setIdprivilegio($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setHabilitado($arr[$keys[9]]); } }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @return Empleado[] * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(EmpleadoPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(EmpleadoPeer::DATABASE_NAME); $criteria->add(EmpleadoPeer::IDEMPLEADO, $pks, Criteria::IN); $objs = EmpleadoPeer::doSelect($criteria, $con); } return $objs; }
/** * 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 Empleado A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { $sql = 'SELECT `ID_EMP`, `APELLIDO`, `NOMBRE`, `USER`, `PASS`, `MAIL`, `ID_CIUDAD`, `ID_PROV`, `IDPRIVILEGIO`, `HABILITADO` FROM `empleado` WHERE `ID_EMP` = :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 Empleado(); $obj->hydrate($row); EmpleadoPeer::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); return $obj; }
public function editarAction() { //ID ENTIDAD $id = $this->params()->fromRoute('id'); $request = $this->getRequest(); if ($request->isPost()) { $post_data = $request->getPost(); $post_files = $request->getFiles(); //INSTANCIAMOS NUESTRA ENTIDAD $entity = \EmpleadoQuery::create()->findPk($id); //SETIAMOS NUESTROS DATOS CON EXCEPCIONES foreach ($post_data as $key => $value) { if (\EmpleadoPeer::getTableMap()->hasColumn($key) && $key != 'empleado_iniciocontrato' && $key != 'empleado_password' && $key != 'empleado_foto') { $entity->setByName($key, $value, \BasePeer::TYPE_FIELDNAME); } } //SETIAMOS LA FECHA DE CONTRATO if (!empty($post_data['empleado_iniciocontrato'])) { $empleado_iniciocontrato = date_create_from_format('d/m/Y', $post_data['empleado_iniciocontrato']); $entity->setEmpleadoIniciocontrato($empleado_iniciocontrato); } //SETIAMOS LA CONTRASEÑA EN MD5 if (!empty($post_data['empleado_password'])) { $entity->setEmpleadoPassword(md5($post_data['empleado_password'])); } //ELIMINAMOS LA FOTOGRAFIA DEL EMPLEADO $entity->setEmpleadoFoto(NULL); unlink($_SERVER['DOCUMENT_ROOT'] . "/img/admin/profiles/empleado_avatar_" . $entity->getIdempleado() . ".jpg"); $entity->save(); //LA FOTO DEL EMPLEADO if (!empty($post_files['empleado_foto']['name'])) { $upload_folder = '/img/admin/profiles/'; $img_type = $post_files['empleado_foto']['type']; $img_type = explode('/', $img_type); $img_type = $img_type[1]; $img_info = getimagesize($post_files['empleado_foto']['tmp_name']); $img_original = imagecreatefromjpeg($post_files['empleado_foto']['tmp_name']); $max_ancho = 250; $max_alto = 250; list($ancho, $alto) = getimagesize($post_files['empleado_foto']['tmp_name']); //Se calcula ancho y alto de la imagen final $x_ratio = $max_ancho / $ancho; $y_ratio = $max_alto / $alto; //Si el ancho y el alto de la imagen no superan los maximos, //ancho final y alto final son los que tiene actualmente if ($ancho <= $max_ancho && $alto <= $max_alto) { //Si ancho $ancho_final = $ancho; $alto_final = $alto; } elseif ($x_ratio * $alto < $max_alto) { $alto_final = ceil($x_ratio * $alto); $ancho_final = $max_ancho; } else { $ancho_final = ceil($y_ratio * $ancho); $alto_final = $max_alto; } //Creamos una imagen en blanco de tamaño $ancho_final por $alto_final . $tmp = imagecreatetruecolor($ancho_final, $alto_final); //Copiamos $img_original sobre la imagen que acabamos de crear en blanco ($tmp) imagecopyresampled($tmp, $img_original, 0, 0, 0, 0, $ancho_final, $alto_final, $ancho, $alto); //Se destruye variable $img_original para liberar memoria imagedestroy($img_original); //Definimos la calidad de la imagen final $calidad = 95; //Se crea la imagen final en el directorio indicado imagejpeg($tmp, $_SERVER['DOCUMENT_ROOT'] . "/img/admin/profiles/empleado_avatar_" . $entity->getIdempleado() . ".jpg", $calidad); //SETIAMOS LA FOTO $entity->setEmpleadoFoto("/img/admin/profiles/empleado_avatar_" . $entity->getIdempleado() . ".jpg"); $entity->save(); } //Agregamos un mensaje $this->flashMessenger()->addSuccessMessage('Registro guardado exitosamente!'); //REDIRECCIONAMOS A LA ENTIDAD QUE ACABAMOS DE CREAR return $this->redirect()->toRoute('admin/catalogo/empleados', array('action' => 'editar', 'id' => $entity->getIdempleado())); } $exist = \EmpleadoQuery::create()->filterByIdempleado($id)->exists(); if ($exist) { $entity = \EmpleadoQuery::create()->findPk($id); //INSTANCIAMOS NUESTRO FORMULARIO $mexico_states = \Shared\GeneralFunction\Geolocation::getMexicoStates(); $form = new \Catalogo\Form\EmpleadoForm($mexico_states); $form->setData($entity->toArray(\BasePeer::TYPE_FIELDNAME)); //REMOVEMOS EL CAMPO DE LA FECHA $form->get('empleado_iniciocontrato')->setValue(''); //RETORNAMOS A NUESTRA VISTA $view_model = new ViewModel(); $view_model->setTemplate('admin/catalogo/empleado/editar'); $view_model->setVariables(array('entity' => json_encode($entity->toArray(\BasePeer::TYPE_FIELDNAME)), 'successMessages' => json_encode($this->flashMessenger()->getSuccessMessages()), 'form' => $form)); return $view_model; } else { return $this->redirect()->toRoute('admin/catalogo/empleados', array('action' => 'index')); } }
/** * Selects a collection of Expedientegasto objects pre-filled with all related objects except Proveedoritrade. * * @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 Expedientegasto objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptProveedoritrade(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden // $criteria->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(ExpedientegastoPeer::DATABASE_NAME); } ExpedientegastoPeer::addSelectColumns($criteria); $startcol2 = ExpedientegastoPeer::NUM_HYDRATE_COLUMNS; EmpleadoPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + EmpleadoPeer::NUM_HYDRATE_COLUMNS; ExpedientePeer::addSelectColumns($criteria); $startcol4 = $startcol3 + ExpedientePeer::NUM_HYDRATE_COLUMNS; GastofacturacionPeer::addSelectColumns($criteria); $startcol5 = $startcol4 + GastofacturacionPeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(ExpedientegastoPeer::IDEMPLEADO, EmpleadoPeer::IDEMPLEADO, $join_behavior); $criteria->addJoin(ExpedientegastoPeer::IDEXPEDIENTE, ExpedientePeer::IDEXPEDIENTE, $join_behavior); $criteria->addJoin(ExpedientegastoPeer::IDGASTOFACTURACION, GastofacturacionPeer::IDGASTOFACTURACION, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = ExpedientegastoPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = ExpedientegastoPeer::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 = ExpedientegastoPeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); ExpedientegastoPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Empleado rows $key2 = EmpleadoPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = EmpleadoPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = EmpleadoPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); EmpleadoPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Expedientegasto) to the collection in $obj2 (Empleado) $obj2->addExpedientegasto($obj1); } // if joined row is not null // Add objects for joined Expediente rows $key3 = ExpedientePeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = ExpedientePeer::getInstanceFromPool($key3); if (!$obj3) { $cls = ExpedientePeer::getOMClass(); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); ExpedientePeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded // Add the $obj1 (Expedientegasto) to the collection in $obj3 (Expediente) $obj3->addExpedientegasto($obj1); } // if joined row is not null // Add objects for joined Gastofacturacion rows $key4 = GastofacturacionPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = GastofacturacionPeer::getInstanceFromPool($key4); if (!$obj4) { $cls = GastofacturacionPeer::getOMClass(); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); GastofacturacionPeer::addInstanceToPool($obj4, $key4); } // if $obj4 already loaded // Add the $obj1 (Expedientegasto) to the collection in $obj4 (Gastofacturacion) $obj4->addExpedientegasto($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's BasePeer::TYPE_PHPNAME * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = EmpleadoPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setIdempleado($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setIdrol($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setEmpleadoNombre($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setEmpleadoApellidopaterno($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setEmpleadoApellidomaterno($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setEmpleadoNombreusuario($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setEmpleadoPassword($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setEmpleadoEmail($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setEmpleadoImagen($arr[$keys[8]]); } }
/** * 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 Empleado A model object, or null if the key is not found * @throws PropelException */ protected function findPkSimple($key, $con) { $sql = 'SELECT `idempleado`, `empleado_nombre`, `empleado_apellidopaterno`, `empleado_apallidomaterno`, `empleado_email`, `empleado_password`, `empleado_celular`, `empleado_telefono`, `empleado_calle`, `empleado_numero`, `empleado_interior`, `empleado_colonia`, `empleado_codigopostal`, `empleado_ciudad`, `empleado_estado`, `empleado_nss`, `empleado_rfc`, `empleado_iniciocontrato`, `empleado_nombrecontacto`, `empleado_telefonocontacto`, `empleado_estatus`, `empleado_rol`, `empleado_foto` FROM `empleado` WHERE `idempleado` = :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 Empleado(); $obj->hydrate($row); EmpleadoPeer::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); return $obj; }
/** * This is a method for emulating ON DELETE CASCADE for DBs that don't support this * feature (like MySQL or SQLite). * * This method is not very speedy because it must perform a query first to get * the implicated records and then perform the deletes by calling those Peer classes. * * This method should be used within a transaction if possible. * * @param Criteria $criteria * @param PropelPDO $con * @return int The number of affected rows (if supported by underlying database driver). */ protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con) { // initialize var to track total num of affected rows $affectedRows = 0; // first find the objects that are implicated by the $criteria $objects = CiudadPeer::doSelect($criteria, $con); foreach ($objects as $obj) { // delete related Cliente objects $criteria = new Criteria(ClientePeer::DATABASE_NAME); $criteria->add(ClientePeer::ID_PROV, $obj->getIdProvincia()); $affectedRows += ClientePeer::doDelete($criteria, $con); // delete related Cliente objects $criteria = new Criteria(ClientePeer::DATABASE_NAME); $criteria->add(ClientePeer::ID_CIUDAD, $obj->getIdciudad()); $affectedRows += ClientePeer::doDelete($criteria, $con); // delete related Empleado objects $criteria = new Criteria(EmpleadoPeer::DATABASE_NAME); $criteria->add(EmpleadoPeer::ID_CIUDAD, $obj->getIdciudad()); $affectedRows += EmpleadoPeer::doDelete($criteria, $con); } return $affectedRows; }