CI连接到SQL SERVER [英] CI connect to SQL SERVER

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

问题描述

我想连接到sql server,我的php版本是5.4,并且我拥有MS SQL Server 2008 R2,我使用PHP Codeigniger 2.1.4
i使用sqlsrv30.exe
i使用XAMPP 1.8.2

i want to connect to sql server my php version is 5.4 and i have MS SQL Server 2008 R2 and i use PHP Codeigniger 2.1.4 i use sqlsrv30.exe i use XAMPP 1.8.2

我更改database.php配置

i change database.php config

$db['default']['hostname'] = '192.168.5.208';
$db['default']['username'] = 'xxx';
$db['default']['password'] = 'xxx';
$db['default']['database'] = 'xxx';
$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;

我下载sqlsrv30.exe。将其安装在php / ext

i download sqlsrv30.exe. install it in php/ext

我在php.ini文件中添加以下内容:

i add the following on the php.ini file:

extension=php_sqlsrv_54_ts.dll

我安装Native Client 10

i install Native Client 10

我将文件夹database-driver-sqlsrv中的sqlsrv_driver.php更改为

i change sqlsrv_driver.php in folder database-driver-sqlsrv to

function db_pconnect() {
        //return $this->db_connect(TRUE);
        return $this->db_connect(TRUE);
    }

我也尝试添加

db['default']['port'] = 1433;

,但仍无法正常工作。我总是遇到ff。错误:

but its still not working. I always encountered the ff. error:

A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: C:\xampp\htdocs\HRM\system\database\DB_driver.php
Line Number: 124

请帮助...

推荐答案

我已经您一年前遇到的同样麻烦。看看这里的答复,那里的人提出了一些很棒的建议: CodeIgniter MSSQL连接

I've had the same trouble you've had about a year ago. Have a look at the replies here, there are some great suggestions from people in there: CodeIgniter MSSQL connection

@StefenWiranata对不起,刚才注意到您的评论的第2部分-我不记得我在哪里进行了更改,但如果可以的话,我可以尝试今晚的情况,不能解决。我肯定知道CI在system / database / drivers / odbc /中的表名周围添加了撇号,很可能是在odbc_driver.php文件中。

@StefenWiranata Sorry, just noticed part 2 of your comment - I can't remember where I'd made the change, but I can try and look tonight if you can't get it solved. I know for sure that CI was adding apostrophes around the table names somewhere in system/database/drivers/odbc/, most likely in the odbc_driver.php file.

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

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