I'm working on a project which will be handled locally, but it has to replicate to the database that is in the cloud, I'm using CodeIgniter, and I really do not know how I could do it
I leave you what I have planned to do.
This would be the configuration of the database:
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'intranet',
'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
);
$db['nube'] = array(
'dsn' => '',
'hostname' => 'xxx.xxx.xxx.xxx',
'username' => 'intranet',
'password' => 'MY_SECRET_PASSWORD',
'dbdriver' => 'mysqli',
'database' => 'intranet',
'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
);
This would be my model:
function __construct() {
parent::__construct();
$this->db_caja = $this->load->database('caja','default', TRUE);
}
function insertar_pago() {
$sql = $this->_obtener_data_query_pagos();
$query = $this->db_caja->query($sql);
return $query->result();
}