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

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

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

But how would I make an index for each of them? Is this right?

 * @Table(name="concerts", indexes={@Index(name="concert_date_start", columns={"date_start"}), @Index(name="concert_date_end", columns={"date_end"})}) 
+8
php indexing annotations doctrine doctrine2
source share
2 answers

The documentation says indexes is an array of @Index annotations. Therefore, I would say yes, that’s right.

+11
source share

Yes, this works great 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") */ 
+10
source share

All Articles