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.
$
it is the same process as mysql. use the same configuration given below:
$active_group = 'default'; $active_record = TRUE;
$db['default']['hostname'] = 'xxx.xx.xx.xx\SQLEXPRESS';
$db['default']['username'] = 'sa';
$db['default']['password'] =
'xxxxxxx'; $db['default']['database'] = 'xxxxx';
$db['default']['dbdriver'] = 'mssql';
$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;
In your Model use same as
function selectagent($table,$agent) {
$field = $this->db->get_where($table, array('var1' =>$agent,'day(date)'=>date('d')));
$fields=$field->result(); return $fields; }