如何在Doctrine中声明postgresql的索引,如: CREATE INDEX index_name_city_hotel ON booking_hotels(lower(name)text_pattern_ops,city_hotel,cc1)
我已经尝试但似乎不可能使用lower()函数。 由于功能较低,这不起作用:
indexes={
@ORM\Index(name="index_name_city_hotel", columns={"lower(name) text_pattern_ops", "city_hotel", "cc1"})
提前感谢您的帮助。
答案 0 :(得分:0)
尝试使用https://github.com/intaro/custom-index-bundle
<?php
namespace Acme\MyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Intaro\CustomIndexBundle\Annotations as CustomIndexAnnotation
/**
* @ORM\Table(name="my_entity")
* @ORM\Entity()
* @CustomIndexAnnotation\CustomIndexes(indexes={
* @CustomIndexAnnotation\CustomIndex(columns="my_property1"),
* @CustomIndexAnnotation\CustomIndex(columns={"lower(my_property1)", "lower(my_property2)"})
* })
*/
class MyEntity
{
/**
* @ORM\Column(type="string", length=256)
*/
protected $myProperty1;
/**
* @ORM\Column(type="string", length=256)
*/
protected $myProperty2;
}