dongqiaogouk86049 2013-10-16 06:29
浏览 77
已采纳

CI连接到SQL SERVER

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

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;

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

i add the following on the php.ini file:

extension=php_sqlsrv_54_ts.dll

i install Native Client 10

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

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

i also try add

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

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

Please help...

  • 写回答

3条回答 默认 最新

  • duankeng9477 2013-10-16 08:45
    关注

    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 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看