我对Symfony 2.0和Doctrine非常陌生。我在不同bundle中有state和customer实体。我只想在state和customer之间添加关联。我已经编写了state和customer实体的代码。以下是我的代码:
/**
* @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
命令生成模式时,表会被生成。但是关系没有生成,客户表中的状态列也没有生成。为什么?我没有任何想法。我很高兴能得到每一个建议和帖子。