Doctrine ORM for PHP
Total Page:16
File Type:pdf, Size:1020Kb
Doctrine ORM for PHP Guide to Doctrine for PHP Doctrine 1.1 License: Creative Commons Attribution-Share Alike 3.0 Unported License Version: manual-1.1-en-2009-11-26 Table of Contents ii Table of Contents Introduction .................................................................................................... 13 Code Examples ........................................................................................................ 13 What is Doctrine? .................................................................................................... 13 What is an ORM? ..................................................................................................... 13 What is the Problem?............................................................................................... 13 Minimum Requirements .......................................................................................... 14 Basic Overview ........................................................................................................ 14 Doctrine Explained .................................................................................................. 15 Key Concepts ........................................................................................................... 16 Further Reading ...................................................................................................... 17 Conclusion ............................................................................................................... 17 Getting Started ............................................................................................... 18 Checking Requirements........................................................................................... 18 Installing.................................................................................................................. 19 Sandbox .............................................................................................................................. 19 SVN..................................................................................................................................... 19 Installing......................................................................................................................................... 19 Updating ......................................................................................................................................... 20 SVN Externals .................................................................................................................... 20 PEAR Installer .................................................................................................................... 20 Download Pear Package ..................................................................................................... 21 Implementing........................................................................................................... 21 Including Doctrine Libraries .............................................................................................. 21 Require Doctrine Base Class .............................................................................................. 21 Register Autoloader............................................................................................................ 22 Autoloading Explained.................................................................................................................... 22 Bootstrap File ..................................................................................................................... 23 Test Script .......................................................................................................................... 23 Conclusion ............................................................................................................... 24 Introduction to Connections........................................................................... 25 DSN, the Data Source Name ................................................................................... 25 Examples ............................................................................................................................ 27 Opening New Connections ...................................................................................... 27 Lazy Database Connecting ...................................................................................... 28 Testing your Connection.......................................................................................... 28 Conclusion ............................................................................................................... 29 Configuration .................................................................................................. 30 Levels of Configuration............................................................................................ 30 Defaults Attributes................................................................................................... 31 Default Column Options ..................................................................................................... 31 ----------------- Brought to you by Table of Contents iii Default Added Auto Id ........................................................................................................ 31 Portability ................................................................................................................ 31 Portability Mode Attributes................................................................................................ 32 Examples ............................................................................................................................ 32 Identifier quoting..................................................................................................... 33 Exporting ................................................................................................................. 34 Naming convention attributes ................................................................................. 34 Index name format ............................................................................................................. 34 Sequence name format....................................................................................................... 35 Table name format ............................................................................................................. 35 Database name format ....................................................................................................... 35 Validation attributes........................................................................................................... 35 Validation mode constants ................................................................................................. 35 Examples ............................................................................................................................ 36 Optional String Syntax ............................................................................................ 36 Conclusion ............................................................................................................... 36 Connections .................................................................................................... 38 Introduction ............................................................................................................. 38 Opening Connections............................................................................................... 38 Retrieve Connections............................................................................................... 38 Current Connection ................................................................................................. 39 Change Current Connection .................................................................................... 39 Iterating Connections .............................................................................................. 39 Get Connection Name.............................................................................................. 39 Close Connection ..................................................................................................... 40 Get All Connections ................................................................................................. 40 Count Connections................................................................................................... 41 Creating and Dropping Database ............................................................................ 41 Conclusion ............................................................................................................... 41 Introduction to Models ................................................................................... 43 Introduction ............................................................................................................. 43 Generating Models .................................................................................................. 43 Existing Databases ............................................................................................................. 44 Making the first import................................................................................................................... 44 Schema Files .....................................................................................................................