• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Switch Database Connection Mysqli or Postgres ??

#1
Hi,

I need to Connect Mysqli Or Postgres in Database Connection.I need to Connect Both are default Option how done ??

We can find driver When query loaded ??

For Example :

Code:
if($db_driver == 'mysqli')
{

$db['default'] = array(
);
}
if($db_driver == 'postgres')
{

$db['default'] = array(
);
}

Is it possible to do like above or any other option to run both database connect in Default database.

Please Give me solution for my problem.
Geetha
Reply

#2
(12-13-2019, 02:53 AM)Geetha Wrote: Hi,

I need to Connect Mysqli Or Postgres in Database Connection.I need to Connect Both are default Option how done ??

We can find driver When query loaded ??

For Example :

Code:
if($db_driver == 'mysqli')
{

$db['default'] = array(
);
}
if($db_driver == 'postgres')
{

$db['default'] = array(
);
}

Is it possible to do like above or any other option to run both database connect in Default database.

Please Give me solution for my problem.



$db['default']['failover'] = array(
                array(
                        'hostname' => 'localhost1',
                        'username' => '',
                        'password' => '',
                        'database' => '',
                        'dbdriver' => 'mysqli',
                        'dbprefix' => '',
                        'pconnect' => TRUE,
                        'db_debug' => TRUE,
                        'cache_on' => FALSE,
                        'cachedir' => '',
                        'char_set' => 'utf8',
                        'dbcollat' => 'utf8_general_ci',
                        'swap_pre' => '',
                        'encrypt' => FALSE,
                        'compress' => FALSE,
                        'stricton' => FALSE
                ),
                array(
                        'hostname' => 'localhost2',
                        'username' => '',
                        'password' => '',
                        'database' => '',
                        'dbdriver' => 'pdo',
                        'dbprefix' => '',
                        'pconnect' => TRUE,
                        'db_debug' => TRUE,
                        'cache_on' => FALSE,
                        'cachedir' => '',
                        'char_set' => 'utf8',
                        'dbcollat' => 'utf8_general_ci',
                        'swap_pre' => '',
                        'encrypt' => FALSE,
                        'compress' => FALSE,
                        'stricton' => FALSE
                )
        );

refer this page https://codeigniter.com/user_guide/database/configuration.html 
Reply

#3
Thanq for your reply
Geetha
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.