barretBSE (3) [Avatar] Offline
#1
Hi! I'm using Zend Framework 1.9.1 and this is my application.ini file section relative to db configuration:

[production]
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "test"
resources.db.params.password = "test"
resources.db.params.dbname = "test"
resources.db.isDefaultTableAdapter = true

My Bootstrap class is the same used in Rob's tutorial Getting Started with Zend Framework (revision 1.6.3)

Now I need an instance of the adapter to creating a Select object. Currently I'm using the following code:

$db = Zend_Db_Table::getDefaultAdapter();
$select = $db->select();

Is this the "right way" to retrieve an adapter instance or there is a better one?
Any help will be really appreciated. Thanks smilie
apprentice (77) [Avatar] Offline
#2
Re: How to retrieve the Zend_Db_Adapter instance?
Maybe this can help you I use the same environment like you.

[1.8] - How do you store $database object to the Zend_Registry? - [SOLVED]
http://www.manning-sandbox.com/thread.jspa?threadID=34637&tstart=0


Then for testing you can do something like this in a View page to fetch your $select object with some modifications. In a proper web application you should move this part of the code to the Controller instead. I think, I'm still a ZF newbie.

[pre]
$db = Zend_Registry::get('db');
Zend_Debug::dump($db);
[/pre]