Changeset 1584
- Timestamp:
- 07/06/06 12:54:28 (2 years ago)
- Files:
-
- trunk/doc/book/content/cli.txt (modified) (3 diffs)
- trunk/doc/book/content/configuration_practice.txt (modified) (1 diff)
- trunk/doc/book/content/i18n.txt (modified) (1 diff)
- trunk/doc/book/content/plugin.txt (modified) (1 diff)
- trunk/doc/book/content/sortable.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/doc/book/content/cli.txt
r1193 r1584 56 56 ### Model generation 57 57 58 `propel-build-model`: Create Propel classes for the current model, based on the `schema. xml` file. If you have several files ending with `schema.xml` in your `config/` directory, they are all taken into account.58 `propel-build-model`: Create Propel classes for the current model, based on the `schema.yml` file. If you have several files ending with `schema.yml` in your `config/` directory, they are all taken into account. 59 59 60 60 $ symfony propel-build-model … … 66 66 $ symfony propel-build-schema 67 67 68 `propel-build-sql`: Create the SQL code to create the tables described in the `schema. xml`, in a `data/schema.sql` file.68 `propel-build-sql`: Create the SQL code to create the tables described in the `schema.yml`, in a `data/schema.sql` file. 69 69 70 70 $ symfony propel-build-sql … … 74 74 $ symfony propel-build-db 75 75 76 `propel-insert-sql`: Insert the SQL code from `data/schema. xml` into the database76 `propel-insert-sql`: Insert the SQL code from `data/schema.sql` into the database 77 77 78 78 $ symfony propel-insert-sql trunk/doc/book/content/configuration_practice.txt
r1471 r1584 45 45 config 46 46 47 * `schema.xml` and `propel.ini` are data access configuration files used by Propel (symfony's [ORM layer](model.txt)). They are used to plug the Propel libraries with the symfony classes and the data of your project. The `schema.xml` contains an XML representation of the project's relational data model. The `propel.ini` is automatically generated, so you probably do not need to modify it. If you don't use Propel, these files are not needed. 48 49 As yet, you probably do not realize the great benefit of the YAML format in symfony since none of the project configuration files use it. But there is a good reason for that: these files are used by external components or need to be processed even before any YAML parsing program can be loaded by the framework. The real benefits actually start accruing with the application configuration. 47 * `schema.yml` and `propel.ini` are data access configuration files used by Propel (symfony's [ORM layer](model.txt)). They are used to plug the Propel libraries with the symfony classes and the data of your project. The `schema.yml` contains a representation of the project's relational data model. The `propel.ini` is automatically generated, so you probably do not need to modify it. If you don't use Propel, these files are not needed. 50 48 51 49 Application configuration {#application} trunk/doc/book/content/i18n.txt
r1288 r1584 76 76 For each table that contains some i18n data, it is recommended to split the table in two parts: one table with no i18n column, and the other one with only the i18n columns. This setup lets you add more languages when needed without a change to your model. Let's take an example with a Product table. 77 77 78 First, create tables in the schema.xml file: 79 80 [xml] 81 <table name="my_product" phpName="Product" isI18N="true" i18nTable="my_product_i18n"> 82 <column name="id" type="integer" required="true" primaryKey="true" autoincrement="true" /> 83 <column name="price" type="float" /> 84 </table> 85 86 <table name="my_product_i18n" phpName="ProductI18n"> 87 <column name="id" type="integer" required="true" primaryKey="true" /> 88 <foreign-key foreignTable="my_product"> 89 <reference local="id" foreign="id"/> 90 </foreign-key> 91 <column name="culture" isCulture="true" type="varchar" size="7" required="true" primaryKey="true" /> 92 <column name="name" type="varchar" size="50" /> 93 </table> 94 95 Notice the `isI18N` and `i18nTable` attributes of the `table` tag, and the special `culture` column. Also, the `_i18n` suffix of the second table is a convention that automates many data access mechanisms. All these are symfony specific Propel enhancements. 78 First, create tables in the `schema.yml` file: 79 80 my_connection: 81 my_product: 82 _attributes: { phpName: Product, isI18N: true, i18nTable: my_product_i18n } 83 id: { type: integer, required: true, primaryKey: true, autoincrement: true } 84 price: { type: float } 85 my_product_i18n: 86 _attributes: { phpName: ProductI18n } 87 id: { type: integer, required: true, primaryKey: true, foreignTable: my_product, foreignReference: id } 88 culture: { isCulture: true, type: varchar, size: 7, required: true, primaryKey: true } 89 name: { type: varchar, size: 50 } 90 91 Notice the `isI18N` and `i18nTable` attributes of the first table key, and the special `culture` column. Also, the `_i18n` suffix of the second table is a convention that automates many data access mechanisms. All these are symfony specific Propel enhancements. 92 93 >**Note**: The symfony automatisms can make this much faster to write. If the table containing internationalized data has the same name as the main table with `_i18n` as a suffix, and that they are related with a cilumn named `id` in both tables, you can write the same as above with only: 94 > 95 > my_connection: 96 > my_product: 97 > _attributes: { phpName: Product} 98 > id: 99 > price: float 100 > my_product_i18n: 101 > _attributes: { phpName: ProductI18n } 102 > name: varchar(50) 103 > 104 >You can find more about the schema syntax and automatisms in the [model chapter](model.txt). 96 105 97 106 Once the corresponding object model is built (don't forget to call `symfony propel-build-model` and clear the cache with a `symfony cc` after each modification of the `schema.xml`), you can use your Product class with i18n support as if there was only one table: trunk/doc/book/content/plugin.txt
r754 r1584 206 206 If your plug-in is a module, it has to embed all the necessary configuration files with it. Use the classical file structure of a module to include a `module.yml` file for instance, and all i18n materials should definitely go into a `i18n/` directory. 207 207 208 If your module has a specific data model, written in a `schema. xml`, you will need a post install script to copy it to the project `config/` directory for local installation. For global installations, your README file will have to specify that the `schema.xml` is to be copied manually in the `config/` directory of each project using the plug-in. In both cases, you must not override any existing `schema.xml` in the projects of the user, so it is best to call your schema `pluginName_schema.xml` (as soon as the name ends with `schema.xml`, the `propel-build-model` command will take it into account).208 If your module has a specific data model, written in a `schema.yml`, you will need a post install script to copy it to the project `config/` directory for local installation. For global installations, your README file will have to specify that the `schema.yml` is to be copied manually in the `config/` directory of each project using the plug-in. In both cases, you must not override any existing `schema.yml` in the projects of the user, so it is best to call your schema `pluginName_schema.yml` (as soon as the name ends with `schema.yml`, the `propel-build-model` command will take it into account). 209 209 210 210 If your plug-in includes media files (images, css, javascripts, etc.), you should declare them with a `data` role and specify a base install directory like `symfony/web/sf/MEDIA_TYPE/pluginName/`. For instance, to store a `myimage.jpg` images for the `sfMyPlugin` plug-in, write the `<content>` tag as follows: trunk/doc/book/content/sortable.txt
r1252 r1584 14 14 ### Data structure 15 15 16 For this article, the example used will be an undefined `Item` table - name it according to your needs. In order to be sortable, records need at least a `rank` field - no need for a [heap](http://en.wikipedia.org/wiki/Heap_%28data_structure%29) here since the sorting will be done by the user, not by the computer. So the data structure (to be written in the [`schema.xml`](model.txt)) is simply: 17 18 [xml] 19 <?xml version="1.0" encoding="UTF-8"?> 20 <database name="propel" defaultIdMethod="native" noxsd="true"> 21 <table name="test_item" phpName="Item"> 22 <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /> 23 <column name="name" type="varchar" size="255" /> 24 <column name="rank" type="integer" required="true" /> 25 </table> 26 </database> 16 For this article, the example used will be an undefined `Item` table - name it according to your needs. In order to be sortable, records need at least a `rank` field - no need for a [heap](http://en.wikipedia.org/wiki/Heap_%28data_structure%29) here since the sorting will be done by the user, not by the computer. So the data structure (to be written in the [`schema.yml`](model.txt)) is simply: 17 18 propel: 19 test_item: 20 _attributes: { phpName: Item } 21 id: 22 name: varchar(255) 23 rank: { type: integer, required: true } 27 24 28 25 Make sure you build your model once the data structure is defined by typing in a command line interface: