自己程式碼一直錯誤: Fatal error: Call to a member function exec() on null
## public $insertId = null;
# public $num = 0;
私人靜態$instance = null;
## 私人$conn = null;
私有函數 __construct($params){
$this->dbConfig = array_merge($this->dbConfig,$params);
# $this->conncet();
}
# 私人函數__clone(){
# }
公用函數getInstance(){
if(!self::$instance instanceof self){
self::$instance = new self();
return self::$instance;
public function connect(){
try{
## //取得單一查詢資訊
##class db{ private $dbConfig = [ 'db' => 'mysql', '主機' => 'localhost', '連接埠' => '3306', '資料庫名稱'=> 'one', '使用者' => 'root', '密碼' => '1234',// '字元集' => 'utf' ];## public $insertId = null;
# public $num = 0;
私人靜態$instance = null;
## 私人$conn = null;
私有函數 __construct($params){
$this->dbConfig = array_merge($this->dbConfig,$params);
# $this->conncet();
}
# 私人函數__clone(){
# }
公用函數getInstance(){
if(!self::$instance instanceof self){
self::$instance = new self();
}
return self::$instance;
}
public function connect(){
try{
## $dsn = " { $this->dbConfig['db']}:{$this->dbConfig['host']}; port = {$this->dbConfig['port']};## //取得單一查詢資訊
public function fetch ($sql ) { return $this->conn->query($sql)->fetch(PDO::FETCH_ASSOC);