Error fatal: usar $ esto cuando no está en el contexto del objeto con la clase contenedora pdo

Estoy utilizando simpleSQL - PDO class in my php application,
and using by this code:

$where['username']=$_POST['username'];
$where['password']=md5($_POST['password']);

$DB = new DB();
$res=$DB->buildQuery('tbl_admin',$where);

it is working fine in localhost, but in online server it get the error this:

Fatal error: Using $this when not in object context in DB.php on line 230  

line no. 230 in DB class is:

$ item  = $ this- > instance- > quote ($ this- > escape ($ item)); 

Donde esta mi problema

preguntado el 24 de agosto de 12 a las 08:08

you 230 line is in a function in the actual class or is outside of the class? -

yes it is in actual class, not outside. .check here simpleSQL - PDO -

check php version on localhost and server -

localhost has version PHP 5.3.5 and online server PHP 5.2.17 -

yes, in local with version 5.2.17 getting the same error. ..is there any solution?. ..because i can't change my server's version. -

1 Respuestas

It's a bug in the class.

En primera buildQuery método:

array_walk($where,'DB::prepareDbValues'); 

Esto llama el prepareDbValues method statically (therefore, not in object context -> $this is not defined). To fix this issue, replace it by

array_walk($where,array($this, 'prepareDbValues')); 

And report the bug and the fix to the class' author.

Respondido 24 ago 12, 09:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.