我正在使用 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模板网!
获取所有产品、类别和元数据的 SQL 查询 woocommSQL query to get all products, categories and meta data woocommerce/wordpress(获取所有产品、类别和元数据的 SQL 查询 woocommerce/wordpre
如何在 WSL(Linux 的 Windows 子系统)中使用 MySQL?How to use MySQL in WSL (Windows Subsystem for Linux)?(如何在 WSL(Linux 的 Windows 子系统)中使用 MySQL?)
任务计划程序中的 PowerShell MySQL 备份脚本错误 PowerShell MySQL Backup Script Error in Task Scheduler 0x00041301(任务计划程序中的 PowerShell MySQL 备份脚本错误 0x00041301)
将数据从 XML 文件导入 MySQL 数据库Import the data from the XML files into a MySQL database(将数据从 XML 文件导入 MySQL 数据库)
在 Windows 7 32 位上安装 Xampp.启动时的错误installed Xampp on Windows 7 32-bit. Errors when starting(在 Windows 7 32 位上安装 Xampp.启动时的错误)
Windows xampp 上的 Mysql 小写表Mysql lower case table on Windows xampp(Windows xampp 上的 Mysql 小写表)