Ver Mensaje Individual
  #2 (permalink)  
Antiguo 22/05/2009, 10:50
Tik3r
 
Fecha de Ingreso: octubre-2008
Mensajes: 32
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: Ayuda con clase XAJAX Y MySQL

Bueno pongo aqui la clase MySQL porque la clase XAJAX es mas bien una libreria... jeje

Código PHP:
<?php

class DataBase {

    private 
$conexion;
    private 
$resource;
    private 
$sql;
    public static 
$queries;
    private static 
$_singleton;

    public static function 
getInstance(){
        if (
is_null (self::$_singleton)) {
            
self::$_singleton = new DataBase();
        }
        return 
self::$_singleton;
    }

    private function 
__construct(){
        
$this->conexion = @mysql_connect('localhost','user','pass');
        
mysql_select_db('db'$this->conexion);
        
$this->queries 0;
        
$this->resource null;
    }

    public function 
execute(){
        if(!(
$this->resource mysql_query($this->sql$this->conexion))){
            return 
null;
        }
        
$this->queries++;
        return 
$this->resource;
    }

    public function 
alter(){
        if(!(
$this->resource mysql_query($this->sql$this->conexion))){
            return 
false;
        }
        return 
true;
    }

    public function 
loadObjectList(){
        if (!(
$cur $this->execute())){
            return 
null;
        }
        
$array = array();
        while (
$row = @mysql_fetch_object($cur)){
            
$array[] = $row;
        }
        return 
$array;
    }

    public function 
setQuery($sql){
        if(empty(
$sql)){
            return 
false;
        }
        
$this->sql $sql;
        return 
true;
    }

    public function 
freeResults(){
        @
mysql_free_result($this->resource);
        return 
true;
    }

    public function 
loadObject(){
        if (
$cur $this->execute()){
            if (
$object mysql_fetch_object($cur)){
                @
mysql_free_result($cur);
                return 
$object;
            }
            else {
                return 
null;
            }
        }
        else {
            return 
false;
        }
    }

    function 
__destruct(){
        @
mysql_free_result($this->resource);
        @
mysql_close($this->conexion);
    }
}
?>
Weno en teoria si seleccionara una opción me tenia que aparecer una tabla con los resultados de la consulta, pero cuando lo hago la aplicación no me hace nada :(

Si alguien puede ayudarme se lo agradeceria