I have installed Xampp with a CodeIgniter installation. I want to connect from CodeIgniter to a SQL database.
I changed the database config file and set the dbdriver to sqlsrv.
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'IP Adress;
$db['default']['username'] = 'DBUserName';
$db['default']['password'] = 'DBPassword';
$db['default']['database'] = 'DBName';
$db['default']['dbdriver'] = 'sqlsrv';
$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 my controller I have the following code to try the connection:
$this->load->database();
$db_obj = $this->db->load('sql_Test',TRUE);
$connected = $db_obj->initialize();
if (!$connected){
$db_obj = $this->d->load('yyy',TRUE);
}
else{
die('connected');
}
I have the following error:
Fatal error: Call to undefined function sqlsrv_connect() in C:xampphtdocssystemdatabasedriverssqlsrvsqlsrv_driver.php on line 76
I have read on a forum that I have to change line 89 from sqlsrv_driver.php:
function db_pconnect()
{
// $this->db_connect(TRUE); original
return $this->db_connect(TRUE);
}
What do I wrong?
See Question&Answers more detail:os