<?php
// Forum Configuration
define('DB_HOST','localhost'); // Database Hostname
define('DB_USER','root'); // Database Username
define('DB_PASSWORD',''); // Database Password
define('DB_NAME','ultraforum'); // Database Name
define('WEB_NAME','Website Name'); // Website Name
define('WEB_TITLE','Website Title'); // Website Title
// Do not modify anything under this line :)
class db {
var $dbhost;
var $dbuser;
var $dbpassword;
var $dbname;
var $query;
function connect() {
$this->db =
new mysqli($this->dbhost, $this->dbuser, $this->dbpassword, $this->dbname);
}
function __construct() {
$this->dbhost = DB_HOST;
$this->dbuser = DB_USER;
$this->dbpassword = DB_PASSWORD;
$this->dbname = DB_NAME;
}
}
$con = new db;
$con->connect();
$con->query("SELECT * FROM topics");
仍然不起作用,并给我一个错误致命错误:在第 39 行调用 C:\wamp\www\CodeCanyon\Ultra Forum\core\Config.php 中的未定义方法 db::query()
我刚开始使用 php 面向对象编程,我创建了连接类(使用mySQLi
),但我仍然不明白如何运行查询?