根据模式声明使用 Doctrine2 创建表和实体
我正在尝试让 Doctrine2
和 Zend Framework
一起工作。到目前为止,我已经能够自动加载 Doctrine2
并连接到我的数据库。
我现在期待使用 yml 中的架构声明创建表:
Doctrine\Entities\User:
type: entity
table: core_user
columns:
id:
primary: true
autoincrement: true
type: integer(11)
notnull: true
name:
type: string
notnull: true
default: ''
middle_name:
type: string
default: ''
last_name:
type: string
notnull:true
default: ''
username:
type: varchar(16)
default: ''
email:
type: string
notnull: true
default: ''
role_id:
type: integer
date_creation:
type: timestamp
version:
type: timestamp
我已经能够使命令行工作,但无法让它在数据库中创建表。
我正在使用标准 Zend Framework
文件夹结构
+-- Application
+-- configs
+-- controllers
+-- doctrine
+-- Schema
+-- schema.yml
+-- Entities
cli-config.php
+-- layouts
+-- models
+-- modules
+-- view
bootstrap.php
+-- Public
+-- Library
+-- Doctrine2
+-- Tests
我的架构声明位于 Application/doctrine/Schema/schema.yml
中,我希望创建我的数据库 tables< /code> 和我的
Entities
。
当我尝试运行命令 doctrine orm:schema-tool:create
时,我收到以下消息:没有要处理的元数据类。
我想知道为什么。
我是否以正确的方式让它工作,或者我应该手动定义我的实体,然后尝试从中创建我的表?
I am trying to get Doctrine2
and Zend Framework
working together. So far I have been able to autoload Doctrine2
and connect to my database.
I am now looking forward creating my tables using a schema declaration in yml
:
Doctrine\Entities\User:
type: entity
table: core_user
columns:
id:
primary: true
autoincrement: true
type: integer(11)
notnull: true
name:
type: string
notnull: true
default: ''
middle_name:
type: string
default: ''
last_name:
type: string
notnull:true
default: ''
username:
type: varchar(16)
default: ''
email:
type: string
notnull: true
default: ''
role_id:
type: integer
date_creation:
type: timestamp
version:
type: timestamp
I have been able to get the command line working, but I can't get it to create the tables in my database.
I am using a standard Zend Framework
folder structure
+-- Application
+-- configs
+-- controllers
+-- doctrine
+-- Schema
+-- schema.yml
+-- Entities
cli-config.php
+-- layouts
+-- models
+-- modules
+-- view
bootstrap.php
+-- Public
+-- Library
+-- Doctrine2
+-- Tests
My schema declaration is in Application/doctrine/Schema/schema.yml
and I am looking to create my database tables
and my Entities
from it.
When I try to run the command doctrine orm:schema-tool:create
I get the following message : No Metadata Classes to process.
and I am wondering why.
Am I on the right way of getting it working, or should I define manually my entities and then try to create my tables from it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查 cli-config.php 中的配置。
您应该使用 YAML 驱动程序:
更多信息请参见 docs。
Check configurations in
cli-config.php
.You should use YAML driver:
More in docs.