Ver Mensaje Individual
  #10 (permalink)  
Antiguo 09/11/2009, 12:15
raleandri
 
Fecha de Ingreso: junio-2009
Mensajes: 22
Antigüedad: 14 años, 10 meses
Puntos: 1
Respuesta: Problema al guardar las barras de la ruta en mysql con php

Aqui va el codigo de base de datos completo.
TAmbien mando abajo la claseCanal completa por als dusas que el error este ahi.
Espero púedas ayudarme

Clase Base de Datos
Código php:
Ver original
  1. <?php
  2.  
  3. class BaseDatos {
  4.     private $HOSTNAME;
  5.     private $BASEDATOS;
  6.     private $USUARIO;
  7.     private $CLAVE;
  8.     private $CONEXION;
  9.     private $QUERY;
  10.     private $RESULT;
  11.     private $ERROR;
  12. /**
  13.  * Constructor de la clase que inicia ls variables instancias de la clase
  14.  * vinculadas a la coneccion con el Servidor de BD
  15.  */
  16.     public function __construct(){
  17.         $this->HOSTNAME = "localhost";
  18.         $this->BASEDATOS = "xdatos";
  19.         $this->USUARIO = "root";
  20.         $this->CLAVE="";
  21.         $this->RESULT=0;
  22.         $this->QUERY="";
  23.         $this->ERROR="";
  24.     }
  25. /**
  26.  * Funcion que retorna una cadena
  27.  * con una pequeña descripcion del error si lo hubiera
  28.  *
  29.  * @return cadena
  30.  */
  31.     public function getError(){
  32.         return $this->ERROR;
  33.        
  34.     }
  35.  
  36. /**
  37.  * Inicia la coneccion con el Servidor y la  Base Datos Mysql.
  38.  * Retorna true si la coneccion con el servidor se pudo establecer y false en caso contrario
  39.  *
  40.  * @return boolean
  41.  */
  42.     public  function Iniciar(){
  43.            $conexion = mysql_connect($this->HOSTNAME,$this->USUARIO,$this->CLAVE);
  44.            if ($conexion){
  45.                if (mysql_select_db($this->BASEDATOS,$conexion)){
  46.                     $this->CONEXION = $conexion;
  47.                     unset($this->QUERY);
  48.                     unset($this->ERROR);
  49.                     return true;
  50.                }  else {  
  51.                         $this->ERROR = mysql_errno($conexion) . ": " .mysql_error($conexion);
  52.                         return false;
  53.                }
  54.            }else{
  55.                 $this->ERROR =  mysql_errno($conexion) . ": " .mysql_error($conexion);
  56.                  return false;
  57.            }
  58.       }
  59.    
  60. /**
  61.  * Ejecuta una consulta en la Base de Datos.
  62.  * Recibe la consulta en una cadena enviada por parametro.
  63.  *
  64.  * @param cadena $consulta
  65.  * @return boolean
  66.  */
  67.     public function Ejecutar($consulta){
  68.         unset($this->ERROR);
  69.          $this->QUERY = $consulta;
  70.          if(  $this->RESULT = mysql_query($consulta)){
  71.             return true;
  72.         } else {
  73.             $this->ERROR =mysql_errno( $this->CONEXION).": ". mysql_error( $this->CONEXION);
  74.             return false;
  75.          }
  76.       }
  77.  
  78. /**
  79.  * Devuelve un registro retornado por la ejecucion de una consulta
  80.  * el puntero se despleza al siguiente registro de la consulta
  81.  *
  82.  * @return unknown
  83.  */
  84.     public function Registro() {
  85.        
  86.         if ($this->RESULT){
  87.             unset($this->ERROR);
  88.             if($temp = mysql_fetch_assoc($this->RESULT)){
  89.                     return $temp;
  90.                 }else{
  91.                     mysql_free_result($this->RESULT);
  92.                     return false;
  93.                 }
  94.         }else{
  95.             $this->ERROR = mysql_errno($this->CONEXION) . ": " . mysql_error($this->CONEXION);
  96.             return false;
  97.         }
  98.      }
  99.  
  100. /**
  101.  * Devuelve el id de un campo autoincrement utilizado como clave de una tabla
  102.  * Retorna el id numerico del registro insertado, devuelve null en caso que la ejecucion de la consulta falle
  103.  *
  104.  * @param cadena $consulta
  105.  * @return id de la tupla insertada
  106.  */
  107.     public function devuelveIDInsercion($consulta){
  108.         unset($this->ERROR);
  109.         $this->QUERY = $consulta;
  110.         if ($this->RESULT = mysql_query($consulta)){
  111.               $id = mysql_insert_id();
  112.               return $id;
  113.         } else {
  114.             $this->ERROR =mysql_errno( $this->CONEXION) . ": " . mysql_error( $this->CONEXION);
  115.             return null;
  116.          }
  117.       }
  118.  
  119. }
  120. ?>

Clase Canal
Código php:
Ver original
  1. <?php
  2. include_once "claseBD.php";
  3.  
  4.  
  5. class canal {
  6.    
  7.     public $id_canal;
  8.     public $descripcion;
  9.     public $url;
  10.     public $path_XML;
  11.     public $path_XSL;
  12.     public $path_HTML;
  13.     public $intervalo;
  14.     public $fecha;
  15.  
  16.  
  17.  
  18.     public function setID($id){
  19.         $this->id_canal=$id;
  20.     }
  21.     public function getID(){
  22.         return $this->id_canal;
  23.     }
  24.    
  25.     public function setFecha($fecha){
  26.         $this->fecha=$fecha;
  27.     }
  28.     public function getFecha(){
  29.         return $this->fecha;
  30.     }
  31.    
  32.     public function setDescripcion($desc){
  33.         $this->descripcion=$desc;
  34.     }
  35.     public function getDescripcion(){
  36.         return $this->descripcion;
  37.     }
  38.    
  39.     public function setURL($url){
  40.         $this->url=$url;
  41.     }
  42.     public function getURL(){
  43.         return $this->url;
  44.     }
  45.    
  46.     public function setPathXML($xml){
  47.         $this->path_XML=$xml;
  48.     }
  49.     public function getPathXML(){
  50.         return $this->path_XML;
  51.     }
  52.    
  53.     public function setPathXSL($xsl){
  54.         $this->path_XSL=$xsl;
  55.     }
  56.     public function getPathXSL(){
  57.         return $this->path_XSL;
  58.     }  
  59.    
  60.     public function setPathHTML($html){
  61.         $this->path_HTML=$html;
  62.     }
  63.    
  64.     public function getPathHTML(){
  65.         return $this->path_HTML;
  66.     }
  67.    
  68.     public function setIntervalo($intervalo){
  69.         $this->intervalo=$intervalo;
  70.     }
  71.  
  72.     public function getIntervalo(){
  73.         return $this->intervalo;
  74.     }
  75.    
  76.    
  77.    
  78.     public function iniciaCanal($id_canal,$descripcion,$url,$xsl,$xml,$html,$intervalo,$fecha){
  79.         $this->setID($id_canal);
  80.         $this->setDescripcion($descripcion);
  81.         $this->setURL($url);
  82.         $this->setPathXSL($xsl);
  83.         $this->setPathXML($xml);
  84.         $this->setPathHTML($html);
  85.         $this->setIntervalo($intervalo);
  86.         $this->setFecha($fecha);
  87.     }
  88.  
  89.     public function cargaCanal(){
  90.         $consulta="INSERT INTO canales (id, descripcion, url, path_XSL, path_XML, path_HTML, intervalo, fecha)
  91.         VALUES ('".$this->getID()."','".$this->getDescripcion()."','".$this->getURL()."','".$this->getPathXSL()."','".$this->getPathXML()."','".$this->getPathHTML()."','".$this->getIntervalo()."','".$this->getFecha()."')";
  92.         $bd=new BaseDatos();
  93.         if($bd->Iniciar()){
  94.             if($bd->Ejecutar($consulta)){
  95.                 return true;
  96.             }else{
  97.                 return false;
  98.                 echo$bd->getError();
  99.             }
  100.         }else{
  101.             return false;
  102.             echo$bd->getError();
  103.         }
  104.     }
  105.  
  106.     public function selectCanal($id){
  107.         $consulta="SELECT * FROM canales WHERE id='$id'";
  108.         $bd=new BaseDatos();
  109.         if($bd->Iniciar()){
  110.             if($bd->Ejecutar($consulta)){
  111.                 $resultado=$bd->Registro();
  112.                 if ($resultado!=null){
  113.                     $canal=new canal();
  114.                     $canal->iniciaCanal($resultado['id'],$resultado['descripcion'],$resultado['url'],$resultado['path_XSL'],$resultado['path_XML'],$resultado['path_HTML'],$resultado['intervalo'],$resultado['fecha']);
  115.                     return $canal;
  116.                 }else{
  117.                     return false;
  118.                     echo $resultado;
  119.                 }
  120.             }else{
  121.                 return false;
  122.                 echo$bd->getError();
  123.             }
  124.         }else{
  125.             return false;
  126.             echo$bd->getError();
  127.         }
  128.     }
  129.  
  130.  
  131.     public function modificaCanal(){
  132.         $consulta="UPDATE canales
  133.         SET descripcion='".$this->getDescripcion()."', url='".$this->getURL()."', path_XSL='".$this->getPathXSL()."', path_XML='".$this->getPathXML()."', path_HTML='".$this->getPathHTML()."', intervalo='".$this->getIntervalo()."', fecha='".$this->getFecha()."'
  134.         WHERE id='".$this->getID()."'";
  135.         $bd=new BaseDatos();
  136.         if($bd->Iniciar()){
  137.             if($bd->Ejecutar($consulta)){
  138.                 return true;
  139.             }else{
  140.                 return false;
  141.                 echo $bd->getError();
  142.             }
  143.         }else{
  144.             return false;
  145.             echo $bd->getError();
  146.         }
  147.     }
  148.  
  149.  
  150.     public function ActualizaFechaCanal(){
  151.         $consulta="UPDATE canales
  152.         SET fecha='".$this->getFecha()."'
  153.         WHERE id='".$this->getID()."'";
  154.         $bd=new BaseDatos();
  155.         if($bd->Iniciar()){
  156.             if($bd->Ejecutar($consulta)){
  157.                 return true;
  158.             }else{
  159.                 return false;
  160.                 echo $bd->getError();
  161.             }
  162.         }else{
  163.             return false;
  164.             echo $bd->getError();
  165.         }
  166.     }
  167.    
  168.    
  169.     public function borraCanal(){
  170.         $consulta="DELETE FROM canales WHERE id='".$this->getID()."'";
  171.         $bd=new BaseDatos();
  172.         if($bd->Iniciar()){
  173.             if($bd->Ejecutar($consulta)){
  174.                 return true;
  175.             }else{
  176.                 return false;
  177.                 echo$bd->getError();
  178.             }
  179.         }else{
  180.             return false;
  181.             echo$bd->getError();
  182.         }
  183.     }
  184.    
  185.    
  186.     public function consultaCanales(){
  187.         $consulta="SELECT * FROM canales";
  188.         $bd=new BaseDatos();
  189.         $canales=array();
  190.         if($bd->Iniciar()){
  191.             if ($bd->Ejecutar($consulta)){
  192.                 while($resultado=$bd->Registro()){
  193.                     $canal= new canal();
  194.                     $canal->iniciaCanal($resultado['id'],$resultado['descripcion'],$resultado['url'],$resultado['path_XSL'],$resultado['path_XML'],$resultado['path_HTML'],$resultado['intervalo'],$resultado['fecha']);
  195.                     array_push($canales,$canal);
  196.                 }
  197.                 return $canales;
  198.             }else{
  199.                 return false;
  200.                 echo$bd->getError();
  201.             }
  202.         }
  203.     }
  204.    
  205. }
  206. ?>