我有两个数据库。当我包括数据库连接时(with a include(\'filename.php\');
) wordpress的行为真的很奇怪。
我无法登录,wordpress用户名和密码正确,但它尝试连接到其他数据库(打开调试时可以看到)。
WordPress database error: [Table \'api.apiwp_options\' doesn\'t exist]
SELECT option_value FROM apiwp_options WHERE option_name = \'widget_pages\' LIMIT 1
WordPress database error: [Table \'api.apiwp_options\' doesn\'t exist]
SELECT option_value FROM apiwp_options WHERE option_name = \'widget_calendar\' LIMIT 1
WordPress database error: [Table \'api.apiwp_options\' doesn\'t exist]
SELECT option_value FROM apiwp_options WHERE option_name = \'widget_links\' LIMIT 1
WordPress database error: [Table \'api.apiwp_options\' doesn\'t exist]
SELECT option_value FROM apiwp_options WHERE option_name = \'widget_tag_cloud\' LIMIT 1
WordPress database error: [Table \'api.apiwp_options\' doesn\'t exist]
SELECT option_value FROM apiwp_options WHERE option_name = \'widget_nav_menu\' LIMIT 1
就像他们无法分离连接一样。有什么可以帮我朝正确的方向发展的吗?内容也停止工作。
Edit: Clearifying
我的数据库连接:function ir_mysql() {
global $dbm;
if(empty($dbm)){
$dbm = new Mysql(DBHOST, DBUSER, DBPASS, DBNAME);
}
return $dbm;
}
mysql。班phpclass Mysql {
// Variabler
// -----------------------------
private $db;
private $user;
private $password;
private $host;
private $linkid;
private $result;
function __construct($host, $user, $password, $db) {
try {
$this->db = $db;
$this->user = $user;
$this->password = $password;
$this->host = $host;
$this->connect();
$this->select();
mysql_set_charset(\'utf8\', $this->linkid);
} catch (exception $e) {
die($e->getMessage());
}
}
function Connect() {
try {
$this->linkid = mysql_connect($this->host, $this->user, $this->password);
if (!$this->linkid) {
throw new Exception(mysql_error());
}
} catch (Exception $e) {
die($e->getMessage());
}
}
function Select() {
try {
if (!mysql_select_db($this->db, $this->linkid)) {
throw new Exception("Cannot access the selected database");
}
} catch (Exception $e) {
die($e->getMessage());
}
}
function Query($sql) {
try {
$this->result = @mysql_query($sql, $this->linkid);
if (!$this->result) {
throw new Exception("Mysql query error: \\n <br />" . mysql_error() . "<br />" . mysql_errno());
}
} catch (Exception $e) {
if (ir_admin()) {
die($e->getMessage());
}
}
return $this->result;
}
function Close() {
mysql_close($this->linkid);
}
}
因此,如果我在查询新的内容,我会这样做:ir_mysql()->query("SELECT....");
我的方法和wordpress方法不太好用。