mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +00:00
catch exeption when opening database connection
This commit is contained in:
parent
cd9d1fe25f
commit
62d9241276
|
@ -283,22 +283,26 @@ class SeedDMS_Core_DatabaseAccess {
|
|||
$dsn = $this->_driver.":".$this->_database;
|
||||
break;
|
||||
}
|
||||
/** @noinspection PhpUndefinedVariableInspection */
|
||||
$this->_conn = new PDO($dsn, $this->_user, $this->_passw);
|
||||
if (!$this->_conn)
|
||||
return false;
|
||||
try {
|
||||
/** @noinspection PhpUndefinedVariableInspection */
|
||||
$this->_conn = new PDO($dsn, $this->_user, $this->_passw);
|
||||
if (!$this->_conn)
|
||||
return false;
|
||||
|
||||
switch($this->_driver) {
|
||||
case 'mysql':
|
||||
$this->_conn->exec('SET NAMES utf8');
|
||||
/* Turn this on if you want strict checking of default values, etc. */
|
||||
// $this->_conn->exec("SET SESSION sql_mode = 'STRICT_TRANS_TABLES'");
|
||||
/* The following is the default on Ubuntu 16.04 */
|
||||
// $this->_conn->exec("SET SESSION sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'");
|
||||
break;
|
||||
case 'sqlite':
|
||||
$this->_conn->exec('PRAGMA foreign_keys = ON');
|
||||
break;
|
||||
switch($this->_driver) {
|
||||
case 'mysql':
|
||||
$this->_conn->exec('SET NAMES utf8');
|
||||
/* Turn this on if you want strict checking of default values, etc. */
|
||||
/* $this->_conn->exec("SET SESSION sql_mode = 'STRICT_TRANS_TABLES'"); */
|
||||
/* The following is the default on Ubuntu 16.04 */
|
||||
/* $this->_conn->exec("SET SESSION sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'"); */
|
||||
break;
|
||||
case 'sqlite':
|
||||
$this->_conn->exec('PRAGMA foreign_keys = ON');
|
||||
break;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
if($this->_useviews) {
|
||||
$tmp = $this->ViewList();
|
||||
|
|
Loading…
Reference in New Issue
Block a user