[英]Load Zend_Test_DbAdapter from Zend_Db::factory()
How can I obtain and instance of the Zend Framework Test DbAdapter using the Zend_Db::factory() ? 如何使用Zend_Db :: factory()获得Zend Framework Test DbAdapter的实例 ?
I have the following code but the Factory stamps on my adapter case and breaks the file path. 我有以下代码,但是Factory会在适配器盒上盖章并中断文件路径。 It seems a little ironic their test adapter can't be loaded by their own Factory.
讽刺的是他们的测试适配器无法由自己的工厂加载。 What am I doing wrong here?
我在这里做错了什么?
$config = new Zend_Config(
array(
'database' => array(
'adapter' => 'DbAdapter',
'params' => array(
'adapterNamespace' => 'Zend_Test',
'host' => 'localhost',
'dbname' => 'mydb',
'username' => 'not',
'password' => 'needed'
)
)
)
);
$db = Zend_Db::factory($config->database);
I get the following error: 我收到以下错误:
Zend_Loader::include_once(Zend/Test/Dbadapter.php): failed to open stream: No such file or directory
Updated 更新
The code above is a direct copy and paste, the adapter parameter case is correct: 'DbAdapter'. 上面的代码是直接复制和粘贴,适配器参数大小写正确:“ DbAdapter”。 This matches the file case Zend_Test_DbAdapter.
这与文件大小写Zend_Test_DbAdapter相匹配。
I changed my code to manually instantiate Zend_Test_DbAdapter
and it autoloads without issue. 我更改了代码以手动实例化
Zend_Test_DbAdapter
并且它自动加载而没有问题。
$db = new Zend_Test_DbAdapter;
print_r(get_class($db));
Output: 输出:
Zend_Test_DbAdapter
I still believe the Zend_Db::factory()
method is nerfing my adapter character case, upper casing the first character, lower casing the rest. 我仍然相信
Zend_Db::factory()
方法正在Zend_Db::factory()
我的适配器字符大小写,第一个字符用大写,其余的用小写。
Check Typo mistake 检查错别字
if not 'adapter' => 'Dbadapter', to 'adapter' => 'DbAdapter',
Zend/Test/Dbadapter.php does not exits
Zend/Test/DbAdapter.php exits in library
OR 要么
File is Missing 文件丢失
You have to add zend lib in includePath or if its a zend project add zend files into library 您必须在includePath中添加zend lib,或者如果它的zend项目将zend文件添加到库中
/application /library add Zend files (download from http://framework.zend.com/download ) / application / library添加Zend文件(从http://framework.zend.com/download下载)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.