I have a Zend_Framework application, which has a whole bunch of model classes.
I need these model classes to be able to access the application’s database (naturally).
Currently I’ve put this in my index.php:
Zend_Registry::set('db',
$application->bootstrap()->getBootstrap()
->getPluginResource('db')->getDbAdapter());
And then $db = Zend_Registry::get('db'); in each of my model classes that require the database.
But this seems like a horrible horrible hack. Am I missing something basic here?
Example of setting up SQLITE in your application.ini. You can also setup for MySQL or others.
Once the db is loaded into the application you may extend the Zend_Db_Table_Abstract
You can use the zend methods…
Or you can do straight sql…
All of this can be done in any model class that extends the Zend_Db_Table_Abstract