Changeset 11714
- Timestamp:
- 09/22/08 03:58:26 (2 months ago)
- Files:
-
- doc/branches/1.2/doctrine_book/en/02-Connections.txt (modified) (2 diffs)
- doc/branches/1.2/doctrine_book/en/03-Configuration.txt (modified) (3 diffs)
- doc/branches/1.2/doctrine_book/en/04-Schema Files.txt (modified) (13 diffs)
- doc/branches/1.2/doctrine_book/en/05-Data-Fixtures.txt (modified) (1 diff)
- doc/branches/1.2/doctrine_book/en/06-Working-With-Data.txt (modified) (7 diffs)
- doc/branches/1.2/doctrine_book/en/07-Migrations.txt (modified) (5 diffs)
- doc/branches/1.2/doctrine_book/en/08-Admin-Generator-And-Crud.txt (modified) (1 diff)
- doc/branches/1.2/doctrine_book/en/09-Forms.txt (modified) (1 diff)
- doc/branches/1.2/doctrine_book/en/10-Routing.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
doc/branches/1.2/doctrine_book/en/02-Connections.txt
r11662 r11714 1 1 Chapter 2 - Connections 2 2 ======================= 3 4 ## Introduction 3 5 4 6 In this chapter we'll explain some things about Doctrine connections, how to configure them, how to use multiple of them and bind models to connections, how to create and drop your databases and other connection related activities. … … 40 42 dsn: driver://username:password@host/database_name 41 43 42 ## PDO Style44 ### PDO Style 43 45 44 46 You may alternatively specify your DSN information in the PDO style syntax. doc/branches/1.2/doctrine_book/en/03-Configuration.txt
r11662 r11714 8 8 In symfony you can control the Doctrine configuration in your `config/ProjectConfiguration.class.php` or `apps/frontend/config/frontendConfiguration.class.php` by creating a configureDoctrine() function. 9 9 10 ### Global Attributes10 ### Global 11 11 12 12 [php] … … 17 17 } 18 18 19 ### Connection Attributes19 ### Connection 20 20 21 21 [php] … … 26 26 } 27 27 28 ### Model Attributes28 ### Model 29 29 30 30 The last level of the hierarchy is for Doctrine models. The attributes can be specified directly in the YAML definition of the model. doc/branches/1.2/doctrine_book/en/04-Schema Files.txt
r11624 r11714 4 4 In the previous chapters you've seen some various syntaxes for specifying your schema information in YAML files placed in `config/doctrine/*.yml`. This chapter explains the syntaxes and how to specify all your schema meta data in schema files. 5 5 6 # Columns7 8 ## Data Types6 ## Columns 7 8 ### Data Types 9 9 10 10 Doctrine offers several column data types. When you specify the portable Doctrine type it is automatically converted to the appropriate type of the dbms you are using. below is a list of the available column types that can be used. … … 52 52 html_header: gzip 53 53 54 # TableOptions54 ## Options 55 55 56 56 Often you need to set options on your table for controlling things like charset, collation and table type in mysql. These can be controlled easily with options. … … 65 65 password: string(255) 66 66 67 # Indexes67 ## Indexes 68 68 69 69 You can optimize your database by defining indexes on columns which are used in conditions on your queries. Below is an example of indexing the username column of a user table since it is common to do lookups on the table by the users username. … … 90 90 >Indexes are automatically created on relationship foreign keys when the relationships are defined. The next section explains how to define relationships between foreign keys on your tables. 91 91 92 # Relationships92 ## Relationships 93 93 94 94 Doctrine offers the ability to map the relationships which exist in your database to the ORM so that it can be the most help when working with your data. 95 95 96 ## One to One96 ### One to One 97 97 98 98 Here is a simple example of how to define a one-to-one relation between a User and Profile model. … … 116 116 email: true 117 117 118 ## One to Many118 ### One to Many 119 119 120 120 Here is a simple example of how to define a one-to-many relation between a User and Phonenumber model. … … 136 136 foreignType: many 137 137 138 ## Many to Many138 ### Many to Many 139 139 140 140 Here is a smiple example of how to define a many-to-many relation between a BlogPost and Tag model. … … 162 162 Tag: 163 163 164 # Cascading Operations164 ## Cascading Operations 165 165 166 166 When saving objects in Doctrine it is cascaded to associated objects by default. Deleting is slightly different. Doctrine has the ability to do both application and database level cascading deletes. 167 167 168 ## Application Level168 ### Application Level 169 169 170 170 Unlike the save() operations the delete() cascading needs to be turned on explicitly. Here is an example: … … 194 194 foreignType: many 195 195 196 ## Database Level196 ### Database Level 197 197 198 198 Doctrine also has the ability to export cascading operations to the database level. Below is an example of how to setup a model with some cascading options. … … 215 215 onDelete: CASCADE 216 216 217 # Behaviors217 ## Behaviors 218 218 219 219 One great feature of Doctrine is the ability to have plug n' play behavior. These behaviors can be easily included in your model definitions and you inherit functionality automatically. 220 221 ### Core Behaviors 220 222 221 223 Here is a list of behavior bundled with Doctrine core. You can use any of the behaviors in your models without writing any code. … … 243 245 The above example will automatically add a slug column to the model and will set the value of the slug column based on the value of the title column and make sure the value is unique. If a slug already exists in the database with the same value then 1, 2, 3, etc. is appended to the end. 244 246 245 # Inheritance247 ## Inheritance 246 248 247 249 Another great feature of Doctrine is the ability to use native PHP oop inheritance with your models. It supports three different inheritance strategies which can be used independently or mixed together. Below are some examples of the different inheritance strategies. 248 250 249 ## Concrete Inheritance251 ### Concrete Inheritance 250 252 251 253 Concrete inheritance creates separate tables for child classes. However in concrete inheritance each class generates a table which contains all columns, including inherited columns. … … 262 264 content: string(300) 263 265 264 ## Simple Inheritance266 ### Simple Inheritance 265 267 266 268 Simple inheritance is the simpliest inheritance. In simple inheritance all the child classes share the same columns as the parent. … … 283 285 type: simple 284 286 285 ## Column Aggregation Inheritance287 ### Column Aggregation Inheritance 286 288 287 289 In the following example we have one database table called entity. Users and groups are both entities and they share the same database table. … … 306 308 type: column_aggregation 307 309 308 # Global Schema Information310 ## Global Schema Information 309 311 310 312 Doctrine schemas allow you to specify certain parameters that will apply to all of the models defined in the schema file. Below you can find an example on what global parameters you can set for schema files. doc/branches/1.2/doctrine_book/en/05-Data-Fixtures.txt
r11624 r11714 1 1 Chapter 5 - Data Fixtures 2 2 ========================= 3 4 ## Introduction 3 5 4 6 Doctrine offers the ability to load small sets of sample test data by using a simple YAML syntax for specifying data to be loaded in to your object relationship hierarchy. It supports easily creating information for your tables and linking foreign keys between records. doc/branches/1.2/doctrine_book/en/06-Working-With-Data.txt
r11624 r11714 2 2 ================================ 3 3 4 # Retrieving Data4 ## Retrieving Data 5 5 6 6 The recommended way to efficiently retrieve data in Doctrine is to use the Doctrine Query Language. It is the best way to retrieve all your data in the lowest amount of queries possible. For convenience when working with single tables we offer some simple finder methods as well. 7 7 8 ## DQL8 ### DQL 9 9 10 10 Doctrine uses DQL for retrieving data and offers a complete Doctrine_Query api for building your DQL queries. Below you'll find examples utilizing all the different api functions as well as a complete list of the functions that can be used. 11 11 12 ### Query API12 #### Query API 13 13 14 14 **Common API** … … 53 53 * delete() 54 54 55 ### Create New Query55 #### Create New Query 56 56 57 57 Create new query from Doctrine_Table instance. … … 68 68 ->where('u.username = ?', 'jwage'); 69 69 70 ### Example Queries70 #### Example Queries 71 71 72 72 Below you will find a few example queries which you can learn from and see how to retrieve result sets in Doctrine. … … 293 293 $user = $q->execute()->getFirst(); 294 294 295 ## Finders295 ### Finders 296 296 297 297 Doctrine offers some simple magic finder methods that automatically create Doctrine_Query objects in the background. Below are some examples of how you can utilize these methods. … … 313 313 $userGroup = Doctrine::getTable('UserGroup')->find(array(1, 2)); 314 314 315 # Altering Data315 ## Altering Data 316 316 317 317 With Doctrine you can alter data by issuing direct DQL update and delete queries or you can fetch objects, alter properties and save. Below we'll show examples of both strategies. 318 318 319 ## Object Properties319 ### Object Properties 320 320 321 321 Doctrine offers 3 ways to alter your object properties and sfDoctrinePlugin implements a fourth. They are object access, array access, function access and propel style access. … … 329 329 $user->save(); 330 330 331 ## Overriding Accessors and Mutators331 ### Overriding Accessors and Mutators 332 332 333 333 [php] … … 350 350 echo $user->username; // Invokes getPassword() and returns PREFIX_jwage 351 351 352 # Deleting Data352 ## Deleting Data 353 353 354 354 You have two options for deleting data. You can retrieve the object first and call the Doctrine_Record::delete() method or you can issue a single DQL delete query. doc/branches/1.2/doctrine_book/en/07-Migrations.txt
r11662 r11714 6 6 sfDoctrinePlugin implements some additional tasks for generating migration classes both from existing databases and models. You can also use Doctrine to generate your blank skeleton migration classes. 7 7 8 **Available Migration Tasks** 8 ## Available Migration Tasks 9 9 10 10 :generate-migration Generate migration class (doctrine-generate-migration) … … 14 14 15 15 The examples in this chapter assume you're working with the following schema and data fixtures. We'll use this as the base of all the examples documented here. 16 17 ## Starting Schema and Data Fixtures 16 18 17 19 **project/config/doctrine/schema.yml** … … 59 61 name: ORM 60 62 61 # Generating Migrations63 ## Generating Migrations 62 64 63 ## From Database 65 Doctrine offers the ability to generate sets of migration classes for existing databases or existing models as well as generating blank migration classes for you to fill in with the code to make your schema changes. 66 67 ### From Database 64 68 65 69 If you have an existing database you can build a set of migration classes that will re-create your database by running the following command. … … 68 72 >> doctrine Generated migration classes successfully from database 69 73 70 ## From Models74 ### From Models 71 75 72 76 If you have an existing set of models you can build a set of migration classes that will create your database by running the following command. … … 85 89 >> doctrine Data was successfully loaded 86 90 87 ## Skeleton91 ### Skeleton 88 92 89 93 Now that your database is all created and migrated to the latest version you can generate new migration class skeletons to migrate your schema as your model evolves. Imagine you have a new column you're adding to the BlogPost model named `excerpt`. Below is the updated BlogPost schema which includes the new column. doc/branches/1.2/doctrine_book/en/08-Admin-Generator-And-Crud.txt
r11615 r11714 1 Chapter 7- Admin Generator and Crud1 Chapter 8 - Admin Generator and Crud 2 2 ==================================== 3 4 Coming soon... doc/branches/1.2/doctrine_book/en/09-Forms.txt
r11615 r11714 1 Chapter 8- Forms1 Chapter 9 - Forms 2 2 ================= 3 4 Coming soon... doc/branches/1.2/doctrine_book/en/10-Routing.txt
r11615 r11714 1 Chapter 9- Routing1 Chapter 10 - Routing 2 2 =================== 3 4 Coming soon...