【发布时间】:2014-12-16 18:27:13
【问题描述】:
我已经看到并尝试了Codeigniter - multiple database connections、You have specified an invalid database connection group codeigniter error、firebird - codeigniter connection 中的所有解决方案,但都没有奏效。
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'testing';
$db['default']['dbdriver'] = 'mysqli';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
$db['fbird']['hostname'] = "localhost";
$db['fbird']['username'] = "SYSDBA";
$db['fbird']['password'] = "masterkey";
$db['fbird']['database'] = "C:\waitkyl.fdb";
$db['fbird']['dbdriver'] = "firebird";
这样配置后,我这样调用fbird数据库:
class Fb_model extends CI_Model{
public function __construct(){
parent::__construct();
}
public function getAll(){
$db = $this->load->database('fbird', TRUE);
return $db->get('categories')->result();
}
}
我在尝试输出值print_r($this->fb_model->getAll()); 后得到的错误是:
致命错误:在非对象上调用成员函数 result()
这通常意味着表“类别”不存在。这不是真的。
所以我尝试将我的配置文件更改为:
$db['fbird']['hostname'] = "localhost";
$db['fbird']['username'] = "SYSDBA";
$db['fbird']['password'] = "masterkey";
$db['fbird']['database'] = "C:\waitkyl.fdb";
$db['fbird']['dbdriver'] = "firebird";
$db['fbird']['dbprefix'] = "";
$db['fbird']['pconnect'] = FALSE;
$db['fbird']['db_debug'] = TRUE;
$db['fbird']['cache_on'] = FALSE;
$db['fbird']['cachedir'] = "";
$db['fbird']['char_set'] = "utf8";
$db['fbird']['dbcollat'] = "utf8_general_ci";
并且还从php.ini 文件中删除了以下行中的;:
extension=php_pdo_firebird.dll
extension=php_interbase.dll
如果我现在刷新页面,我收到的错误是:
无法使用提供的设置连接到您的数据库服务器。
文件名:C:\xampp\htdocs\projtesting\system\database\DB_driver.php
行号:124
为了查看数据库中的凭据是否正常,我在软件SQL Manager 2008 Lite for Interbase and Firebird 上打开它,一切正常。
对出了什么问题有任何想法吗?
【问题讨论】:
-
That usually means that the table 'categories' doesn't exists..which isn't true.充其量只是一个理论。不管怎样,试试看print_r($db->get('categories'));为你带来了什么。 -
另外,在 Firebird 中,表在引用时区分大小写,我不知道 codeigniter,但它可能会引用表名。您可能想改用
CATEGORIES。
标签: php codeigniter firebird