2012年9月10日 星期一

doctrine 支援特殊字元欄位名


doctrine query language column name (dash OR - OR character)

http://docs.doctrine-project.org/en/2.0.x/reference/basic-mapping.html

4.9. Quoting Reserved Words

It may sometimes be necessary to quote a column or table name because it conflicts with a reserved word of the particular RDBMS in use. This is often referred to as “Identifier Quoting”. To let Doctrine know that you would like a table or column name to be quoted in all SQL statements, enclose the table or column name in backticks. Here is an example:
<?php
/** @Column(name="`number`", type="integer") */
private $number;
Doctrine will then quote this column name in all SQL statements according to the used database platform.
Identifier Quoting is not supported for join column names or discriminator column names.
Identifier Quoting is a feature that is mainly intended to support legacy database schemas. The use of reserved words and identifier quoting is generally discouraged. Identifier quoting should not be used to enable the use non-standard-characters such as a dash in a hypothetical column test-name. Also Schema-Tool will likely have troubles when quoting is used for case-sensitivity reasons (in Oracle for example).

symfony doctrine Identifier Quoting

http://www.symfony-project.org/reference/1_2/en/07-Databases

Doctrine

Default Configuration:
all:
  doctrine:
    class:        sfDoctrineDatabase
    param:
      dsn:        mysql:dbname=##PROJECT_NAME##;host=localhost
      username:   root
      password:   
      attributes:
        quote_identifier: false
        use_native_enum: false
        validate: all
        idxname_format: %s_idx
        seqname_format: %s_seq
        tblname_format: %s

沒有留言:

張貼留言