5
我对Symfony 2.0和学说非常陌生。我有不同的捆绑状态和客户实体。我只想增加国家和客户之间的关系。我是代码状态和客户实体。下面是我的代码:Symfony 2:学说不能创建关系
/**
* @orm:Entity
*/
class Customer
{
/**
* @orm:Id
* @orm:Column(type="integer")
* @orm:GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @OneToOne(targetEntity="State")
* @JoinColumn(name="state_id", referencedColumnName="id")
*/
protected $state;
}
/**
* @orm:Entity
*/
class State
{
/**
* @orm:Id
* @orm:Column(type="integer")
* @orm:GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* @orm:Column(type="string", length="50")
*/
protected $name;
}
而且我的配置文件:
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
dbname: %database_name%
user: %database_user%
password: %database_password%
orm:
auto_generate_proxy_classes: %kernel.debug%
mappings:
FogCustomerBundle: { type: annotation, dir: Entity/ }
FogMainBundle: { type: annotation, dir: Entity/ }
所以我的问题是,当我使用产生php app/console doctrine:schema:create
命令表生成模式。但是关系不会生成/状态列不会在客户表/中生成。为什么?我没有任何想法?我会很高兴为每个建议和帖子。
谢谢你的回复。根据您的指示,我将所有'@orm'注释更改为'orm'。然后运行'code'php app/console doctrine:schema:create'code'命令并获取'code'没有元数据类来处理。'code'消息。表格不会生成。任何想法? – Zeck 2011-05-10 14:18:32
你可以用你的新实体更新你的问题吗(即用现在的样子替换现有的例子)? – Problematic 2011-05-10 14:21:10
很酷谢谢你。你节省了我的一天。 – Zeck 2011-05-10 14:30:06