PHP Classes

Error on disconnect

Recommend this page to a friend!

      Simple PHP MySQLi  >  All threads  >  Error on disconnect  >  (Un) Subscribe thread alerts  
Subject:Error on disconnect
Summary:When disconnect is called and the database is not initialised
Messages:2
Author:William Cairns
Date:2017-09-09 15:50:03
 

  1. Error on disconnect   Reply   Report abuse  
Picture of William Cairns William Cairns - 2017-09-09 15:50:03
While adding PHPUnit tests to my project using this package I got numerous errors. By checking if it is initialized before closing I could prevent the errors.

/**
* Disconnect from db server
* Called automatically from __destruct function
*/
public function disconnect()
{
if( self::$inst != null )
{
$this->link->close();
}
}

  2. Re: Error on disconnect   Reply   Report abuse  
Picture of Bennett Stone Bennett Stone - 2017-09-09 16:39:14 - In reply to message 1 from William Cairns
Good catch! I don't actually still support this particular class as I created a PDO version here: https://www.phpclasses.org/package/8933-PHP-Wrapper-to-access-MySQL-databases-using-PDO.html which is more secure.

The same methods are implemented within SimplePDO so converting between them is quite easy as well.