我正在升級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