我正在升级Codeigniter应用程序我已经运行在1.7.2到2.0.3,但我无法连接到SQL Server。两个版本都运行在运行php 5.2.10的同一台服务器上并连接到同一个SQL Server。Codeigniter 2.0.3与SQL Server活动记录
这是CI 2.0.3
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 260
错误这是我使用的连接字符串这当然适用于1.7.2
$db['reports']['hostname'] = "mysqlserver";
$db['reports']['username'] = "sqluser";
$db['reports']['password'] = "sqlpass";
$db['reports']['database'] = "SQLReportDB";
$db['reports']['dbdriver'] = "mssql";
$db['reports']['dbprefix'] = "";
$db['reports']['pconnect'] = TRUE;
$db['reports']['db_debug'] = TRUE;
$db['reports']['cache_on'] = FALSE;
$db['reports']['cachedir'] = "";
$db['reports']['port'] = 972;
在控制器我打电话与此连接
$report_db = $this->load->database('reports', TRUE);
以下是加载程序文件中报告故障的功能。 260 线是return DB($params, $active_record);
/**
* Database Loader
*
* @param string the DB credentials
* @param bool whether to return the DB object
* @param bool whether to enable active record (this allows us to override the config setting)
* @return object
*/
public function database($params = '', $return = FALSE, $active_record = NULL)
{
// Grab the super object
$CI =& get_instance();
// Do we even need to load the database class?
if (class_exists('CI_DB') AND $return == FALSE AND $active_record == NULL AND isset($CI->db) AND is_object($CI->db))
{
return FALSE;
}
require_once(BASEPATH.'database/DB.php');
if ($return === TRUE)
{
return DB($params, $active_record);
}
// Initialize the db variable. Needed to prevent
// reference errors with some configurations
$CI->db = '';
// Load the DB class
$CI->db =& DB($params, $active_record);
}
听起来像是一个实际的连接错误。仔细检查凭据?在sql服务器日志中的任何东西? – stormdrain
尝试设置$ db ['reports'] ['pconnect'] = FALSE; – Ivan
尝试设置$ db ['reports'] ['pconnect'] = FALSE。不用找了。 – getSurreal