原则2多个索引 [英] Doctrine 2 with multiple indexes

查看:140
本文介绍了原则2多个索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Zend框架和doctrine2.1发展。

I am developing using zend framework and doctrine2.1.

我已经生成的数据库实体。

I have generated entities from database.

但问题是:主义不承认我的索引。他们不是在所有标注实体的注解。

But the problem is: Doctrine doesn't recognize my indexes. They are not marked in entity annotations at all.

而当我去验证,模式​​和转储SQL ORM:架构工具:更新自卸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.

我发现学说用于定义索引以下标注:

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.

推荐答案

我会说你可以在索引属性插入多个索引(但并没有测试它的时间):

I would say you can insert multiple indexes in the indexes property (but didn't had the time to test it):

indexes={
@index(name="index_name", columns={"database_column1","database_column2"}),
@index(name="index_name2", columns={"database_column1"}),
@index(name="index_name3", columns={"database_column2"})
}

希望这有助于你

这篇关于原则2多个索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆