Development

Changeset 11662

You must first sign up to be able to contribute.

Changeset 11662

Show
Ignore:
Timestamp:
09/18/08 20:36:11 (2 months ago)
Author:
Jonathan.Wage
Message:

[1.2] Updates to match the recent 1.2 changes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • doc/branches/1.2/doctrine_book/en/01-Getting-Started.txt

    r11624 r11662  
    44>**NOTE** 
    55>The symfony and Doctrine book does not explain in detail everything about Doctrine. It briefly touches on a few critical subjects that symfony utilizes the most. The Doctrine manual is still the best source of documentation for referencing everything that is Doctrine. It is recommended you read this book to get started and then utilize the Doctrine manual for referencing the specifics of using Doctrine. You can find the main Doctrine documentation [here](http://www.doctrine-project.org/documentation "Doctrine Documentation"). 
     6 
     7## What is Doctrine? 
     8 
     9Doctrine is a PHP ORM (object relational mapper) for PHP 5.2.3+ that sits on top of a powerful PHP DBAL (database abstraction layer). One of its key features is the ability to optionally write database queries in an OO (object oriented) SQL-dialect called DQL inspired by Hibernates HQL. This provides developers with a powerful alternative to SQL that maintains a maximum of flexibility without requiring needless code duplication. 
     10 
     11## Enable Doctrine 
    612 
    713In order to begin using Doctrine you must first enable it in your application with the following command. It will automatically make some configuration changes and create directories that Doctrine require. 
     
    5359      :migrate                     Migrates database to current/specified version (doctrine-migrate) 
    5460      :rebuild-db                  Creates database for current model (doctrine-rebuild-db) 
    55  
    56 ## Import from Propel 
    57  
    58 Doctrine has the ability to generate schema files from existing databases so all you need to do is make your configured Doctrine database have the schema of the database you want to import in to Doctrine. Run the following command to generate your yaml schema files from the existing database. 
    59  
    60     $ ./symfony doctrine:build-schema frontend 
    61     >> doctrine  Generate YAML schema successfully from database 
    62  
    63 Now have a look in `config/doctrine/schema.yml` and you will see the yaml for the database. In this example we have a user table. 
    64  
    65     CREATE TABLE user (id BIGINT AUTO_INCREMENT, username VARCHAR(255), password VARCHAR(255), PRIMARY KEY(id)) ENGINE = INNODB; 
    66  
    67 The above mysql table would generate a yaml schema like the following in `config/doctrine/schema.yml` 
    68  
    69     --- 
    70     User: 
    71       tableName: user 
    72       columns: 
    73         id: 
    74           type: integer(8) 
    75           primary: true 
    76           autoincrement: true 
    77         username: string(255) 
    78         password: string(255) 
  • doc/branches/1.2/doctrine_book/en/02-Connections.txt

    r11624 r11662  
    11Chapter 2 - Connections 
    22======================= 
    3  
    4 >**TIP** 
    5 >More can be read about connections in the Doctrine Manual [here](http://www.doctrine-project.org/documentation/manual/1_0?chapter=connection-management). 
    63 
    74In 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. 
     
    4845 
    4946    all: 
    50       dictrube: 
     47      doctrine: 
    5148        class:          sfDoctrineDatabase 
    5249        param: 
     
    5754>**TIP** 
    5855>Using the PDO style syntax offers more flexibility and ability to specify non standard information about your connection to PDO. For example, when specifying non standard unix_socket paths or ports to use when connecting, specifying it in PDO syntax is more flexible. 
     56 
     57## Import from Propel 
     58 
     59Doctrine has the ability to generate schema files from existing databases so all you need to do is make your configured Doctrine database have the schema of the database you want to import in to Doctrine. Run the following command to generate your yaml schema files from the existing database. 
     60 
     61    $ ./symfony doctrine:build-schema frontend 
     62    >> doctrine  Generate YAML schema successfully from database 
     63 
     64Now have a look in `config/doctrine/schema.yml` and you will see the yaml for the database. In this example we have a user table. 
     65 
     66    CREATE TABLE user (id BIGINT AUTO_INCREMENT, username VARCHAR(255), password VARCHAR(255), PRIMARY KEY(id)) ENGINE = INNODB; 
     67 
     68The above mysql table would generate a yaml schema like the following in `config/doctrine/schema.yml` 
     69 
     70    --- 
     71    User: 
     72      tableName: user 
     73      columns: 
     74        id: 
     75          type: integer(8) 
     76          primary: true 
     77          autoincrement: true 
     78        username: string(255) 
     79        password: string(255) 
    5980 
    6081## Multiple Connections 
     
    97118>**Note** 
    98119>Because the tables are in separate databases the data can only be lazily loaded. Doctrine does not currently support generating sql for joining tables across databases. Also, notice the export attribute being set to tables. This tells Doctrine to only export the create table statement and not any foreign keys. 
     120 
     121## Connection Attributes 
     122 
     123sfDoctrinePlugin allows you to specify connection attributes directly in the `config/databases.yml` file like the following. 
     124 
     125    all: 
     126      doctrine: 
     127        class:          sfDoctrineDatabase 
     128        param: 
     129          dsn:          mysql://root@localhost/dbname 
     130          attributes: 
     131            use_dql_callbacks: true 
     132 
     133The attributes you specify here will be set on the Doctrine_Connection instances when the connection is created. 
    99134 
    100135## Build Everything 
  • doc/branches/1.2/doctrine_book/en/03-Configuration.txt

    r11624 r11662  
    11Chapter 3 - Configuration 
    22========================= 
    3  
    4 Doctrine controls most configuration from the `project/apps/frontend/config/doctrine.yml` which was copied for you with the `$ ./symfony doctrine:enable frontend` command. Below is the sample configuration that comes bundled with Doctrine. 
    5  
    6     all: 
    7       # all attributes below are set on the Doctrine_Manager instance 
    8       attributes: 
    9         # export sql (none, tables, constraints, all) 
    10         export:  all 
    11  
    12         # enable doctrine side validation (true, false) 
    13         validate: false 
    14      
    15         # recursive merge functions from different directories/plugins 
    16         recursive_merge_fixtures: true 
    17  
    18         # enable quoting 
    19         quote_identifier: false 
    20      
    21         # enable autoloading of table class 
    22         autoload_table_classes: true 
    23  
    24       listeners:        [] 
    25       record_listeners: [] 
    26  
    27     # Configuration for specific connection names  
    28     #  connections: 
    29     #    doctrine: 
    30     #      attributes: 
    31     #        export: all 
    32     #      listeners:        [] 
    33     #      record_listeners: [] 
    343 
    354## Attributes 
     
    376Doctrine controls features and settings with attributes. The attributes can be defined at different levels of a hierarchy. Some attributes can be specified at all levels and others cannot. Below explains how you can specify attributes at each level. Attributes can be specified globally, on each connection, or on each individual model. 
    387 
     8In 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 
    3910### Global Attributes 
    4011 
    41 You can specify global attributes by editing `project/apps/frontend/config/doctrine.yml`. 
    42  
    43     all: 
    44       attributes: 
    45         use_dql_callbacks: true # Enable DQL callbacks globally 
     12    [php] 
     13    public function configureDoctrine() 
     14    { 
     15      $manager = Doctrine_Manager::getInstance(); 
     16      $manager->setAttribute('use_dql_callbacks', true); 
     17    } 
    4618 
    4719### Connection Attributes 
    4820 
    49 You can specify connection attributes the same way you do global ones in `project/apps/frontend/config/doctrine.yml` with the following YAML. 
    50  
    51     all: 
    52       connections: 
    53         doctrine: 
    54           attributes: 
    55             export: tables          # Only export tables when creating database from models 
    56             use_dql_callbacks: true # Enable DQL callbacks on this connection 
     21    [php] 
     22    public function configureDoctrine() 
     23    { 
     24      $conn = Doctrine_Manager::getInstance()->getConnection('connection_name'); 
     25      $conn->setAttribute('use_dql_callbacks', true); 
     26    } 
    5727 
    5828### Model Attributes 
  • doc/branches/1.2/doctrine_book/en/07-Migrations.txt

    r11624 r11662  
    1 Chapter 6 - Migrations 
     1Chapter 7 - Migrations 
    22====================== 
    33