我正在使用 Zend 框架和 Doctic2.1 进行开发.
I am developing using zend framework and doctrine2.1.
我从数据库生成了实体.
I have generated entities from database.
但问题是:Doctrine 无法识别我的索引.它们根本没有在实体注释中标记.
But the problem is: Doctrine doesn't recognize my indexes. They are not marked in entity annotations at all.
当我去验证模式并从 orm:schema-tool:update --dump-sql
转储 sql 时,它会生成 sql 来删除整个数据库中的所有索引.
And when I go to validate-schema and dump sql from orm:schema-tool:update --dump-sql
it generates sql to drop all my indexes across whole database.
我发现 Doctrine 有以下用于定义索引的注释:
I found that Doctrine has following annotation used for defining indexes:
indexes={@index(name="index_name",
columns={"database_column1","database_column2"}
)}
但这允许我为多列定义一个索引,而我真的不需要那个.
我想要的是能够在多列上定义多个索引,每列一个索引.
But this allows me to define one index for multiple columns and I don't really need that.
What I want is the ability to define multiple indexes on multiple columns, one index per column.
有什么办法可以做到这一点吗?有没有办法让我可以使用定义多个索引的注释.
Is there a way I can achieve this? Is there a way that I can have annotation that defines multiple indexes.
我会说你可以在 indexs 属性中插入多个索引(但我没有时间测试它):
I would say you can insert multiple indexes in the indexes property (but I haven't had the time to test it):
indexes={
@ORM\Index(name="index_name", columns={"database_column1","database_column2"}),
@ORM\Index(name="index_name2", columns={"database_column1"}),
@ORM\Index(name="index_name3", columns={"database_column2"})
}
希望对你有帮助
这篇关于具有多个索引的 Doctrine 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!