【发布时间】:2017-05-06 23:41:53
【问题描述】:
是否有一种简单的方法来定义列上的非唯一索引?
当我定义唯一索引时,这就足够了:
/** @ORM\Entity */
class Foo {
/** @ORM\Column(type="string", unique=true) */
private $foo;
}
但是,对于非唯一索引,我需要这一堆样板:
/**
* @ORM\Entity
* @ORM\Table(indexes={@Index(name="foo_idx", columns={"foo"})})
*/
class Foo
{
/** @ORM\Column(type="string") */
private $foo;
}
我更喜欢 @ORM\Index 在单个属性上的注释,或者 index=true 等...
【问题讨论】:
标签: php indexing doctrine-orm annotations