Chapter 4: Configuration 30 Chapter 4 Configuration Doctrine controls configuration of features and functionality using attributes. In this section we will discuss how to set and get attributes as well as an overview of what attributes exist for you to use to control Doctrine functionality. Levels of Configuration Doctrine has a three-level configuration structure. You can set configuration attributes at a global, connection and table level. If the same attribute is set on both lower level and upper level, the uppermost attribute will always be used. So for example if a user first sets default fetchmode in global level to Doctrine_Core::FETCH_BATCH and then sets a table fetchmode to Doctrine_Core::FETCH_LAZY, the lazy fetching strategy will be used whenever the records of that table are being fetched. • Global level - The attributes set in global level will affect every connection and every table in each connection. • Connection level - The attributes set in connection level will take effect on each table in that connection. • Table level - The attributes set in table level will take effect only on that table. In the following example we set an attribute at the global level: Listing 4-1 // bootstrap.php // ... $manager->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL); In the next example above we override the global attribute on given connection: Listing 4-2 // bootstrap.php // ... $conn->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_NONE); In the last example we override once again the connection level attribute in the table level: Listing 4-3 // bootstrap.php // ... $table = Doctrine_Core::getTable('User'); ----------------- Brought to you by
Chapter 4: Configuration 31 $table->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL); We haven't introduced the above used Doctrine_Core::getTable() method. You will learn more about the table objects used in Doctrine in the Table (page 164) section of the next chapter. Portability Each database management system (DBMS) has it's own behaviors. For example, some databases capitalize field names in their output, some lowercase them, while others leave them alone. These quirks make it difficult to port your applications over to another database type. Doctrine strives to overcome these differences so your applications can switch between DBMS's without any changes. For example switching from sqlite to mysql. The portability modes are bitwised, so they can be combined using | and removed using ^. See the examples section below on how to do this. You can read more about the bitwise operators on the PHP website 20 . Portability Mode Attributes Below is a list of all the available portability attributes and the description of what each one does: Name PORTABILITY_ALL PORTABILITY_DELETE_COUNT PORTABILITY_EMPTY_TO_NULL PORTABILITY_ERRORS Description Turn on all portability features. This is the default setting. Force reporting the number of rows deleted. Some DBMS's don't count the number of rows deleted when performingsimple DELETE FROM tablename queries. This mode tricks such DBMS's into telling the count by adding WHERE 1=1 to the end of DELETE queries. Convert empty strings values to null in data in and output. Needed because Oracle considers empty strings to be null, while most other DBMS's know the difference between empty and null. Makes certain error messages in certain drivers compatible with those from other DBMS's PORTABILITY_FIX_ASSOC_FIELD_NAMES This removes any qualifiers from keys in associative fetches. Some RDBMS, like for example SQLite, will by default use the fully qualified name for a column in assoc fetches if it is qualified in a query. 20. http://www.php.net/language.operators.bitwise ----------------- Brought to you by
The comprehensive data will ensure that marketers can save on their marketing costs by using a single database for all their marketing purposes. With our Mailing Lists of Medical Associates you can expand your business, gain new customers, networking with associate medical directors, reduce sales cycle and improve sales, revenue and ROI.
Test4Direct provides latest PDF questions of IBM C2090-610 exam. You have an opportunity to pass the IBM C2090-610 exam in one go. Test4Direct is most accurate source to prepare IBM C2090-610 exam as your success will become site’s responsibility after purchasing C2090-610 exam product. There are also lots of discounts and promotion offers that you can avail. Let’s try a free demo http://www.test4direct.com/C2090-610.html