我试过这样的......在我的database.php文件中
$active_group = 'default';
$active_record = TRUE;
$uri = $_SERVER['REQUEST_URI'];
$pieces = explode('/', $uri);
if($pieces[1]==""){
$_SESSION['user_db_username']='**';
$_SESSION['user_db_pass']='**';
$_SESSION['user_db_name']='**';
}
else
{
$link = mysql_connect('**', '**', '**');
if($link){
$db_selected = mysql_select_db('**', $link);
if ($db_selected)
{
$query_arr= "SELECT * FROM ** where domain='".$pieces[1]."' ";
$queryResult_arr=mysql_query($query_arr,$link);
while($row=mysql_fetch_assoc($queryResult_arr))
{
$_SESSION['user_db_user']=$row['**'];
$_SESSION['user_db_pass']=$row['**'];
$_SESSION['user_db_name']=$row['**'];
}
}
}
}
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = $_SESSION['user_db_username'];
$db['default']['password'] = $_SESSION['user_db_pass'];
$db['default']['database'] = $_SESSION['user_db_name'];