【发布时间】:2015-03-02 21:16:03
【问题描述】:
我从另一个团队继承了一个项目,但似乎无法对数据库做任何事情。我是 zend 和教义的总 n00b,但 ORM 工具似乎很简单;但是,在尝试使用它时,我从orm:schema-tool:drop、orm:schema-tool:create、orm:schema-tool:update 等收到同样的错误。
[Doctrine\DBAL\Schema\SchemaException]
The table with name 'mydb.alerts_residents' already exists.
我的数据库已创建,但没有表。我读过的其他帖子让我得出结论,这条消息是基于我的实体对象定义和注释。
您可能会怀疑,alerts_residents 是一个连接表,它以多对多关系将Alert 实体与Resident 实体连接起来。这些是唯一引用此表的实体,而且它们似乎正确地这样做了。
class Resident
{
/**
* @var ArrayCollection $zone
*
* @ORM\ManyToMany(targetEntity="Alert")
* @ORM\JoinTable(
* name="alerts_residents",
* joinColumns={@ORM\JoinColumn(name="resident_id", referencedColumnName="id", onDelete="CASCADE")},
* inverseJoinColumns={@ORM\JoinColumn(name="alert_id", referencedColumnName="id", onDelete="CASCADE")}
* )
*/
protected $alerts;
class Alert
{
/**
* @var ArrayCollection $zone
*
* @ORM\ManyToMany(targetEntity="Resident")
* @ORM\JoinTable(
* name="alerts_residents",
* joinColumns={@ORM\JoinColumn(name="alert_id", referencedColumnName="id", onDelete="CASCADE")},
* inverseJoinColumns={@ORM\JoinColumn(name="resident_id", referencedColumnName="id", onDelete="CASCADE")}
* )
*/
protected $residents;
没有@ORM\Table(name="alerts_residents") 的实体。为什么会出现此错误?
【问题讨论】:
标签: php mysql orm doctrine-orm zend-framework2