cari

Rumah  >  Soal Jawab  >  teks badan

Mengapa dikatakan bahawa bukan objek memanggil fungsi ahli fetch()

<?phpclass Db{ private $dbConfig=[                                                                                                                              ;'             6            'pass'=>'root',               'charset'=>' utf8',                   'dbname'=>'edu',    ]; //Single case $instance private = null; public $num1 = null; private function __construct($params) { //Initialization parameters array_merge($this->dbConfig, $params); //Sambung ke pangkalan data $this->connect( } private function __clone() { // TODO : Laksanakan kaedah __clone() } public static function getInstance($params=[]) { if(!self::$instance instanceof self) { self::$instance = new self($params return self::$ instance; fungsi peribadi connect() { $dsn="{$this->dbConfig['d b']}:host = {$ this-& gt; dbconfig ['host']}; port = {$ this- & gt; dbconfig ['port']}; dbname = {$ this- & gt; dbconfig ['dbname']}; C Harset = { $this->dbConfig['charset']}";                                                                                                                                                                                                                           'lulus ']);                                                                                                                                                                                                                                                                        Tangkap (pdoexception $ E) {DIE ('kegagalan sambungan pangkalan data'. $ e- & gt; getMessage ());} eksekutif fungsi awam ($ SQL) {$ NUM = $ ini- & gt; ; EC ($ sql); if($num>0) if(null !== $this->conn->lastInsertID()) { $this->insertID = $this->conn -> lastInsertID() ; Cetakan Mesej 'Operasi gagal '.$error[0].':'.$error[1].':'.$error[2];                                                                                                                                                  ambil ($sql)                                                     . $sql)-> fetch(PDO::FETCH_ASSOC); } public function fetchALl($sql) { return $this->conn->query($sql)->fetch(PDO::FETCH_ASSOC);;

远处一朵花远处一朵花1417 hari yang lalu862

membalas semua(1)saya akan balas

  • 灭绝师太

    灭绝师太2021-01-12 09:08:32

    Objek pdo tidak berjaya diperolehi Pengambilan kaedah ahli objek telah dipanggil untuk menyemak parameter sambungan

    balas
    0
  • Batalbalas