【发布时间】:2013-07-25 08:47:51
【问题描述】:
我正在尝试使用 CodeIgniter 连接到 SQL 服务器。如果我使用 sqlsrv 驱动程序 - 我会收到一条致命错误消息,如果我使用 odbc 驱动程序 - 我会收到“无法使用提供的设置错误消息连接到您的数据库服务器”。有谁知道如何解决这个问题???我不介意怎么做,我只是想让 Codeigniter 连接到 SQL Server 数据库。
这是数据库配置文件
$db['otherdb']['hostname'] = '195.234.10.55\SQLEXPRESS';
$db['otherdb']['username'] = 'username';
$db['otherdb']['password'] = 'password';
$db['otherdb']['database'] = 'ONEDB';
$db['otherdb']['dbdriver'] = 'odbc'; // Done this in both ODBC and SQLSRV
$db['otherdb']['dbprefix'] = '';
$db['otherdb']['pconnect'] = TRUE;
$db['otherdb']['db_debug'] = TRUE;
$db['otherdb']['cache_on'] = FALSE;
$db['otherdb']['cachedir'] = '';
$db['otherdb']['char_set'] = 'utf8';
$db['otherdb']['dbcollat'] = 'utf8_general_ci';
$db['otherdb']['swap_pre'] = '';
$db['otherdb']['autoinit'] = TRUE;
$db['otherdb']['stricton'] = FALSE;
谢谢
【问题讨论】:
-
你能显示你用来连接服务器的代码吗?
-
您好,很抱歉回复晚了。您可以使用这些凭据与
odbc_connect()建立连接吗?另外,您是否已经连接到另一个数据库?
标签: php sql-server codeigniter-2