0

我可以用什么方法在codeigniter和sql server之间建立连接?下面是我连接的方式,但它似乎不起作用

    $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

);

连接未建立,我无法弄清楚是什么问题

4

1 回答 1

0
$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

);

首先,我需要在安装扩展的计算机上安装 sql server php 驱动程序。下载驱动然后解压,然后将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复制到/php/ext。然后将这些添加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到 /php/php.ini 中。重启阿帕奇

于 2020-09-11T11:22:48.977 回答