<?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");
仍然不工作,並給我一個錯誤致命錯誤:調用未定義的方法DB ::查詢()在C:\ WAMP \ WWW \ CodeCanyon \超論壇\核心\ config.php文件上線39如何運行mysqli查詢?
我剛開始使用php面向對象的編程,我做了我的連接類(使用mySQLi
),但我仍然不明白如何運行查詢?
不教程或書或任何你花了這麼遠告訴你嗎? – JJJ
那真的沒什麼幫助:/ –
不,真的,看起來很奇怪,有些東西告訴你如何建立連接,但不知道如何處理。 – JJJ