我在我的php应用程序中使用simpleSQL - PDO类,
并使用此代码:
$where['username']=$_POST['username'];
$where['password']=md5($_POST['password']);
$DB = new DB();
$res=$DB->buildQuery('tbl_admin',$where);
它在localhost中正常工作,但在在线服务器上它会收到错误:
Fatal error: Using $this when not in object context in DB.php on line 230
行号DB类中的230是:
$ item = $ this- > instance- > quote ($ this- > escape ($ item));
我的问题在哪里?
答案 0 :(得分:2)
这是班上的一个错误。
在buildQuery
方法中:
array_walk($where,'DB::prepareDbValues');
这会静态调用prepareDbValues
方法(因此,不在对象上下文中 - > $this
未定义)。要解决此问题,请将其替换为
array_walk($where,array($this, 'prepareDbValues'));
并向班级作者报告错误和修复。