AnsweredAssumed Answered

bug(?)  in connect method

Question asked by alessio palma on Feb 23, 2015
1) public function connect(array $configOptions = null, $dieOnError = false) {
2)   3) ... some code here...   4)
5) if(!isset($this->database)) {
                                                              At 5) code checks $this->database to understand if the connection is still open and this works together the disconnect method which does:
$this->database = null;
Actually it does not check if connection is still alive.
I think adding this code before 5) it's a better solution.

if ( isset( $this->database) ) {
   // Just ping the database
   $result = @mysqli_query($this->database, "SELECT 1;" ); 
  if ( ! isset($result) ) { 
       $this->database = null;
  }
  else 
    $result->close()
}
This is just an example and works only for mysql databases.

I'm looking for some feedback.

Outcomes