$dbConfig = [
'host' => DB_HOST,
'dbname' => DB_DATABASE,
'username' => DB_USER,
'password' => DB_PASS
];
// Debug Config
$config = [
'logDir' => APP_DIR . 'View/logs/',
'attributes' => [
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
//PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, // Set pdo error mode silent
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, // If you want to Show Class exceptions on Screen, Uncomment below code
PDO::ATTR_EMULATE_PREPARES => true, // Use this setting to force PDO to either always emulate prepared statements (if TRUE), or to try to use native prepared statements (if FALSE).
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC // Set default pdo fetch mode as fetch assoc
]
];
$db = new Database($dbConfig, $config);
// Debug Config
$config = [
'logDir' => APP_DIR . 'View/logs/',
'attributes' => [
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
//PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, // Set pdo error mode silent
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, // If you want to Show Class exceptions on Screen, Uncomment below code
PDO::ATTR_EMULATE_PREPARES => true, // Use this setting to force PDO to either always emulate prepared statements (if TRUE), or to try to use native prepared statements (if FALSE).
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC // Set default pdo fetch mode as fetch assoc
]
];
$dsn = [
'host' => DB_HOST,
'dbname' => DB_DATABASE,
'dbtype' => 'mysql'
];
$db = new Database($dsn, DB_USER, DB_PASS, $config);
// Debug Config
$config = [
'log_dir' => APP_DIR . 'View/logs/',
'attributes' => [
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
//PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, // Set pdo error mode silent
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, // If you want to Show Class exceptions on Screen, Uncomment below code
PDO::ATTR_EMULATE_PREPARES => true, // Use this setting to force PDO to either always emulate prepared statements (if TRUE), or to try to use native prepared statements (if FALSE).
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC // Set default pdo fetch mode as fetch assoc
]
];
$db = new Database('mysql:host='.DB_HOST.';dbname=' . DB_DATABASE . ';port=3306', DB_USER, DB_PASS, $config);