【发布时间】:2015-06-20 06:29:08
【问题描述】:
我是使用 postgresql 的新手,我已经使用 Codeigniter 一年了。
我有一个小型 postgresql 数据库,我想从 Codeigniter 调用它。
在我的 database.php 文件中,我有这个设置:
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => 'pgsql:host=localhost;port=5432;dbname=test;user=postgres;password=aPass',
// 'dsn' => '',
'hostname' => 'localhost',
'username' => 'postgres',
'password' => 'aPass',
'database' => 'test',
'dbdriver' => '',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
// 'port' => '5432'
);
在控制器中我有这个功能:
public function dbtest(){
$this->load->database();
$feeds = $this->db->get('vts_feeds');
echo $feeds;die();
}
我得到的结果是:
An Error Was Encountered
You have not selected a database type to connect to.
为什么它不起作用?
【问题讨论】:
标签: php database postgresql codeigniter