I have a project that uses multiple databases, MySQL and Oracle.
In Codeigniter 3 we have database driver
oci8 and
mysqli that can be easily used and configured in database connection.
Below is my database connection in Codeigniter 3:
Code:
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'password',
'database' => 'dki_jft',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT === 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$active_group = 'oracle';
$query_builder = TRUE;
$db['oracle'] = array(
'dsn' => '',
// Local setting
// 'hostname' => 'localhost/XE',
// 'username' => 'system',
// 'password' => 'password',
// 'database' => '',
// end local setting
'dbdriver' => 'oci8',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT === 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
How can I use the same setting above in Codeigniter 4?
I noticed that in Codeigniter 4 RC 3 there is no (or not yet) database driver for Oracle.
This is my setting in Codeigniter 4:
Code:
public $defaultGroup = 'default';
/**
* The default database connection.
*
* @var array
*/
public $default = [
'DSN' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => 'PASSWORD',
'database' => 'DATABASE',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'cacheOn' => false,
'cacheDir' => '',
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
];
public $defaultGroup = 'oracle';
/**
* The default database connection.
*
* @var array
*/
public $oracle = [
'DSN' => '',
// Local setting
// 'hostname' => 'localhost/XE',
// 'username' => 'system',
// 'password' => 'password',
// 'database' => 'mydtabase',
// end local setting
'DBDriver' => 'WHAT DRIVER SHOULD I USE?',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'cacheOn' => false,
'cacheDir' => '',
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
];
Thank you for your help and kind attentions