首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

[CI]多数据库配备使用

2012-12-26 
[CI]多数据库配置使用1.在database.php配置文件中 加入$db[[colorred]second[/color]][hostname]

[CI]多数据库配置使用
1.在database.php配置文件中 加入

$db['[color=red]second[/color]']['hostname'] = '[color=red]localhost[/color]';$db['second']['username'] = 'root';$db['second']['password'] = 'root';$db['second']['database'] = '[color=red]ci_0_2[/color]';$db['second']['dbdriver'] = 'mysql';$db['second']['dbprefix'] = '';$db['second']['pconnect'] = TRUE;$db['second']['db_debug'] = TRUE;$db['second']['cache_on'] = FALSE;$db['second']['cachedir'] = '';$db['second']['char_set'] = 'utf8';$db['second']['dbcollat'] = 'utf8_general_ci';$db['second']['swap_pre'] = '';$db['second']['autoinit'] = TRUE;$db['[color=red]second[/color]']['stricton'] = FALSE;

2. 在model中加入:
function __construct(){parent::__construct();$this->[color=red]second_db[/color] = $this->load->database('[color=red]second[/color]', true);}function verify_users($email, $password){$q = $this->[color=red]second_db[/color]->where('email', $email)->where('password', sha1($password))->limit(1)->get('users');if($q->num_rows > 0){return $q->row();}return false;}

热点排行