is there a way of creating a connection between codeigniter 3 and sql server using php version 7.2

124 views Asked by At

what is way i can use to create a connection between codeigniter and sql server? below is the way i was connecting but it seems not to work

    $active_group = 'default'; $query_builder = TRUE; $db['default'] = array(
'dsn'   => '',
'hostname' => 'localhost',
'port' => '1433',
'username' => 'username',
'password' => '*****',
'database' => 'database_name',
'dbdriver' => 'mssql',
'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

);

the connection is not established and i cant figure out what is the problem

1

There are 1 answers

0
Bashir Saidi Wamula On BEST ANSWER
$active_group = 'default'; $query_builder = TRUE; $db['default'] = array(
'dsn'   => '',
'hostname' => 'computer_name\SQLEXPRESS',
'port' => '1433',
'username' => 'username',
'password' => '*****',
'database' => 'database_name',
'dbdriver' => 'sqlsrv',
'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

);

First i needed to install the sql server php driver on my computer installing the extension. download driver then extract then copy php_pdo_sqlsrv_72_nts_x64.dll, php_pdo_sqlsrv_72_ts_x64.dll, php_sqlsrv_72_nts_x64.dll, php_sqlsrv_72_ts_x64.dll to the /php/ext. then add these extension=php_pdo_sqlsrv_72_nts_x64.dll extension=php_pdo_sqlsrv_72_ts_x64.dll extension=php_sqlsrv_72_nts_x64.dll extension=php_sqlsrv_72_ts_x64.dll in /php/php.ini. restart apache