0
我有一個擁有所有其他數據庫名稱的主數據庫,當用戶登錄時,我在此主數據庫上找到了appropraite數據庫名稱,然後使用該名稱將用戶連接到系統。我做的是,獲取數據庫名後,我將它保存爲一個會話,並將該會話傳遞給我的其他數據庫連接的數據庫名稱。這就是我如何將用戶連接到系統在旅途中更改數據庫名稱php
class DataDB extends mysqli {
// single instance of self shared among all instances
private static $instance = null;
// db connection config vars
private $dbName = $_SESSION['dname'];
private $dbHost = "localhost";
//This method must be static, and must return an instance of the object if the object
//does not already exist.
public static function getInstance() {
if (!self::$instance instanceof self) {
self::$instance = new self;
}
return self::$instance;
}
到目前爲止其拒絕工作正在此錯誤解析錯誤:語法錯誤,意想不到的「$ _SESSION」(T_VARIABLE)。也有沒有更好的方式來做到這一點沒有會話
感謝了很多,看它現在@ka_lin – hamobi
檢查我的編輯的版本,雖然,我misstake –
這我怎麼分配它'父:: __結構($這個 - > DBHOST,$這個 - >用戶,$這個 - >通,$這個 - >數據庫名);' – hamobi