Symfony2将数据库架构信息存储在数据库表中

布拉巴斯

我需要将数据库架构信息存储在数据库中。我已经有一个名为db_entity的表,该表存储实体名称,名称空间和其他选项。与此表相关,我需要有一个表Entity_attributes,该表将具有entity_id,attribute_name,attribute_type,必需等。

创建模式结构很容易,但是将我所有实体中的所有字段插入数据库中将是一件繁琐的工作。有什么方法可以创建一个脚本,该脚本可以解析所有实体注释,从而可以将所有字段创建到数据库表中?

最好的做法是为doctrine:schema:update写一个类似的命令,以更新我的表模式。

谢谢你。

乌丹

原则元数据类http://www.doctrine-project.org/api/orm/2.2/source-class-Doctrine.ORM.Mapping.ClassMetadataInfo.html包含可能正是您所需要的公共属性:

 222:     /**
 223:      * READ-ONLY: The field mappings of the class.
 224:      * Keys are field names and values are mapping definitions.
 225:      *
 226:      * The mapping definition array has the following values:
 227:      *
 228:      * - <b>fieldName</b> (string)
 229:      * The name of the field in the Entity.
 230:      *
 231:      * - <b>type</b> (string)
 232:      * The type name of the mapped field. Can be one of Doctrine's mapping types
 233:      * or a custom mapping type.
 234:      *
 235:      * - <b>columnName</b> (string, optional)
 236:      * The column name. Optional. Defaults to the field name.
 237:      *
 238:      * - <b>length</b> (integer, optional)
 239:      * The database length of the column. Optional. Default value taken from
 240:      * the type.
 241:      *
 242:      * - <b>id</b> (boolean, optional)
 243:      * Marks the field as the primary key of the entity. Multiple fields of an
 244:      * entity can have the id attribute, forming a composite key.
 245:      *
 246:      * - <b>nullable</b> (boolean, optional)
 247:      * Whether the column is nullable. Defaults to FALSE.
 248:      *
 249:      * - <b>columnDefinition</b> (string, optional, schema-only)
 250:      * The SQL fragment that is used when generating the DDL for the column.
 251:      *
 252:      * - <b>precision</b> (integer, optional, schema-only)
 253:      * The precision of a decimal column. Only valid if the column type is decimal.
 254:      *
 255:      * - <b>scale</b> (integer, optional, schema-only)
 256:      * The scale of a decimal column. Only valid if the column type is decimal.
 257:      *
 258:      * - <b>unique (string, optional, schema-only)</b>
 259:      * Whether a unique constraint should be generated for the column.
 260:      *
 261:      * @var array
 262:      */
 263:     public $fieldMappings = array();

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Symfony2,在数据库中配置pdo会话存储

来自分类Dev

将视图计数存储在数据库表中

来自分类Dev

如何在数据库中存储字体信息

来自分类Dev

在数据库中存储嵌套信息的最佳方法

来自分类Dev

Facebook用户信息存储在数据库中

来自分类Dev

Symfony2 FOSUserBundle更改数据库表

来自分类Dev

在数据库表中存储视图计数

来自分类Dev

如何从存储在数据库中的表中选择*

来自分类Dev

Symfony2 Profiler在数据库面板中为空结果

来自分类Dev

使用二维码将信息存储在数据库中

来自分类Dev

将登录详细信息存储在数据库中

来自分类Dev

登录的详细信息是否将通过php存储在数据库中?

来自分类Dev

Symfony2数据库配置

来自分类Dev

插入数据库symfony2

来自分类Dev

在数据库中存储ID

来自分类Dev

在数据库中存储CSS

来自分类Dev

在数据库中存储逻辑

来自分类Dev

在数据库中存储数组

来自分类Dev

将行数存储在数据库中或动态获取

来自分类Dev

将映像存储在数据库与文件系统中

来自分类Dev

将帖子显示顺序存储在数据库中

来自分类Dev

将php代码规则存储在数据库中

来自分类Dev

将“ SQL查询文本”存储在数据库中

来自分类Dev

Django,将函数存储在数据库中

来自分类Dev

将指向对象的指针存储在数据库中

来自分类Dev

将枚举存储在数据库中

来自分类Dev

将git repo存储在数据库中

来自分类Dev

将映像存储在数据库与文件系统中

来自分类Dev

使用For循环将值存储在数据库中