この質問のタイトルが実際の質問を説明していない場合は申し訳ありません。この質問のタイトルにふさわしい言葉が見つかりませんでした。
私は次のようなデータベースクラスを持っています:
class Database
{
private $link;
private $host, $username, $password, $database;
public function __construct($setup)
{
if ($setup == 'default') {
$this->host = 'localhost';
$this->username = 'root';
$this->password = 'root';
$this->database = 'infobox_sierraleone';
}
if ($setup == 'promo') {
$this->host = 'localhost';
$this->username = 'root';
$this->password = 'root';
$this->database = 'infobox';
}
$this->link = mysql_connect($this->host, $this->username, $this->password)
OR die("There was a problem connecting to the database.");
mysql_select_db($this->database, $this->link)
OR die("There was a problem selecting the database.");
}
public function __destruct()
{
mysql_close($this->link)
OR die("There was a problem disconnecting from the database.");
}
}
上記のクラスのさまざまなオブジェクトを別のファイルに作成しました。
include 'conn/database.php';
$db = new Database('default');
$db_promo = new Database('promo');
上記のスクリプトを実行すると、次のメッセージが表示されます。
There was a problem disconnecting from the database.
このメッセージが __destruct() 関数からのものであることに気付きました。しばらく調査しましたが、このメッセージが表示される理由とそれを取り除く方法がまだわかりません。
どんな種類の助けも大歓迎です。
ありがとうございました。
編集:コンストラクターにあった return ステートメントを削除しました。