开发者

How do I set more than one index for a table in a doctrine 2 entity file (using annotations)?

I have two columns representing a start date and an end date. If I wanted to create a joint index for them, I would do:

* @Table(name="concerts", indexes={@Index(name="concert_dates", columns={"date_start","date_end"})})

But how would I do an index for each of them ? Is the following way correct?

* @Table(name="concerts", indexes={@Index(name="concert_date_start", 开发者_如何学JAVAcolumns={"date_start"}), @Index(name="concert_date_end", columns={"date_end"})})


Documentation says that indexes is an array of @Index annotations. So I'd say yes, it is correct.


Yes it works fine for me. I have done this:

/**
 * Class ProductDisplayArea
 * @ORM\Entity
 * @ORM\Table(name="product_display_area", indexes={
 *      @Index(name="product_display_area_product_id", columns={"product_id"}),
 *      @Index(name="product_display_area_productCat_id", columns={"productCat_id"}),
 *      @Index(name="product_display_area_productSCat_id", columns={"productSCat_id"}),
 *      @Index(name="product_display_area_productSSCat_id", columns={"productSSCat_id"})
 * })
 * @ORM\HasLifecycleCallbacks()
 * @ORM\Entity(repositoryClass="Admin\AdminBundle\Entity\ProductDisplayAreaRepository")
 */
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜