我正在创建一个mysqli db对象,执行以下操作:
class DatabaseQK {
public $db;
public function __construct() {
$this->db = new mysqli(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME, true);
// if the connection could not be obtained record an error
if (mysqli_connect_errno()){
log_system_error("Fatal DB Error: ", mysqli_connect_error());
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
}
在destruct函数中,以下内容足以关闭连接:
public function __destruct() {}
还是需要这个?
public function __destruct() {
$this->db->close();
}