Chapter 1: Introduction 16 implementing all the mapping on your own (because at the time of this writing we are not aware of any powerful ORM tools for PHP that are not based on an ActiveRecord approach). (1) Note that complexity != size. A domain model can be pretty large without being complex and vice versa. Obviously, larger domain models have a greater probability of being complex. Now you already know a lot about what Doctrine is and what it is not. If you would like to dive in now and get started right away, jump straight to the next chapter "Getting Started". Listing 1-1 Key Concepts The Doctrine Query Language (DQL) is an object query language. It let's you express queries for single objects or full object graphs, using the terminology of your domain model: class names, field names, relations between classes, etc. This is a powerful tool for retrieving or even manipulating objects without breaking the separation of the domain model (field names, class names, etc) from the relational model (table names, column names, etc). DQL looks very much like SQL and this is intended because it makes it relatively easy to grasp for people knowing SQL. There are, however, a few very important differences you should always keep in mind: Take this example DQL query: FROM User u LEFT JOIN u.Phonenumbers where u.level > 1 The things to notice about this query: • We select from classes and not tables. We are selecting from the User class/model. • We join along associations (u.Phonenumbers) • We can reference fields (u.level) • There is no join condition (ON x.y = y.x). The associations between your classes and how these are expressed in the database are known to Doctrine (You need to make this mapping known to Doctrine, of course. How to do that is explained later in the Defining Models (page 53) chapter.). DQL expresses a query in the terms of your domain model (your classes, the attributes they have, the relations they have to other classes, etc.). It's very important that we speak about classes, fields and associations between classes here. User is not a table / table name . It may be that the name of the database table that the User class is mapped to is indeed named User but you should nevertheless adhere to this differentiation of terminology. This may sound nit picky since, due to the ActiveRecord approach, your relational model is often very similar to your domain model but it's really important. The column names are rarely the same as the field names and as soon as inheritance is involved, the relational model starts to diverge from the domain model. You can have a class User that is in fact mapped to several tables in the database. At this point it should be clear that talking about "selecting from the User table" is simply wrong then. And as Doctrine development continues there will be more features available that allow the two models to diverge even more. ----------------- Brought to you by
Chapter 1: Introduction 17 Further Reading For people new to object-relational mapping and (object-oriented) domain models we recommend the following literature: The books by Martin Fowler 5 cover a lot of the basic ORM terminology, the different approaches of modeling business logic and the patterns involved. Another good read is about Domain Driven Design 6 . Though serious Domain-Driven Design is currently not possible with Doctrine, this is an excellent resource for good domain modeling, especially in complex business domains, and the terminology around domain models that is pretty widespread nowadays is explained in depth (Entities, Value Objects, Repositories, etc). Conclusion Well, now that we have given a little educational reading about the methodologies and principals behind Doctrine we are pretty much ready to dive in to everything that is Doctrine. Lets dive in to setting up Doctrine in the Getting Started (page 18) chapter. 5. http://www.martinfowler.com/books.html 6. http://domaindrivendesign.org/books/#DDD ----------------- 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