5

I just started to learn about ZF and Firebird because of a project I am assigned to. I have been trying to make the connection between both for several days now, but I haven't succeed yet. I tried ZF with PDO_Mysql and it works just fine as it does Firebird connection with PHP (out of ZF), but when I try to make the connection with the Firebird adapter in ZF it keeps displaying all kinds of errors.

So, just to check. To make the connection in ZF with Firebird it should be done with the the adapter (Firebird.php) which I have configure in application.ini? I have something like this in the application.ini:

**resources.db.adapter = "Firebird"
resources.db.params.host = "localhost"
resources.db.params.dbname =  "C:/wamp/www/WebTH/application/data/THDATA.gdb"
resources.db.params.username = "sysdba"
resources.db.params.password = "masterkey"**

Resulting error: ...Firebird.php): failed to open stream: No such file or directory in ...\Loader.php

I have also seen that a function needs to be added in the Bootstrap.php. If I add the function initDb in the bootstrap.php like this:

 **protected function _initDb()
{
    $this->bootstrap('config');
    $config = $this->getResource('config');
    $db = Zend_Db::factory('Firebird', array(
        'host' => $config->Database->Server,
        'username' => $config->Database->Username,
        'password' => $config->Database->Password,
        'dbname' => $config->Database->DBName,
        'adapterNamespace' => 'ZendX_Db_Adapter'
    ));
    return $db;
}**

I get the error: ...Uncaught exception 'Zend_Application_Bootstrap_Exception' with message 'Resource matching "config" not found' in ...\BootstrapAbstract.php

I would like to know what do I really need to do in order to make the connection work. Sorry if this is too obvious, but I haven't been able to find a basic connection case specific for Zend Framework and Firebird, therefore I am not really sure on what I should do and where I should go.

numaroth
  • 1,187
  • 3
  • 22
  • 35
Clarissa
  • 115
  • 1
  • 9
  • Yes, thanks for the advice. I was using the site for the first when I asked the question, so no idea on how it worked. I know now ;) – Clarissa Feb 05 '13 at 08:25

1 Answers1

5

[Disclosure: I've never used the Firebird db.]

As you are probably aware, the Firebird adapter does not ship as part of the core ZF1 package. Looks like you can pull it from extras under the ZendX prefix:

http://framework.zend.com/svn/framework/extras/trunk/library/ZendX/Db/Adapter/

Drop the Firebird.php and Firebird/ files into a directory library/ZendX/Db/Adapter/.

If your application.ini uses the resources.db.* keys, then there is no need for an _initDb() method in your Bootstrap class. Just make sure that you include the adapterNamespace key in there, as well:

resources.db.params.adapterNamespace = "ZendX_Db_Adapter_"

You might also need to add the ZendX prefix to your autoloader namespaces:

autoloaderNamespaces[] = "ZendX_"

Not tested, but something like this should work.

David Weinraub
  • 14,037
  • 4
  • 36
  • 63
  • Ok, Now it seems to work. I added the resources.db.params.adapterNamespace = "ZendX_Db_Adapter_" – Clarissa Jan 03 '13 at 13:21
  • Ok, Now it seems to work. I added the resources.db.params.adapterNamespace = "ZendX_Db_Adapter_" but it still gave the "No such file or directory" error, so what I did is to put two copies of the same folder in Zend/library> Zend and ZendX. It seems a bit messy but now it is working... Thanks!!! – Clarissa Jan 03 '13 at 13:28
  • The essence is that the `ZendX` directory has to be in your `include_path` and typically, the `library` folder is one of the `include_path` components. Glad it worked out for you. Cheers! ;-) – David Weinraub Jan 03 '13 at 15:46