How to sync from local database to server database using Codeigniter

0
1371

inside your config file define your local database and server database. like this.i hope it will help you.

//database.php

$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
    'dsn'   => '',
//  'hostname' => 'localhost',
//  'username' => 'root',
//  'password' => 'root',
//  'database' => 'alpaca_web',
    '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
);
switch (ENVIRONMENT) {
    case 'development':
        $db['default']['hostname'] = 'localhost';
        $db['default']['username'] = 'user_name';
        $db['default']['password'] = 'root';
        $db['default']['database'] = 'database_name';
        break;
    case 'testing':
    case 'production':
        $db['default']['hostname'] = 'localhost';
        $db['default']['username'] = 'user_name';
        $db['default']['password'] = 'password';
        $db['default']['database'] = 'database_name';
        break;
    default:
        $db['default']['hostname'] = 'localhost';
        $db['default']['username'] = 'user_name';
        $db['default']['password'] = 'password';
        $db['default']['database'] = 'database_name';
        break;
}

//config.php

switch (ENVIRONMENT) {
    case 'development':
        $config['base_url'] = 'http://localhost/site_name/';
        break;
    case 'testing':
        $config['base_url'] = 'http://server ip or name/';
        break;
    default:
        $config['base_url'] = 'http://localhost/site_name/';
        break;

LEAVE A REPLY

Please enter your comment!
Please enter your name here