我已经得到了错误,并线是这样的:致命错误:无法访问空属性
$stations=$this->$db->query('SELECT * from service_stations');
的$ DB变量声明为私有的,我用它在__construct函数是这样的:
public function __construct() {
//after including the config file
$host=DB_HOST;
$dbname=DB_NAME;
$dbuser=DB_USER;
$dbpsw=DB_PASSWORD;
try{
$pdo_options[PDO::ATTR_ERRMODE]=PDO::ERRMODE_EXCEPTION;
$this->db=new PDO('mysql:host='.$host.';dbname='.$dbname, $dbuser, $dbpsw, $pdo_options);
}
catch(Exception $e)
{
die('Erreur: '.$e->getMessage());
}
}
THX提前:)
请停止在问题标题中写入标签。你几乎完成了所有这些。 – 2011-04-24 19:52:13
我做了几乎相同的错误,这个问题的答案是非常有帮助 – 2013-12-08 10:10:35