Codeigniter无法连接到firebird

时间:2014-12-16 18:27:13

标签: php codeigniter firebird

我已经看到并尝试了Codeigniter - multiple database connectionsYou have specified an invalid database connection group codeigniter errorfirebird - 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上打开了它,这没关系。 什么出错的想法?​​

1 个答案:

答案 0 :(得分:1)

解决方案:Codeigniter 3(dbdriver = ibase)

$db['firebird'] = array(
    'dsn'   => '',
    'hostname' => 'localhost',
    'username' => 'sysdba',
    'password' => 'masterkey',
    'database' => 'c:/database.GDB',
    'dbdriver' => 'ibase',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'ANSI',
    'dbcollat' => 'NONE',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);