我正在使用simpleSQL - PDO我的 php 应用程序中的类,
并通过此代码使用:
$where['username']=$_POST['username'];
$where['password']=md5($_POST['password']);
$DB = new DB();
$res=$DB->buildQuery('tbl_admin',$where);
它在本地主机中工作正常,但在在线服务器中出现以下错误:
Fatal error: Using $this when not in object context in DB.php on line 230
行号DB 类中的 230 是:
$ item = $ this- > instance- > quote ($ this- > escape ($ item));
我的问题出在哪里?
最佳答案
这是类中的一个错误。
在buildQuery
方法中:
array_walk($where,'DB::prepareDbValues');
这会静态调用 prepareDbValues
方法(因此,不在对象上下文中 -> $this
未定义)。要解决此问题,请将其替换为
array_walk($where,array($this, 'prepareDbValues'));
并向类(class)作者报告错误和修复。
关于php - fatal error : Using $this when not in object context with pdo wrapper class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12105135/