笨不连接到SQL Server

问题描述 投票:0回答:1

我试图连接到使用笨的SQL服务器。如果我使用SQLSRV驱动程序 - 我得到一个致命的错误消息,如果我使用ODBC驱动程序 - 我得到一个“无法使用所提供的设定错误的信息连接到数据库服务器。有谁知道如何解决这个问题???我不介意怎么样,我只想笨连接到SQL Server数据库。

这是数据库配置文件

$db['otherdb']['hostname'] = '195.234.10.55\SQLEXPRESS';
$db['otherdb']['username'] = 'username';
$db['otherdb']['password'] = 'password';
$db['otherdb']['database'] = 'ONEDB';
$db['otherdb']['dbdriver'] = 'odbc'; // Done this in both ODBC and SQLSRV
$db['otherdb']['dbprefix'] = '';
$db['otherdb']['pconnect'] = TRUE;
$db['otherdb']['db_debug'] = TRUE;
$db['otherdb']['cache_on'] = FALSE;
$db['otherdb']['cachedir'] = '';
$db['otherdb']['char_set'] = 'utf8';
$db['otherdb']['dbcollat'] = 'utf8_general_ci';
$db['otherdb']['swap_pre'] = '';
$db['otherdb']['autoinit'] = TRUE;
$db['otherdb']['stricton'] = FALSE;

谢谢

php sql-server codeigniter-2
1个回答
0
投票

(不要吝啬复活旧的文章,但以防万一别人都在寻找答案,因为这个帖子我的搜索过程中想出了...)

短一步一步的指导,使用本机驱动程序从笨3连接到SQL_SERVER:

  1. 首先下载PHP从http://www.microsoft.com/en-us/download/details.aspx?id=20098 SQL_SERVER微软本地驱动程序。小心选择适合您的设置之一。
  2. 它安装到PHP扩展目录中。
  3. 配置php.ini中的新的扩展。取消注释或附加线路(取决于已选定驱动程序版本)。即: extension = php_sqlsrv_55_ts.dll
  4. 重新启动Apache。 现在,你的PHP设置是能够连接到数据库SQL_SERVER。
  5. 通过配置的application / config / database.php中一样设置您的CodeIgniter数据库连接 <?php // native-driver connection $db['default'] = array( 'dsn' => '', 'hostname' => 'SERVER\SQLEXPRESS', 'username' => 'test_user', 'password' => 'test_password', 'database' => 'test01', 'dbdriver' => 'sqlsrv', 'dbprefix' => '', 'pconnect' => FALSE, 'db_debug' => TRUE, 'cache_on' => FALSE, 'cachedir' => 'application/cache', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'autoinit' => TRUE, 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE, 'failover' => array(), 'save_queries' => TRUE );

从笨3.0.1上SQL_SERVER 2008 R2和SQL_SERVER 2014次特快测试。

© www.soinside.com 2019 - 2024. All rights reserved.