Symfony2 Doctrine Entity 中字段注释支持的参数和数据类型(Data Type List )

支持的参数:

  • type: (optional, defaults to ‘string’) The mapping type to use for the column.

  • name: (optional, defaults to field name) The name of the column in the database.

  • length: (optional, default 255) The length of the column in the database. (Applies only if a string-valued column is used).

  • unique: (optional, default FALSE) Whether the column is a unique key.

  • nullable: (optional, default FALSE) Whether the database column is nullable.

  • precision: (optional, default 0) The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum number of digits that are stored for the values.

  • scale: (optional, default 0) The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number of digits to the right of the decimal point and must not be greater than precision.

  • columnDefinition: (optional) Allows to define a custom DDL snippet that is used to create the column. Warning: This normally confuses the SchemaTool to always detect the column as changed.

  • options: (optional) Key-value pairs of options that get passed to the underlying database platform when generating DDL statements.


"type"支持的数据类型:

  • string: Type that maps a SQL VARCHAR to a PHP string.

  • integer: Type that maps a SQL INT to a PHP integer.

  • smallint: Type that maps a database SMALLINT to a PHP integer.

  • bigint: Type that maps a database BIGINT to a PHP string.

  • boolean: Type that maps a SQL boolean or equivalent (TINYINT) to a PHP boolean.

  • decimal: Type that maps a SQL DECIMAL to a PHP string.

  • date: Type that maps a SQL DATETIME to a PHP DateTime object.

  • time: Type that maps a SQL TIME to a PHP DateTime object.

  • datetime: Type that maps a SQL DATETIME/TIMESTAMP to a PHP DateTime object.

  • datetimetz: Type that maps a SQL DATETIME/TIMESTAMP to a PHP DateTime object with timezone.

  • text: Type that maps a SQL CLOB to a PHP string.

  • object: Type that maps a SQL CLOB to a PHP object using serialize() and unserialize()

  • array: Type that maps a SQL CLOB to a PHP array using serialize() and unserialize()

  • simple_array: Type that maps a SQL CLOB to a PHP array using implode() and explode(), with a comma as delimiter.IMPORTANT Only use this type if you are sure that your values cannot contain a ”,”.

  • json_array: Type that maps a SQL CLOB to a PHP array using json_encode() and json_decode()

  • float: Type that maps a SQL Float (Double Precision) to a PHP double. IMPORTANT: Works only with locale settings that use decimal points as separator.

  • guid: Type that maps a database GUID/UUID to a PHP string. Defaults to varchar but uses a specific type if the platform supports it.

  • blob: Type that maps a SQL BLOB to a PHP resource stream


更多参考官方文档:

http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#property-mapping

by 雪洁 2014-10-20 03:59:15 3278 views
我来说几句

相关文章