Prev | Current Page 84 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

To retrieve the object at a different place in the code, Zend_Registry::get() is used,
where you supply the key name and a reference to the object is returned. There is also a helper function
Zend_Registry::isRegistered() which enables you to check if a given object key is registered or now.
As a word of warning, the registry is very similar to using a global variable and so unwanted coupling
between the registered objects and the rest of the code can occur if we are not careful. Zend_Registry should
therefore be used with caution. We will use it with confidence for two object: $config and $db. These two
objects are ideal for storing to a registry as they are generally only read from and not written to and so we can
be confident that they are unlikely to change during the course of the request. Hence, even though the data is in
the registry, we will still pass the relevant configuration data around our application when appropriate if it
minimizes coupling or a given section easier to test.
3.2.5 Database initialization
The configuration file contains all the information we need to initialize the database. As we discussed in
Chapter two, we use the Zend_Db factory class to create a Zend_Db_Adapter specific to our database. In this
case, we??™ll receive an object of type Zend_Db_Adapter_Pdo_Mysql.


Pages:
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
Wczasy nad morzem buchsbaum loans with no credit check Fundusze Emerytalne Biuro księgowe Lublin