与Zend Framework中的Firebird适配器的数据库连接 [英] Database connection with Firebird Adapter in Zend Framework
问题描述
我刚开始了解ZF和Firebird,因为我分配了一个项目。我一直试图使两者之间的连接几天,但我还没有成功。
我尝试ZF与PDO_Mysql和它的工作正常,因为它与PHP(出ZF)的Firebird连接,但是当我尝试与ZF中的Firebird适配器连接时,它保持显示各种错误。 / p>
所以,只是检查。要使用Firebird连接ZF,应该使用我在application.ini中配置的适配器(Firebird.php)?我在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**
导致的错误: ... Firebird.php):无法打开流:没有这样的文件或目录... \Loader.php
我也看到一个函数需要在Bootstrap.php中添加。如果我在bootstrap.php中添加如下的函数initDb:
** 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;
} **
我收到错误: ...未捕获异常Zend_Application_Bootstrap_Exception,其中包含消息资源匹配confignot foundin ... \BootstrapAbstract.php
知道我真正需要做什么,以使连接工作。对不起,如果这是太明显,但我没有能够找到一个特定的Zend框架和Firebird的基本连接的情况,因此我不知道我应该做什么,我应该去。
[披露:我从未使用 Firebird db。]
您可能知道,Firebird适配器不作为核心ZF1软件包的一部分提供。看起来您可以从 ZendX
前缀下的 extras
中拉取
http://framework.zend.com/svn/framework / extras / trunk / library / ZendX / Db / Adapter /
删除 Firebird.php
和 Firebird /
文件导入目录 library / ZendX / Db / Adapter /
。
如果您的 application.ini
使用 resources.db。*
键,在 Bootstrap
类中不需要 _initDb()
方法。只要确保在其中包含 adapterNamespace
键即可:
.db.params.adapterNamespace =ZendX_Db_Adapter _
您可能还需要添加 ZendX
自动加载器命名空间的前缀:
autoloaderNamespaces [] =ZendX _
未测试,但这样的东西应该可以工作。
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.
[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.
这篇关于与Zend Framework中的Firebird适配器的数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!