PDO-Mysql database operation class

in the 1.mvc framework, there is an error in the database operation class, and there is a file whose code is the same as mine. Why am I wrong?

class MySQLPDO {

//
private $dbConfig = array(
        "db" => "MYSQL",
        "host" => "localhost",
        "port" => "3306",
        "user" => "root",
        "pass" => "root",
        "charset" => "utf8",
        "dbname" => "mvc_study",
    );
//
private static $instance;


//PDO
private $db;

//
private function __construct($params){
    $this->dbConfig = array_merge($this->dbConfig,$params);
    $this->connect();
}

//
public static function getInstance($params=array()){
    if(!self::$instance instanceof self){
        //new self()$params
        self::$instance = new self($params);
    }
    return self::$instance;
} 
//
private function __clone(){}

//
private function connect(){
    try{
        $dsn = "{$this->dbConfig["db"]}:port={$this->dbConfig["port"]};host={$this->dbConfig["host"]};dbname={$this->dbConfig["dbname"]};charset={$this->dbConfig["charset"]}";
        $pdo = new PDO($dsn,$this->dbConfig["user"],$this->dbConfig["pass"]);
        $pdo->query("set names {$this->dbConfig["charset"]}"); 
    }catch(PDOException $e){
        $e->getMessage();
    }
}

//sql
public function query($sql){
    return $this->db->query($sql);
}

//
public function fetchRow($sql){
    return $this->query($sql)->fetch(PDO::FETCH_ASSOC);
}

//
public function fetchAll($sql){
    return $this->query($sql)->fetchAll(PDO::FETCH_ASSOC);
}

}

? >

clipboard.png

problem description

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Php
Mar.24,2022
The db attribute is not assigned a value in

code


//
private function connect(){
    try{
        $dsn = "{$this->dbConfig['db']}:port={$this->dbConfig['port']};host={$this->dbConfig['host']};dbname={$this->dbConfig['dbname']};charset={$this->dbConfig['charset']}";
        $pdo = new PDO($dsn,$this->dbConfig['user'],$this->dbConfig['pass']);
        $pdo->query("set names {$this->dbConfig['charset']}");
        
        -sharp 
        $this->db = $pdo;
 
    }catch(PDOException $e){
        $e->getMessage();
    }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb625c-25ab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb625c-25ab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?