-
andoyoandoyo
Andoyo (Java Web Media)
-
Posts: 31
Threads: 4
Joined: Jan 2015
Reputation:
0
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
-
Sercan
Newbie
-
Posts: 2
Threads: 1
Joined: Jul 2018
Reputation:
-1
CI4, oracle not yet support.
-
InsiteFX
Super Moderator
-
Posts: 6,301
Threads: 288
Joined: Oct 2014
Reputation:
234
You should only need to change the group name property when loading a database.
PHP Code: $db = \Config\Database::connect('group_name', false);
Database settings.
PHP 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, ];
/** * 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, ];
Try that when they release the oracle driver.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
-
andoyoandoyo
Andoyo (Java Web Media)
-
Posts: 31
Threads: 4
Joined: Jan 2015
Reputation:
0
|