This is connect to database function in BxDolDb.php of Dolphin 7.3.5:
/**
* connect to database with appointed parameters
*/
function connect()
{
$full_host = $this->host;
$full_host .= $this->port ? ':'.$this->port : '';
$full_host .= $this->socket ? ':'.$this->socket : '';
$this->link = @mysql_pconnect($full_host, $this->user, $this->password);
if (!$this->link)
$this->error('Database connect failed', true);
if (!$this->select_db())
$this->error('Database select failed', true);
mysql_query("SET NAMES 'utf8'", $this->link);
mysql_query("SET sql_mode = ''", $this->link);
$GLOBALS['bx_db_link'] = $this->link;
}
But, This is connect to database function in BxDolDb.php of Dolphin 7.4:
/**
* connect to database with appointed parameters
*/
protected function connect()
{
$sSocketOrHost = ($this->socket) ? "unix_socket={$this->socket}" : "host={$this->host};port={$this->port}";
$this->link = new PDO(
"mysql:{$sSocketOrHost};dbname={$this->dbname};charset=utf8",
$this->user,
$this->password,
[
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode=""',
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_PERSISTENT => defined('DATABASE_PERSISTENT') && DATABASE_PERSISTENT ? true : false,
]
);
}
When MySQL is gone away, user will see an PHP error message like this in the browser:
Fatal error: Uncaught PDOException: SQLSTATE[HY000]......... require_once(' in /dolphin/inc/classes/BxDolDb.php on line 103
BTW, this is connect to database function in WordPress 5.1:
public function __construct($location, $name, $type)
{
$this->options = array(
'user' => null,
'pass' => null,
'host' => '127.0.0.1',
'port' => '3306',
'path' => '',
'extras' => array(
'prefix' => '',
),
);
$this->options = array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location));
// Path is prefixed with a "/"
$this->options['dbname'] = substr($this->options['path'], 1);
try
{
$this->mysql = new PDO("mysql:dbname={$this->options['dbname']};host={$this->options['host']};port={$this->options['port']}", $this->options['user'], $this->options['pass'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
}
catch (PDOException $e)
{
$this->mysql = null;
return;
}