Chapter 4: Configuration 36 For exporting tables only (but not constraints) you can use on of the following: Listing 4-24 // bootstrap.php // ... $manager->setAttribute(Doctrine_Core::ATTR_EXPORT, Doctrine_Core::EXPORT_TABLES); You can also use the following syntax as it is the same as the above: Listing 4-25 // bootstrap.php // ... $manager->setAttribute(Doctrine_Core::ATTR_EXPORT, Doctrine_Core::EXPORT_ALL ^ Doctrine_Core::EXPORT_CONSTRAINTS); For exporting everything (tables and constraints) you can use: Listing 4-26 // bootstrap.php // ... $manager->setAttribute(Doctrine_Core::ATTR_EXPORT, Doctrine_Core::EXPORT_ALL); Naming convention attributes Naming convention attributes affect the naming of different database related elements such as tables, indexes and sequences. Basically every naming convention attribute has affect in both ways. When importing schemas from the database to classes and when exporting classes into database tables. So for example by default Doctrine naming convention for indexes is %s_idx. Not only do the indexes you set get a special suffix, also the imported classes get their indexes mapped to their non-suffixed equivalents. This applies to all naming convention attributes. Index name format Doctrine_Core::ATTR_IDXNAME_FORMAT can be used for changing the naming convention of indexes. By default Doctrine uses the format [name]_idx. So defining an index called 'ageindex' will actually be converted into 'ageindex_idx'. You can change the index naming convention with the following code: Listing 4-27 // bootstrap.php // ... $manager->setAttribute(Doctrine_Core::ATTR_IDXNAME_FORMAT, '%s_index'); Sequence name format Similar to Doctrine_Core::ATTR_IDXNAME_FORMAT, Doctrine_Core::ATTR_SEQNAME_FORMAT can be used for changing the naming convention of sequences. By default Doctrine uses the format [name]_seq, hence creating a new sequence with the name of mysequence will lead into creation of sequence called mysequence_seq. You can change the sequence naming convention with the following code: ----------------- Brought to you by
Chapter 4: Configuration 37 // bootstrap.php Listing 4-28 // ... $manager->setAttribute(Doctrine_Core::ATTR_SEQNAME_FORMAT, '%s_sequence'); Table name format The table name format can be changed the same as the index and sequence name format with the following code: // bootstrap.php Listing 4-29 // ... $manager->setAttribute(Doctrine_Core::ATTR_TBLNAME_FORMAT, '%s_table'); Database name format The database name format can be changed the same as the index, sequence and table name format with the following code: // bootstrap.php Listing 4-30 // ... $manager->setAttribute(Doctrine_Core::ATTR_DBNAME_FORMAT, 'myframework_%s'); Validation attributes Doctrine provides complete control over what it validates. The validation procedure can be controlled with Doctrine_Core::ATTR_VALIDATE. The validation modes are bitwised, so they can be combined using | and removed using ^. See the examples section below on how to do this. Validation mode constants Name VALIDATE_NONE VALIDATE_LENGTHS VALIDATE_TYPES Description Turns off the whole validation procedure. Makes Doctrine validate all field lengths. Makes Doctrine validate all field types. Doctrine does loose type validation. This means that for example string with value '13.3' will not pass as an integer but '13' will. VALIDATE_CONSTRAINTS Makes Doctrine validate all field constraints such as notnull, email etc. VALIDATE_ALL Turns on all validations. Validation by default is turned off so if you wish for your data to be validated you will need to enable it. Some examples of how to change this configuration are provided below. ----------------- Brought to you by
Chapter 7: Defining Models 87 } { }
Chapter 7: Defining Models 89 } } )
Chapter 7: Defining Models 91 Some
Chapter 7: Defining Models 93 Now w
Chapter 7: Defining Models 95 # ...
Chapter 7: Defining Models 97 Concl
Chapter 8: Working with Models 99 $
Chapter 8: Working with Models 101
Chapter 8: Working with Models 103
Chapter 8: Working with Models 105
Chapter 8: Working with Models 107
Chapter 8: Working with Models 109
Chapter 8: Working with Models 111
Chapter 8: Working with Models 113
Chapter 8: Working with Models 115
Chapter 8: Working with Models 117
Chapter 8: Working with Models 119
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 9: DQL (Doctrine Query Lang
Chapter 10: Component Overview 163
Chapter 10: Component Overview 165
Chapter 10: Component Overview 167
Chapter 10: Component Overview 169
Chapter 10: Component Overview 171
Chapter 10: Component Overview 173
Chapter 10: Component Overview 175
Chapter 10: Component Overview 177
Chapter 10: Component Overview 179
Chapter 10: Component Overview 181
Chapter 10: Component Overview 183
Chapter 10: Component Overview 185
Chapter 10: Component Overview 187
Chapter 10: Component Overview 189
Chapter 10: Component Overview 191
Chapter 11: Native SQL 193 $users =
Chapter 12: YAML Schema Files 195 C
Chapter 12: YAML Schema Files 197 D
Chapter 12: YAML Schema Files 199 p
Chapter 12: YAML Schema Files 201 -
Chapter 12: YAML Schema Files 203 O
Chapter 12: YAML Schema Files 205 C
Chapter 12: YAML Schema Files 207 o
Chapter 13: Data Validation 209 Cha
Chapter 13: Data Validation 211 # .
Chapter 13: Data Validation 213 The
Chapter 13: Data Validation 215 if
Chapter 13: Data Validation 217 Her
Chapter 13: Data Validation 219 # .
Chapter 13: Data Validation 221 } e
Chapter 13: Data Validation 223 } }
Chapter 13: Data Validation 225 //
Chapter 14: Data Hydrators 227 Chap
Chapter 14: Data Hydrators 229 echo
Chapter 15: Inheritance 231 Chapter
Chapter 15: Inheritance 233 columns
Chapter 15: Inheritance 235 name: s
Chapter 15: Inheritance 237 // test
Chapter 16: Behaviors 239 Chapter 1
Chapter 16: Behaviors 241 Here is t
Chapter 16: Behaviors 243 } $this->
Chapter 16: Behaviors 245 The imple
Chapter 16: Behaviors 247 } } ); )
Chapter 16: Behaviors 249 $blogPost
Chapter 16: Behaviors 251 Look how
Chapter 16: Behaviors 253 length 25
Chapter 16: Behaviors 255 $ php tes
Chapter 16: Behaviors 257 Searchabl
Chapter 16: Behaviors 259 // test.p
Chapter 16: Behaviors 261 } } elsei
Chapter 16: Behaviors 263 ) [name]
Chapter 16: Behaviors 265 } public
Chapter 17: Searching 267 Chapter 1
Chapter 17: Searching 269 body LONG
Chapter 17: Searching 271 • Strip
Chapter 17: Searching 273 $ php tes
Chapter 17: Searching 275 // test.p
Chapter 18: Hierarchical Data 277 N
Chapter 18: Hierarchical Data 279 i
Chapter 18: Hierarchical Data 281 E
Chapter 18: Hierarchical Data 283 F
Chapter 19: Data Fixtures 285 Chapt
Chapter 19: Data Fixtures 287 class
Chapter 19: Data Fixtures 289 Resou
Chapter 19: Data Fixtures 291 --- #
Chapter 20: Database Abstraction La
Chapter 20: Database Abstraction La
Chapter 20: Database Abstraction La
Chapter 20: Database Abstraction La
Chapter 20: Database Abstraction La
Chapter 20: Database Abstraction La
Chapter 21: Transactions 305 log 43
Chapter 21: Transactions 307 try {
Chapter 22: Event Listeners 309 Cha
Chapter 22: Event Listeners 311 pub
Chapter 22: Event Listeners 313 pos
Chapter 22: Event Listeners 315 } {
Chapter 22: Event Listeners 317 */
Chapter 22: Event Listeners 319 FRO
Chapter 22: Event Listeners 321 Ski
Chapter 23: Caching 323 $cacheDrive
Chapter 23: Caching 325 // bootstra
Chapter 24: Migrations 327 Chapter
Chapter 24: Migrations 329 array('t
Chapter 24: Migrations 331 { } // .
Chapter 24: Migrations 333 $options
Chapter 24: Migrations 335 Up/Down
Chapter 24: Migrations 337 Now you
Chapter 25: Extensions 339 $ cd /pa
Chapter 26: Utilities 341 $pager->g
Chapter 26: Utilities 343 Currently
Chapter 26: Utilities 345 Template
Chapter 26: Utilities 347 Doctrine_
Chapter 26: Utilities 349 // Possib
Chapter 26: Utilities 351 // Genera
Chapter 26: Utilities 353 You can r
Chapter 26: Utilities 355 The above
Chapter 27: Unit Testing 357 $ cd /
Chapter 27: Unit Testing 359 } // .
Chapter 27: Unit Testing 361 Common
Chapter 28: Improving Performance 3
Chapter 28: Improving Performance 3
Chapter 28: Improving Performance 3
Chapter 29: Technology 369 Doctrine
Chapter 29: Technology 371 • Neve
Chapter 30: Exceptions and Warnings
Chapter 31: Real World Examples 375
Chapter 31: Real World Examples 377
Chapter 31: Real World Examples 379
Chapter 32: Coding Standards 381 Ch
Chapter 32: Coding Standards 383 Fu
Chapter 32: Coding Standards 385 $s
Chapter 32: Coding Standards 387 Fu