Development

Changeset 11714

You must first sign up to be able to contribute.

Changeset 11714

Show
Ignore:
Timestamp:
09/22/08 03:58:26 (2 months ago)
Author:
Jonathan.Wage
Message:

[1.2] Updates to doctrine book

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • doc/branches/1.2/doctrine_book/en/02-Connections.txt

    r11662 r11714  
    11Chapter 2 - Connections 
    22======================= 
     3 
     4## Introduction 
    35 
    46In 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. 
     
    4042          dsn:          driver://username:password@host/database_name 
    4143 
    42 ## PDO Style 
     44### PDO Style 
    4345 
    4446You may alternatively specify your DSN information in the PDO style syntax. 
  • doc/branches/1.2/doctrine_book/en/03-Configuration.txt

    r11662 r11714  
    88In 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. 
    99 
    10 ### Global Attributes 
     10### Global 
    1111 
    1212    [php] 
     
    1717    } 
    1818 
    19 ### Connection Attributes 
     19### Connection 
    2020 
    2121    [php] 
     
    2626    } 
    2727 
    28 ### Model Attributes 
     28### Model 
    2929 
    3030The 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  
    44In 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. 
    55 
    6 # Columns 
    7  
    8 ## Data Types 
     6## Columns 
     7 
     8### Data Types 
    99 
    1010Doctrine 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. 
     
    5252        html_header: gzip 
    5353 
    54 # Table Options 
     54## Options 
    5555 
    5656Often 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. 
     
    6565        password: string(255) 
    6666 
    67 # Indexes 
     67## Indexes 
    6868 
    6969You 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. 
     
    9090>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. 
    9191 
    92 # Relationships 
     92## Relationships 
    9393 
    9494Doctrine 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. 
    9595 
    96 ## One to One 
     96### One to One 
    9797 
    9898Here is a simple example of how to define a one-to-one relation between a User and Profile model. 
     
    116116          email: true 
    117117 
    118 ## One to Many 
     118### One to Many 
    119119 
    120120Here is a simple example of how to define a one-to-many relation between a User and Phonenumber model. 
     
    136136          foreignType: many 
    137137 
    138 ## Many to Many 
     138### Many to Many 
    139139 
    140140Here is a smiple example of how to define a many-to-many relation between a BlogPost and Tag model. 
     
    162162        Tag: 
    163163 
    164 # Cascading Operations 
     164## Cascading Operations 
    165165 
    166166When 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. 
    167167 
    168 ## Application Level 
     168### Application Level 
    169169 
    170170Unlike the save() operations the delete() cascading needs to be turned on explicitly. Here is an example: 
     
    194194          foreignType: many 
    195195 
    196 ## Database Level 
     196### Database Level 
    197197 
    198198Doctrine 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. 
     
    215215          onDelete: CASCADE 
    216216 
    217 # Behaviors 
     217## Behaviors 
    218218 
    219219One 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 
    220222 
    221223Here is a list of behavior bundled with Doctrine core. You can use any of the behaviors in your models without writing any code. 
     
    243245The 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. 
    244246 
    245 # Inheritance 
     247## Inheritance 
    246248 
    247249Another 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. 
    248250 
    249 ## Concrete Inheritance 
     251### Concrete Inheritance 
    250252 
    251253Concrete inheritance creates separate tables for child classes. However in concrete inheritance each class generates a table which contains all columns, including inherited columns. 
     
    262264        content: string(300) 
    263265 
    264 ## Simple Inheritance 
     266### Simple Inheritance 
    265267 
    266268Simple inheritance is the simpliest inheritance. In simple inheritance all the child classes share the same columns as the parent. 
     
    283285        type: simple 
    284286 
    285 ## Column Aggregation Inheritance 
     287### Column Aggregation Inheritance 
    286288 
    287289In the following example we have one database table called entity. Users and groups are both entities and they share the same database table. 
     
    306308        type: column_aggregation 
    307309 
    308 # Global Schema Information 
     310## Global Schema Information 
    309311 
    310312Doctrine 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  
    11Chapter 5 - Data Fixtures 
    22========================= 
     3 
     4## Introduction 
    35 
    46Doctrine 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  
    22================================ 
    33 
    4 # Retrieving Data 
     4## Retrieving Data 
    55 
    66The 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. 
    77 
    8 ## DQL 
     8### DQL 
    99 
    1010Doctrine 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. 
    1111 
    12 ### Query API 
     12#### Query API 
    1313 
    1414**Common API** 
     
    5353  * delete() 
    5454 
    55 ### Create New Query 
     55#### Create New Query 
    5656 
    5757Create new query from Doctrine_Table instance. 
     
    6868      ->where('u.username = ?', 'jwage'); 
    6969 
    70 ### Example Queries 
     70#### Example Queries 
    7171 
    7272Below you will find a few example queries which you can learn from and see how to retrieve result sets in Doctrine. 
     
    293293    $user = $q->execute()->getFirst(); 
    294294 
    295 ## Finders 
     295### Finders 
    296296 
    297297Doctrine 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. 
     
    313313    $userGroup = Doctrine::getTable('UserGroup')->find(array(1, 2)); 
    314314 
    315 # Altering Data 
     315## Altering Data 
    316316 
    317317With 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. 
    318318 
    319 ## Object Properties 
     319### Object Properties 
    320320 
    321321Doctrine 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. 
     
    329329    $user->save(); 
    330330 
    331 ## Overriding Accessors and Mutators 
     331### Overriding Accessors and Mutators 
    332332 
    333333    [php] 
     
    350350    echo $user->username; // Invokes getPassword() and returns PREFIX_jwage 
    351351 
    352 # Deleting Data 
     352## Deleting Data 
    353353 
    354354You 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  
    66sfDoctrinePlugin 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. 
    77 
    8 **Available Migration Tasks** 
     8## Available Migration Tasks 
    99 
    1010    :generate-migration          Generate migration class (doctrine-generate-migration) 
     
    1414 
    1515The 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 
    1618 
    1719**project/config/doctrine/schema.yml** 
     
    5961        name: ORM 
    6062 
    61 # Generating Migrations 
     63## Generating Migrations 
    6264 
    63 ## From Database 
     65Doctrine 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 
    6468 
    6569If you have an existing database you can build a set of migration classes that will re-create your database by running the following command. 
     
    6872    >> doctrine  Generated migration classes successfully from database 
    6973 
    70 ## From Models 
     74### From Models 
    7175 
    7276If 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. 
     
    8589    >> doctrine  Data was successfully loaded 
    8690 
    87 ## Skeleton 
     91### Skeleton 
    8892 
    8993Now 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 Crud 
     1Chapter 8 - Admin Generator and Crud 
    22==================================== 
     3 
     4Coming soon... 
  • doc/branches/1.2/doctrine_book/en/09-Forms.txt

    r11615 r11714  
    1 Chapter 8 - Forms 
     1Chapter 9 - Forms 
    22================= 
     3 
     4Coming soon... 
  • doc/branches/1.2/doctrine_book/en/10-Routing.txt

    r11615 r11714  
    1 Chapter 9 - Routing 
     1Chapter 10 - Routing 
    22=================== 
     3 
     4Coming soon...