10.04.2018 Views

Doctrine_manual-1-2-en

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 29: Technology 370<br />

• State 57 , for state-wise connections<br />

• Strategy 58 , for algorithm strategies<br />

Enterprise application design patterns used:<br />

• Active Record 59 , <strong>Doctrine</strong> is an implem<strong>en</strong>tation of this pattern<br />

• UnitOfWork 60 , for maintaining a list of objects affected in a transaction<br />

• Id<strong>en</strong>tity Field 61 , for maintaining the id<strong>en</strong>tity betwe<strong>en</strong> record and database row<br />

• Metadata Mapping 62 , for <strong>Doctrine</strong> DataDict<br />

• Dep<strong>en</strong>d<strong>en</strong>t Mapping 63 , for mapping in g<strong>en</strong>eral, since all records ext<strong>en</strong>d<br />

<strong>Doctrine</strong>_Record which performs all mappings<br />

• Foreign Key Mapping 64 , for one-to-one, one-to-many and many-to-one relationships<br />

• Association Table Mapping 65 , for association table mapping (most commonly manyto-many<br />

relationships)<br />

• Lazy Load 66 , for lazy loading of objects and object properties<br />

• Query Object 67 , DQL API is actually an ext<strong>en</strong>sion to the basic idea of Query Object<br />

pattern<br />

Speed<br />

• Lazy initialization - For collection elem<strong>en</strong>ts<br />

• Subselect fetching - <strong>Doctrine</strong> knows how to fetch collections effici<strong>en</strong>tly using a<br />

subselect.<br />

• Executing SQL statem<strong>en</strong>ts later, wh<strong>en</strong> needed : The connection never issues an<br />

INSERT or UPDATE until it is actually needed. So if an exception occurs and you<br />

need to abort the transaction, some statem<strong>en</strong>ts will never actually be issued.<br />

Furthermore, this keeps lock times in the database as short as possible (from the<br />

late UPDATE to the transaction <strong>en</strong>d).<br />

• Join fetching - <strong>Doctrine</strong> knows how to fetch complex object graphs using joins and<br />

subselects<br />

• Multiple collection fetching strategies - <strong>Doctrine</strong> has multiple collection<br />

fetching strategies for performance tuning.<br />

• Dynamic mixing of fetching strategies - Fetching strategies can be mixed and<br />

for example users can be fetched in a batch collection while users' phon<strong>en</strong>umbers<br />

are loaded in offset collection using only one query.<br />

• Driver specific optimizations - <strong>Doctrine</strong> knows things like bulk-insert on mysql.<br />

• Transactional single-shot delete - <strong>Doctrine</strong> knows how to gather all the primary<br />

keys of the p<strong>en</strong>ding objects in delete list and performs only one sql delete statem<strong>en</strong>t<br />

per table.<br />

• Updating only the modified columns. - <strong>Doctrine</strong> always knows which columns<br />

have be<strong>en</strong> changed.<br />

57. http://www.dofactory.com/Patterns/PatternState.aspx<br />

58. http://www.dofactory.com/Patterns/PatternStrategy.aspx<br />

59. http://www.martinfowler.com/eaaCatalog/activeRecord.html<br />

60. http://www.martinfowler.com/eaaCatalog/unitOfWork.html<br />

61. http://www.martinfowler.com/eaaCatalog/id<strong>en</strong>tityField.html<br />

62. http://www.martinfowler.com/eaaCatalog/metadataMapping.html<br />

63. http://www.martinfowler.com/eaaCatalog/dep<strong>en</strong>d<strong>en</strong>tMapping.html<br />

64. http://www.martinfowler.com/eaaCatalog/foreignKeyMapping.html<br />

65. http://www.martinfowler.com/eaaCatalog/associationTableMapping.html<br />

66. http://www.martinfowler.com/eaaCatalog/lazyLoad.html<br />

67. http://www.martinfowler.com/eaaCatalog/queryObject.html<br />

----------------- Brought to you by

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!