How do I connect to a SQL Server database in CodeIgniter?
I\'m currently starting an application in CodeIgniter and I would like to use SQL Server.
$
Follow these simple steps:
Install the instance with "mixed mode"-enabled. If your unsure watch this - video starts at the right sequence. Maybe it's a good idea to watch it completely.
change the db-config in '...ci/application/config/database.php'
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'sa', // <- use 'sa'
'password' => 'THE_PASSWORD_YOU_SET_ON_INSTALL', // "mixed-mode"
'database' => 'ci',
'dbdriver' => 'sqlsrv',
// 'dbdriver' => 'mysqli', // <- my old "non-server" config (approx. 70% slower)
'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
);