开发者

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()?

I have the following code but the Factory stamps on my adapter case and breaks the file path. 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' => 'myd开发者_Go百科b',
                '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'. This matches the file case Zend_Test_DbAdapter.

I changed my code to manually instantiate Zend_Test_DbAdapter and it autoloads without issue.

$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.


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

/application /library add Zend files (download from http://framework.zend.com/download)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜