我建立了一个doctrine2实体类Group
并引用了表名:
/**
* models\Entity\Group
*
* @ORM\Entity(repositoryClass="models\Repository\GroupRepository")
* @ORM\Table(name="`group`", indexes={@ORM\Index(name="admin", columns={"`admin`"})})
*/
class Group
{
但是教义似乎没有在每个查询中引用表名。当我运行doctrine orm:schema-tool:update --dump-sql
最后两个查询时没有转义:
ALTER TABLE group DROP FOREIGN KEY FK_6DC044C5814666E9;
ALTER TABLE group ADD CONSTRAINT FK_6DC044C5814666E9 FOREIGN KEY (`admin`) REFERENCES `user` (`id`)
这里做错了吗?
编辑
现在我更换了
if ($table instanceof Table) {
$table = $table->getQuotedName($this);
}
这样
if ($table instanceof Table) {
$table = $table->getQuotedName($this);
} /* Start hack */ else if (0 !== strpos($table, '`'))
$table = "`$table`"; /* End hack */
在\Doctrine\DBAL\Platforms\AbstractPlatform::getCreateForeignKeySQL()
和getDropForeignKeySQL()
。但这当然不是……嗯……一个很好的解决方案。