CodeIgniter MSSQL连接 [英] CodeIgniter MSSQL connection

查看:143
本文介绍了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:\inetpub\wwwroot\system\database\DB_driver.php
Line Number: 124

如果我尝试通过MSSQL连接,我只是得到一个空白页,无论什么。

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

如果我尝试使用SQLSRV使用以下params:

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:\inetpub\wwwroot\system\database\drivers\sqlsrv\sqlsrv_driver.php on line 76

我一直在读对旧帖子和不同的视图,但我还没有解决问题。

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

我只是寻找一个解决方案的单个DB驱动程序 - 任何东西,连接很好。

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天全站免登陆