# tp-doctrine **Repository Path**: misssuri/tp-doctrine ## Basic Information - **Project Name**: tp-doctrine - **Description**: No description available - **Primary Language**: PHP - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-29 - **Last Updated**: 2024-06-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 参考地址: [doctrine注释常用属性](https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/annotations-reference.html) 属性说明 - name:指定映射的数据库列名称,不指定时默认使用属性名。 - type:指定映射的数据库中列的类型。不指定时默认为string类型即对应mysql的varchar(255)。 - length:指定列类型是string时的长度,如:length=32对应mysql的varchar(32),不指定时默认为255。 - unique: 指定列添加唯一索引,默认为false。 - nullable: 指定列是否可空,默认为false。 - precision:指定列为decimal类型时,可存储的最大值。 - scale: 指定列位decimal类型时,小数点后的精度位数。 - columnDefinition:直接使用数据库定义语句DDL片段进行指定。如:columnDefinition="char(32) not null "。 - options: 通过键值对参数设置数据库定义语言参数。如:options=[ "nullable" => false, "unsigned" => true, "default" => '']; 基本映射类型 - Icon - string => varchar; - integer => int; - smallint => smallint; - bigint => bigint; - boolean => tinyint; - decimal => decimal; - date => datetime; - time => time; - datetime => timestamp; - text => text; - object => text(serialize()/unserialize()); - array => text(serialize()/unserialize()); - simple_array => text(implode()/explode()); - json_array => text(json_encode()/json_decode()) 常用命令: - doctrine.bat //查看系统基本的命令 - doctrine.bat orm:validate-schema //校验映射实体和数据库是否匹配 - doctrine.bat orm:schema-tool:update --force --dump-sql //通过映射实体操作数据库表(更新OR创建) - doctrine.bat orm:clear-cache:metadata //更新映射缓存(每次对映射进行修改时,最好执行一遍,避免未知问题)