Fatal error: Call to undefined method Database::prepare()

前端 未结 3 1068
隐瞒了意图╮
隐瞒了意图╮ 2020-12-03 18:28

I have created a separate class for database and users.

Database.php

 class Database{

     private $db;


    public function __construct(){

  /***         


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 19:03

    Your Database class does not extend PDO neither it does implement prepare method.

    In order to access your PDO object, you must make it public and access like:

    From User class:

    $this->db->db->prepare();

    The best way would be to extend the PDO class.

提交回复
热议问题