我有 db
几乎所有类都扩展的类:
class db {
protected $db;
public function __construct() {
$this->connect();
}
protected function connect() {
$this->db = new MySQLi(db_host, db_user, db_pass, db_name) or die($this->db->error); (line 22)
$this->db->set_charset('utf8');
}
}
这是页面类
class page extends db {
var $common;
public function __construct() {
parent::__construct();
$this->common = new common();
和
class common extends db {
public function __construct() {
parent::__construct();
}
我得到了
Warning: mysqli::mysqli() [mysqli.mysqli]: (42000/1203): User admin already has more than 'max_user_connections' active connections in /home/tural/public_html/incl/classes/class.db.php on line 22
我该如何解决这个问题?
最佳答案
您实例化的每个继承自 db
的类都会建立一个新的数据库连接。您应该只有一个数据库类实例。所有的page
和common
都不需要继承它,只需要给它们传递一个db
实例。
关于php - 用户已经有超过 'max_user_connections' 个事件连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11278195/