Anonymous Anonymous - 7 months ago
223 0

Example how to add indexes to multiple rows in Doctrine2.

PHP

Doctrine2 add index to multiple rows.

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Entity
 *
 * @ORM\Table(name="table_name",indexes={
 *  @ORM\index(name="firstRow", columns={"first_row"}),
 *  @ORM\index(name="secondRow", columns={"second_row"}),
 *  @ORM\index(name="thirdRow", columns={"third_row"}),
 * })
 * @ORM\Entity(repositoryClass="AppBundle\Repository\Entity")
 */
class Entity
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="first_row", type="string", length=255)
     * @
     */
    private $firstRow;

    /**
     * @var string
     *
     * @ORM\Column(name="second_row", type="string", length=255)
     */
    private $secondRow;

    /**
     * @var int
     *
     * @ORM\Column(name="third_row", type="integer")
     */
    private $thirdRow;
}