Chapter 11: Native SQL 194 Listing 11-8 // test.php // ... $users = $q->execute(); echo get_class($users) . "\n"; echo get_class($users[0]) . "\n"; echo get_class($users[0]['Phonenumbers'][0]) . "\n"; The above example would output the following when executed: Listing 11-9 $ php test.php Doctrine_Collection User Phonenumber Conclusion This chapter may or may not be useful for you right now. In most cases the Doctrine Query Language is plenty sufficient for retrieving the complex data sets you require. But if you require something outside the scope of what Doctrine_Query is capable of then Doctrine_RawSql can help you. In the previous chapters you've seen a lot of mention about YAML schema files and have been given examples of schema files but haven't really been trained on how to write your own. The next chapter explains in great detail how to maintain your models as YAML Schema Files (page 195). ----------------- Brought to you by
Chapter 12: YAML Schema Files 195 Chapter 12 YAML Schema Files Introduction The purpose of schema files is to allow you to manage your model definitions directly from a YAML file rather then editing php code. The YAML schema file is parsed and used to generate all your model definitions/classes. This makes Doctrine model definitions much more portable. Schema files support all the normal things you would write with manual php code. Component to connection binding, relationships, attributes, templates/behaviors, indexes, etc. Abbreviated Syntax Doctrine offers the ability to specify schema in an abbreviated syntax. A lot of the schema parameters have values they default to, this allows us to abbreviate the syntax and let Doctrine just use its defaults. Below is an example of schema taking advantage of all the abbreviations. The detect_relations option will attempt to guess relationships based on column names. In the example below Doctrine knows that User has one Contact and will automatically define the relationship between the models. --- detect_relations: true Listing 12-1 User: columns: username: string password: string contact_id: integer Contact: columns: first_name: string last_name: string phone: string email: string address: string ----------------- Brought to you by
Doctrine ORM for PHP Guide to Doctr
Table of Contents iii Examples ....
Table of Contents v Sample Queries
Table of Contents vii Component Que
Table of Contents ix Inserting a No
Table of Contents xi Generating Mig
Chapter 1: Introduction 13 Chapter
Chapter 1: Introduction 15 layer de
Chapter 1: Introduction 17 Further
Chapter 2: Getting Started 19 Insta
Chapter 2: Getting Started 21 Downl
Chapter 2: Getting Started 23 In th
Chapter 3: Introduction to Connecti
Chapter 3: Introduction to Connecti
Chapter 3: Introduction to Connecti
Chapter 4: Configuration 31 $table-
Chapter 4: Configuration 33 backtic
Chapter 4: Configuration 35 class M
Chapter 4: Configuration 37 // boot
Chapter 5: Connections 39 Chapter 5
Chapter 5: Connections 41 $conn = D
Chapter 5: Connections 43 This is p
Chapter 6: Introduction to Models 4
Chapter 6: Introduction to Models 4
Chapter 6: Introduction to Models 4
Chapter 6: Introduction to Models 5
Chapter 7: Defining Models 53 Chapt
Chapter 7: Defining Models 55 } } /
Chapter 7: Defining Models 57 class
Chapter 7: Defining Models 59 Strin
Chapter 7: Defining Models 61 class
Chapter 7: Defining Models 63 class
Chapter 7: Defining Models 65 $this
Chapter 7: Defining Models 67 onUpd
Chapter 7: Defining Models 69 // te
Chapter 7: Defining Models 71 First
Chapter 7: Defining Models 73 } } $
Chapter 7: Defining Models 75 In ma
Chapter 7: Defining Models 77 Here
Chapter 7: Defining Models 79 class
Chapter 7: Defining Models 81 Here
Chapter 7: Defining Models 83 } } )
Chapter 7: Defining Models 85 --- #
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 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