Skip to content

Instantly share code, notes, and snippets.

@mpmont
Created September 4, 2012 14:25
Show Gist options
  • Select an option

  • Save mpmont/3621634 to your computer and use it in GitHub Desktop.

Select an option

Save mpmont/3621634 to your computer and use it in GitHub Desktop.
double connection codeigniter
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'username';
$db['default']['password'] = 'password';
$db['default']['database'] = 'myDatabase';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
$db['mssql']['hostname'] = 'localhost';
$db['mssql']['username'] = 'username';
$db['mssql']['password'] = 'password';
$db['mssql']['database'] = 'myseconddatabase';
$db['mssql']['dbdriver'] = 'mssql';
$db['mssql']['dbprefix'] = '';
$db['mssql']['pconnect'] = TRUE;
$db['mssql']['db_debug'] = TRUE;
$db['mssql']['cache_on'] = FALSE;
$db['mssql']['cachedir'] = '';
$db['mssql']['char_set'] = 'utf8';
$db['mssql']['dbcollat'] = 'utf8_general_ci';
$db['mssql']['swap_pre'] = '';
$db['mssql']['autoinit'] = TRUE;
$db['mssql']['stricton'] = FALSE;
/* End of file database.php */
/* Location: ./application/config/database.php */
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Example_model extends CI_Model {
public function __construct()
{
parent::__construct();
$this->db_mssql = $this->load->database('mssql', TRUE);
}
public function get_all() {
return $this->db_mssql->get('examples');
}
}
/* End of file Example_model.php */
/* Location: ./application/models/example_model.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment