无法从 codeigniter 2.1.4 连接到 SQL Server 2012
Posted
技术标签:
【中文标题】无法从 codeigniter 2.1.4 连接到 SQL Server 2012【英文标题】:Cannot connect to SQL Server 2012 from codeigniter 2.1.4 【发布时间】:2014-03-25 14:56:54 【问题描述】:警告
发生数据库错误
无法使用提供的设置连接到您的数据库服务器。
文件名:D:\xampp\htdocs\214report\system\database\DB_driver.php
行号:124
源代码
mmanagement/config/database.php
$active_group = '默认';
$active_record = TRUE;
$db['default']['hostname'] = 'HOSTNAME';
$db['default']['username'] = 'user';
$db['default']['password'] = 'password';
$db['default']['database'] = '报告';
$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;
php.ini
extension=php_pdo_sqlsrv_54_ts.dll
extension=php_sqlsrv_54_ts.dll
问题?
如何解决这个问题?
如果需要,请向我索取更多源代码。
【问题讨论】:
那么如果我与其他连接一起使用它就可以了。在其他项目中,codeigniter 不使用。 [index.php] /////"报表", "UID"=>"sa", "PWD"=>"root"); $conn = sqlsrv_connect($serverName, $connectionInfo); ?> /// 您是否尝试过使用 mssql_connect() 甚至 PDO 直接从 PHP 连接到该数据库? 【参考方案1】:1) 尝试查看是否满足所有系统要求
2) 尝试通过查看phpinfo()来查看Sqlserv是否加载;
根据微软网站http://www.microsoft.com/en-in/download/details.aspx?id=20098
系统要求/sqlserv 支持的操作系统
Windows 7、Windows 8、Windows 8.1、Windows Server 2008 R2、Windows Server 2008 Service Pack 2、Windows Vista Service Pack 2
The following summarizes requirements. It will be important to see System Requirements (Microsoft Drivers for PHP for SQL Server) for more detail.
Requires PHP 5.x. For information about how to download and install the latest stable binaries, visit http://windows.php.net for more detail.
Version support for PHP is as follows
Version 3.2 supports PHP 5.6, 5.5, and 5.4
Version 3.1 supports PHP 5.5 and 5.4
Version 3.0 supports PHP 5.4.
For more detail and for supported operating systems, see System Requirements (Microsoft Drivers for PHP for SQL Server) .
An Internet Information Services (IIS) Web server is required
Versions 3.2 and 3.1 of the driver require Microsoft ODBC Driver 11 (or higher). You can download the Microsoft ODBC Driver 11 for SQL Server from the Microsoft® ODBC Driver 11 for SQL Server® - Windows page.
Version 3.0 requires the x86 version of Microsoft SQL Server 2012 Native Client.
Version 2.0 requires the x86 version of Microsoft SQL Server 2008 R2 Native Client.
【讨论】:
以上是关于无法从 codeigniter 2.1.4 连接到 SQL Server 2012的主要内容,如果未能解决你的问题,请参考以下文章
CodeIgniter 3.1.10:无法通过 DSN 使用 ODBC 连接到远程数据库
Codeigniter 无法连接到外部 SQL Server
无法使用 codeigniter 连接到 SQL SERVER 数据库
无法使用提供的设置连接到您的数据库服务器。 (Codeigniter) 和 MySQL® 服务器当前处于脱机状态。 (面板)