Estoy creando una clase que gestione los select, drop, update, conexiones y tal de mi proyecto web.
Estoy teniendo problemas al acceder a cualquier contenido de la web.
El error que me aparece es:
Fatal error: Call to a member function fetch_object() on a non-object in C:\Users\JaimeMSE\Dropbox\www\librerias\class_db.p hp on line 34
Y la función select es la siguiente:
Código PHP:
Ver original
function select($select, $nombredb, $where, $limit=null) { #$this->nombredb = $_SESSION['web_db'].'_'.$this->nombredb; $this->nombredb = 'web_1_'.$nombredb; $this->select = $select; $this->where = $where; $this->limit = $limit; if($limit=null) { $this->consulta = $this->db->query("SELECT {$this->select} FROM {$this->nombredb} WHERE {$this->where}"); $this->resultado = $this->db->fetch_object($this->consulta); return $this->resultado; } else { $this->consulta = $this->db->query("SELECT {$this->select} FROM {$this->nombredb} WHERE {$this->where} LIMIT {$this->limit}"); $this->resultado = $this->consulta->fetch_object($this->consulta); return $this->resultado; } }
A ella la llamo así (dentro de otra clase):
Código PHP:
Ver original
Y luego en el controlador tengo:
Código PHP:
Ver original
$articulos = new Articulos(); $articulo = $articulos->obtenerArticulo(1);
Estoy algo atascado, ya que no me estoy muy puesto en POO ni en mysqli.
¿Alguien me puede ayudar y/o orientar un poquito?
Gracias.