致命错误:在第19行的C:\ xampp \ htdocs \ PhpOO \ classes \ Usuarios.php中调用未定义的方法DB :: getInstance()

时间:2017-11-24 17:42:14

标签: php pdo

ta dando esse erro alguem pode me ajudar?

require_once 'config.php';

class DB {
    private static $instance;

    public static function getInstance() {
        if (!isset(self::$instance)) {
            try {
                self::$instance = new PDO('mysql:host=' . HOST . '; dbname=' . BASE, USER, PASS);
                self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                self::$instance->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);

            } catch (PDOException $e) {
                echo $e->getMessage();
            }
        }
        return self::$instance;
    }

    public static function prepare($sql) {
        return self::getInstance()->prepare($sql);
    }
}

0 个答案:

没有答案