本文实例讲述了CodeIgniter针对数据库的连接、配置及使用方法。分享给大家供大家参考,具体如下:
1. 数据库:
sql;">
create database test;
create table users(
id int not null,name varchar(10),pwd varchar(10),email varchar(20)
)
insert into users values(1,'shunping','aa@163.com');
insert into users values(2,'shunping2','bb@163.com');
2. 我用的是Postgreql
在\CodeIgniter\system\application\config\database.PHP文件中配置数据库参数:
<div class="jb51code">
<pre class="brush:PHP;">
$active_group = "default";
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "postgres";
$db['default']['password'] = "admin";
$db['default']['database'] = "test";
$db['default']['dbdriver'] = "postgre";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['port'] = "5432";