Monday, February 17, 2014

MSSQL Database Configuration using ODBC in CodeIgniter

MSSQL Database Configuration using ODBC in CodeIgniter

CodeIgniter has a config file that lets you store your database connection values (username, password, database name, etc.). The config file is located atapplication/config/database.php. You can also set database connection values for specific environments by placing database.php it the respective environment config folder.
The config settings are stored in a multi-dimensional array with this prototype:

/* Connect MSSQL Server*/
$db['mssql']['hostname'] = 'Driver={SQL Server};Server=192.168.202.20;Database=test_db;
$db['mssql']['username'] = 'sa';
$db['mssql']['password'] = '654321';
$db['mssql']['database'] = 'test_db';
$db['mssql']['dbdriver'] = 'odbc';
$db['mssql']['dbprefix'] = '';
$db['mssql']['pconnect'] = FALSE;
$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;

11 comments: