Ver Mensaje Individual
  #3 (permalink)  
Antiguo 24/05/2014, 14:03
AprendizPollito
 
Fecha de Ingreso: abril-2014
Mensajes: 26
Antigüedad: 10 años
Puntos: 0
Respuesta: Fatal error: Call to a member function getAll()

Cita:
Iniciado por hhs Ver Mensaje
Código PHP:
Ver original
  1. $aItems = $GLOBALS['MySQL']->getAll("SELECT * FROM `ejemplo` ORDER by `when` ASC");
Asegurate que GLOBALS realmente tenga el objeto que esperas.
e_e ese es el problema, que nose como hacerlo... en el post que encontre este codigo le falto poner un archivo mas que es el de la conexion a la BD... talves el puso mas cosas ahy... este es el link :

http://www.script-tutorials.com/how-to-create-own-voting-system/


EDITO :

Ya encontre el archivo faltante buscando en varios de sus temas... hubo uno en el que uso el mismo archivo, aki lo dejo por si acaso a alguien le sirva:

CMySQL.php


Código PHP:
<?php

class CMySQL {

    
// variables
    
var $sDbName;
    var 
$sDbUser;
    var 
$sDbPass;

    var 
$vLink;

    
// constructor
    
function CMySQL() {
        
$this->sDbName 'wimne';
        
$this->sDbUser 'root';
        
$this->sDbPass '';

        
// create db link
        
$this->vLink mysql_connect("localhost"$this->sDbUser$this->sDbPass);

        
//select the database
        
mysql_select_db($this->sDbName$this->vLink);

        
mysql_query("SET names UTF8");
    }

    
// return one value result
    
function getOne($query$index 0) {
        if (! 
$query)
            return 
false;
        
$res mysql_query($query);
        
$arr_res = array();
        if (
$res && mysql_num_rows($res))
            
$arr_res mysql_fetch_array($res);
        if (
count($arr_res))
            return 
$arr_res[$index];
        else
            return 
false;
    }

    
// executing sql
    
function res($query$error_checking true) {
        if(!
$query)
            return 
false;
        
$res mysql_query($query$this->vLink);
        if (!
$res)
            
$this->error('Database query error'false$query);
        return 
$res;
    }

    
// return table of records as result in pairs
    
function getPairs($query$sFieldKey$sFieldValue$arr_type MYSQL_ASSOC) {
        if (! 
$query)
            return array();

        
$res $this->res($query);
        
$arr_res = array();
        if (
$res) {
            while (
$row mysql_fetch_array($resMYSQL_ASSOC)) {
                
$arr_res[$row[$sFieldKey]] = $row[$sFieldValue];
            }
            
mysql_free_result($res);
        }
        return 
$arr_res;
    }

    
// return table of records as result
    
function getAll($query$arr_type MYSQL_ASSOC) {
        if (! 
$query)
            return array();

        if (
$arr_type != MYSQL_ASSOC && $arr_type != MYSQL_NUM && $arr_type != MYSQL_BOTH)
            
$arr_type MYSQL_ASSOC;

        
$res $this->res($query);
        
$arr_res = array();
        if (
$res) {
            while (
$row mysql_fetch_array($res$arr_type))
                
$arr_res[] = $row;
            
mysql_free_result($res);
        }
        return 
$arr_res;
    }

    
// return one row result
    
function getRow($query$arr_type MYSQL_ASSOC) {
        if(!
$query)
            return array();
        if(
$arr_type != MYSQL_ASSOC && $arr_type != MYSQL_NUM && $arr_type != MYSQL_BOTH)
            
$arr_type MYSQL_ASSOC;
        
$res $this->res ($query);
        
$arr_res = array();
        if(
$res && mysql_num_rows($res)) {
            
$arr_res mysql_fetch_array($res$arr_type);
            
mysql_free_result($res);
        }
        return 
$arr_res;
    }

    
// escape
    
function escape($s) {
        return 
mysql_real_escape_string(strip_tags($s));
    }

    
// get last id
    
function lastId() {
        return 
mysql_insert_id($this->vLink);
    }

    
// display errors
    
function error($text$isForceErrorChecking false$sSqlQuery '') {
        echo 
$text; exit;
    }
}

$GLOBALS['MySQL'] = new CMySQL();

Última edición por AprendizPollito; 24/05/2014 a las 15:25