CodeIgniter MSSQL 连接 [英] CodeIgniter MSSQL connection

查看:24
本文介绍了CodeIgniter MSSQL 连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Web 项目,该项目将部署在运行 IIS 7.5 和 PHP 5.3.8 的 64 位 Windows 2008 Server 计算机上.系统上的数据库是 Microsoft SQL Server 2008 R2.我正在 CodeIgniter 2.1.0 框架上开发应用程序,但我有点难以让它连接到 SQL Server.

I'm working on a web project that is to be deployed on a 64bit Windows 2008 Server machine running IIS 7.5 and PHP 5.3.8. The database on the system is Microsoft SQL Server 2008 R2. I'm developing the application on the CodeIgniter 2.1.0 framework, and I'm a bit stumped on getting it to connect to the SQL Server.

我已经尝试使用 MSSQL、ODBC 和 SQLSRV 数据库驱动程序,但遇到了三个不同的错误,每个不同的驱动程序.

I've tried using both the MSSQL, ODBC and SQLSRV database drivers, and have encountered three separate errors, for each different driver.

这是我的 ODBC 配置:

Here is my configuration for ODBC:

$db['default']['hostname'] = 'SA';
$db['default']['username'] = 'petre';
$db['default']['password'] = 'start';
$db['default']['database'] = 'petre';
$db['default']['dbdriver'] = 'odbc';
$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;

我在数据源下定义了 SA 的 DNS,并且我确定用户名和密码都有效,并且服务器接受混合身份验证(Windows + SQL 身份验证).

I have the DNS for SA defined under Data Sources, and I'm sure that the username and password are both valid, and that the server accepts Mixed authentication(Windows + SQL authentication).

我正在自动加载数据库库,对于我访问的任何页面,我都会得到:

I'm auto-loading the DB library and for any page I access I get:

Unable to connect to your database server using the provided settings.
Filename: C:inetpubwwwrootsystemdatabaseDB_driver.php
Line Number: 124

如果我尝试通过 MSSQL 连接,无论如何我都会得到一个空白页面.

If I try to connect via MSSQL, I just get a blank page, no matter what.

如果我尝试使用以下参数使用 SQLSRV:

If I try using SQLSRV using the following params:

$db['default']['hostname'] = '127.0.0.1';
$db['default']['username'] = 'petre';
$db['default']['password'] = 'start';
$db['default']['database'] = 'petre';
$db['default']['dbdriver'] = 'sqlsrv';

即使我链接到 php.ini 中的 sqlsrv DLL 文件,我也收到以下消息:

Even though I'm linking to the sqlsrv DLL file in php.ini, I get the following message:

PHP Fatal error:  Call to undefined function sqlsrv_connect() in C:inetpubwwwrootsystemdatabasedriverssqlsrvsqlsrv_driver.php on line 76

我一直在阅读旧帖子和不同观点,但我还没有解决问题.

I've been reading up on old posts and different views but I've yet to solve the problem.

我只是在为单个数据库驱动程序寻找解决方案 - 任何让它连接的东西都很好.有人对解决这个问题有什么建议吗?

I'm only looking for a solution for a single DB Driver - anything that gets it to connect is fine. Does anyone have any advice on solving this?

推荐答案

您为 SQLSRV 驱动程序显示的错误意味着 DLL 从未加载.你的 php_info() 怎么说?

The error you are showing for the SQLSRV driver implies the DLL is never loading. What does your php_info() say?

另外,您是否安装了 SQL Server Native Access Client (SNAC) 10?SQLSRV 驱动程序需要它.

Also, do you have the SQL Server Native Access Client (SNAC) 10 installed? The SQLSRV driver requires it.

这篇关于CodeIgniter MSSQL 连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆