你能向我解释一下如何为数据库配置设置端口号:
class MY_Model extends CI_Model
{
protected static $db2_loaded = false;
protected static $db2 = false;
function __construct()
{
parent::__construct();
if(($this->session->userdata('login_user')!=false) && !self::$db2_loaded)
{
self::$db2_loaded = true;
$config['hostname'] = "localhost";
$config['username'] = "root";
$config['password'] = "";
$config['database'] = $this->session->userdata('bdd_compte');
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = TRUE;
$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";
self::$db2 = $this->load->database($config,TRUE);
}
$this->db = self::$db2;
}
}
有什么想法可以帮我设置不同的端口号?
谢谢!
$db['default']['port'] = 5432;
没有起作用, 改为:$db['default']['hostname'] = "mysqlhost.yourdomain.com:3310";
- Stefan Rogin