in lessons similar to this http://akrabat.com/zend-framework-tutorial/, the database parameters for that application are saved within the
application.ini config file. Reading through with the paperwork for
zend_db along with other database interaction lessons, it indicates the database object is produced from parameters hard coded into php code. What is confusing is the fact that there does not seem to be any explicit initialisation from the database object in lessons like the one above. So my natural conclusion for this would be that the database object is instantly produced in the parameters provided within the
application.ini config file?
So my natural conclusion for this is the database object is instantly produced in the parameters provided within the application.ini config file?
Type of, actually, you will find a couple of step before your database get initialized.
- The application is bootstraped
- It reads the config file
- Whenever a resource.* is located, see if the according resource class is available
- The resource class initialize an item using the given parameter
- Zend_Db_Table includes a static method setDefaultAdapter($db) that takes the recently produced Zend_Db object, now every Zend_Db_table object may use the Db object you occur your configuration.
- Return the recently produced object
- Return to 3.
- Router, Controller, Layout, View, etc.
This "behavior" is recent, it's the reason why you may found some old tutorial which demonstrates how to bootstrap your Zend_Db object by hand, sometimes, it is simply to inform you how Zend_Db works.