Allora senza indugi ti posto il codice...
Codice PHP:
function __construct( $initializeDatabase = false ) {
$this->m_host = "localhost";
$this->m_user = "root";
$this->m_pass = "root";
$this->m_dbName = "name";
$this->m_dbLink = mysql_connect( $this->m_host, $this->m_user, $this->m_pass );
if( !$this->m_dbLink ) die( mysql_error() );
$this->m_select = mysql_select_db( $this->m_dbName, $this->m_dbLink )
}
function __destruct() {
$this->close();
}
private function close () {
if ( $this->m_dbLink)
mysql_close($this->m_dbLink);
}
A questo punto quello che non capisco è a cosa serva il distruttore se PHP gestisce in modo automatico la chiusura al DB ???
In altri linguaggi di programmazione è necessario e credo anche a in PHP