duanping2809 2014-12-16 18:27
浏览 60

Codeigniter无法连接到firebird

I have seen and tried all the solutions in Codeigniter - multiple database connections, You have specified an invalid database connection group codeigniter error, firebird - codeigniter connection and none of them worked.

$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";

After this configuration, I call the fbird database this way:

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();    
    }
}

And the error I get after trying output the values print_r($this->fb_model->getAll()); is:

Fatal error: Call to a member function result() on a non-object

That usually means that the table 'categories' doesn't exists..which isn't true.

So I have tried to change my configuration file into:

$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";

And also removed from the php.ini file the ; from the following lines:

extension=php_pdo_firebird.dll
extension=php_interbase.dll

And if I refresh the page now the error I receive is:

Unable to connect to your database server using the provided settings.

Filename: C:\xampp\htdocs\projtesting\system\database\DB_driver.php

Line Number: 124

In order to see if the credentials from the database were fine I opened it on the software SQL Manager 2008 Lite for Interbase and Firebird, and it was ok. Any ideas of what's going wrong?

  • 写回答

1条回答 默认 最新

  • dtnwm4807 2015-10-07 13:28
    关注

    Solution: 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
    );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测