无法使用PHP 7.2.4与SQL Server 2008进行连接

时间:2018-04-17 11:58:16

标签: php sql-server-2008 database-connection codeigniter-3 windows-server-2008-r2

我在PHP 7.2.4 and Apache 2.4上新安装了windows server 2008 r2。一切都完成了;我已经设置了路径,但问题是当我为连接配置我的PHP文件时,它会给我一个无法连接数据库的错误。我正在使用codeIgniter 3.1.8

$db['default'] = array(
    'dsn' => '', 
    'hostname' => 'localhost', 
    'username' => 'root', 
    'password' => '', 
    'database' => 'database_name', 
    'dbdriver' => 'mysqli', 
    'dbprefix' => '', 
    'pconnect' => TRUE, 
    'db_debug' => TRUE, 
    'cache_on' => FALSE 
)

1 个答案:

答案 0 :(得分:0)

定义( '环境', '发展');这是MSign 2008R2的Codeigniter 3,database.php(非SSPI)代码段示例:

 define('ENVIRONMENT','development');                            
 $db['test1'] = array( 'dsn'    => '',
    'hostname' => 'MY_MSSQL_DB_FQDN\i1,10001',
    'username' => 'somemssqluser',
    'password' => 'somemssqlpassword',
    'database' => 'somedbname',
    '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
);