0
我是新來的PDO CLASS編程,這裏是我的問題,我有這個類從DB回顧一些信息,我真的需要類似的東西,我得到標題錯誤: 致電成員函數prepare()在非對象查詢行上:在我的PDO函數中的錯誤
$stmt = $this->db->prepare()
我在做什麼錯?
class map{
private $db;
public $dir;
public $query;
function mapWant($query,$db,$dir){
$stmt = $this->db->prepare("SELECT ".$this->query." WHERE ID = :dir");
$stmt->execute(array(':dir'=>$this->dir));
$row=$stmt->fetch(PDO::FETCH_LAZY);
echo $row[0]; //I want retrive the only field that the result has
}
}
$map = new map();
$map->mapWant($dir,$db,"Breve");
$ dir是一個$ _GET方法retrive只有一個號碼 $分貝=是PDO連接(這是工作); 預先感謝您。
哦,不錯,謝謝,現在我得到另一個錯誤,我會嘗試修復它:) – 2014-09-30 10:06:59
很高興能有所幫助。 – George 2014-09-30 10:07:34