database = $bd; $this -> host = $host; $this -> user = $user; $this -> pass = $password; $this -> conexion = mysql_connect ( $this -> host , $this -> user , $this -> pass ); if ( !@mysql_select_db ( $this -> database, $this -> conexion ) ) { $exito = $this -> correo -> NotificarError ("ERROR: No se ha podido abrir '$bd' .", $this->destinoError); $this -> Alert("Error al seleccionar la base de datos."); return 0; } //$this->correo = new Mail(); if( !$this -> conexion ) { $this -> Alert("No se ha podido hacer la conexión"); $exito = $this -> correo -> NotificarError ("ERROR: No se ha podido conectar a la base de datos '$bd' .", $this->destinoError); exit (); } return true; } // Fin constructor Conectar. function Desconectar () { @mysql_free_result ($this -> result); @mysql_close ($this -> conexion); } /************************************************************************************************************/ /* Metodo para hacer una consulta */ /************************************************************************************************************/ function Consultar ( $tabla, $campos = "*", $condicion = "", $orden = "id", $mostrar = false ) { if ( $condicion ) $sql = 'Select '.$campos.' From '.$tabla.' Where '.$condicion.' Order By '.$orden.''; else $sql = 'Select '.$campos.' From '.$tabla.' Order By '.$orden.''; $this -> sql = $sql; // Copio la cadena sql a la propiedad de la clase para almacenarla if( $mostrar ) echo '
Consulta SQL: '.$sql.'
'; $this -> result = @mysql_query ( $sql, $this->conexion ); if ( $this -> result ) { $this -> row = @mysql_fetch_array ( $this -> result ); $this -> num = @mysql_num_rows ( $this -> result ); return true; } else { //$this -> Alert("HA HABIDO UN ERROR EN LA CONSULTA."); echo "
**ERROR[".$this->database."][".$_SERVER['PHP_SELF']."]: Consulta SQL: $sql
"; //$exito = $this -> correo -> NotificarError ("**ERROR: [".$this->user."] [".$this->database."][".$_SERVER['REQUEST_URI']."]: Consulta SQL: ".$sql,$this->destinoError); return false; } } /************************************************************************************************************/ /* Metodo para hacer una consulta */ /************************************************************************************************************/ function Insertar ( $tabla, $campos, $valores, $mostrar = false ) { $cuantos = count($valores); $temp = ""; // Formateo la cadena para insertar, poniendo los valores en formato: campo=valor, campo=valor ........ for ($i=0; $i<$cuantos; $i++) { $temp .= $campos [$i]."= '".$valores[$i]."'"; if ( $i != $cuantos-1 ) $temp .= ","; } $sql = 'Insert Into '.$tabla.' Set '.$temp.''; // Ejecuto la cadena SQL $this -> result = @mysql_query ( $sql, $this->conexion ); if( $mostrar ) { echo $sql; echo "
Campos $this->num: ".$this->row[0]."

"; } // En caso de error, advierto y mando un correo al admin if ( !$this -> result ) { //$this -> Alert("HA HABIDO UN ERROR EN LA CONSULTA."); echo "
**ERROR[".$this->database."][".$_SERVER['PHP_SELF']."]: Consulta SQL: $sql
"; //$exito = $this -> correo -> NotificarError ("**ERROR: [".$this->user."] [".$this->database."][".$_SERVER['REQUEST_URI']."]: Consulta SQL: ".$sql,$this->destinoError); return false; } else { $this->id=mysql_insert_id($this -> conexion); return true; } } /************************************************************************************************************/ /* Metodo para hacer una consulta */ /************************************************************************************************************/ function Actualizar ( $tabla, $campos, $valores, $condicion, $mostrar = false ) { $cuantos = count($valores); $temp = ""; // Formateo la cadena para actualizar, poniendo los valores en formato: campo=valor, campo=valor ........ for ($i=0; $i<$cuantos; $i++) { $temp .= $campos [$i]."= '".$valores[$i]."'"; if ( $i != $cuantos-1 ) $temp .= ","; } // Monto la cadena SQL definitiva $sql = 'Update '.$tabla.' Set '.$temp.' Where '.$condicion.''; // Ejecuto la cadena SQL $this -> result = @mysql_query ( $sql, $this->conexion ); if( $mostrar ) echo '
Consulta SQL: '.$sql.'
'; // En caso de error, advierto y mando un correo al admin if ( !$this -> result ) { //$this -> Alert("HA HABIDO UN ERROR EN LA CONSULTA."); echo "
**ERROR[".$this->database."][".$_SERVER['PHP_SELF']."]: Consulta SQL: $sql
"; //$exito = $this -> correo -> NotificarError ("**ERROR: [".$this->user."] [".$this->database."][".$_SERVER['REQUEST_URI']."]: Consulta SQL: ".$sql,$this->destinoError); return false; } } /************************************************************************************************************/ /* Metodo para eliminar una consulta */ /************************************************************************************************************/ function Eliminar ( $tabla, $condicion, $mostrar = false ) { // Monto la cadena SQL definitiva $sql = 'Delete From '.$tabla.' Where '.$condicion.''; // Ejecuto la cadena SQL $this -> result = @mysql_query ( $sql, $this->conexion ); if( $mostrar ) echo "Campos $this->num: ".$this->row[0]."

"; // En caso de error, advierto y mando un correo al admin if ( !$this -> result ) { //$this -> Alert("HA HABIDO UN ERROR EN LA CONSULTA."); echo "
**ERROR[".$this->database."][".$_SERVER['PHP_SELF']."]: Consulta SQL: $sql
"; //$exito = $this -> correo -> NotificarError ("**ERROR: [".$this->user."] [".$this->database."][".$_SERVER['REQUEST_URI']."]: Consulta SQL: ".$sql,$this->destinoError); return false; } } /************************************************************************************************************/ /* Metodo para hacer pasar a la siguiente fila del array de la consulta */ /************************************************************************************************************/ function Siguiente() { $this->row = @mysql_fetch_array ( $this->result ); if ($this->row) return true; else return false; } /************************************************************************************************************/ /* Metodo para imprimir una alerta en pantalla */ /************************************************************************************************************/ function Alert($msj, $sql="") { echo ""; } /************************************************************************************************************/ /* Metodo recoger la fecha */ /************************************************************************************************************/ function dameFecha () { return date ("Y/m/d"); } /************************************************************************************************************/ /* Metodo recoger la hora */ /************************************************************************************************************/ function dameHora () { return date ("H:i:s"); } /************************************************************************************************************/ /* Metodo que formatea la fehca */ /************************************************************************************************************/ function formateaFecha ( $cadena, $hora = false ) { $trozos = explode (" ",$cadena); $fecha = explode ("-", $trozos[0]); if ($hora) return $fecha[2]."/".$fecha[1]."/".$fecha[0]." ".$trozos [1]; else return $fecha[2]."/".$fecha[1]."/".$fecha[0]; } /************************************************************************************************************/ /* Metodo que formatea la fehca para el RSS */ /************************************************************************************************************/ function FechaRSS ( $cadena, $hora = false ) { $trozos = explode (" ",$cadena); $fecha = explode ("-", $trozos[0]); if ($hora) return $fecha[2]." ".$this->DimeMes($fecha[1])." ".$fecha[0]." ".$trozos [1]." -0600"; else return $fecha[2]."/".$this->DimeMes($fecha[1])."/".$fecha[0]; } function DimeMes ($id_mes) { switch ($id_mes) { case 1: return "Enero"; break; case 2: return "Febrero"; break; case 3: return "Marzo"; break; case 4: return "Abril"; break; case 5: return "Mayo"; break; case 6: return "Junio"; break; case 7: return "Julio"; break; case 8: return "Agosto"; break; case 9: return "Septiembre"; break; case 10: return "Oct"; break; case 11: return "Noviembre"; break; case 12: return "Diciembre"; break; } } function SimbolosRaros ($cadena) { $cad = strtolower ($cadena); $cad = eregi_replace (" ", "-", $cad); $cad = eregi_replace ("á", "a", $cad); $cad = eregi_replace ("à", "a", $cad); $cad = eregi_replace ("ä", "a", $cad); $cad = eregi_replace ("é", "e", $cad); $cad = eregi_replace ("è", "e", $cad); $cad = eregi_replace ("ë", "e", $cad); $cad = eregi_replace ("í", "i", $cad); $cad = eregi_replace ("ì", "i", $cad); $cad = eregi_replace ("ï", "i", $cad); $cad = eregi_replace ("ó", "o", $cad); $cad = eregi_replace ("ò", "o", $cad); $cad = eregi_replace ("ö", "o", $cad); $cad = eregi_replace ("ú", "u", $cad); $cad = eregi_replace ("ù", "u", $cad); $cad = eregi_replace ("ü", "u", $cad); $cad = eregi_replace ("ñ", "n", $cad); $cad = eregi_replace ("\"", "", $cad); $cad = eregi_replace ("\'", "", $cad); $cad = eregi_replace ("\,", "", $cad); $cad = eregi_replace ("\.", "", $cad); $cad = eregi_replace ("=", "-", $cad); $cad = eregi_replace ("¡", "", $cad); $cad = eregi_replace ("!", "", $cad); $cad = eregi_replace (":", "-", $cad); $cad = eregi_replace ("%", "", $cad); $cad = eregi_replace ("\?", "", $cad); $cad = eregi_replace ("\/", "-", $cad); $cad = eregi_replace ("\¿", "", $cad); $cad = eregi_replace ("\(", "", $cad); $cad = eregi_replace ("\)", "", $cad); $cad = eregi_replace ("&", "", $cad); $cad = eregi_replace ("$", "", $cad); $cad = eregi_replace ("--", "-", $cad); return $cad; } } // Fin de la clase ?> Ildum Tanatorio

Galería de fotos

  • Ildum Tanatorio - Instalaciones