首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用MySQL和Symfony3向列/s添加Symfony3索引

使用MySQL和Symfony3向列/s添加Symfony3索引
EN

Stack Overflow用户
提问于 2017-10-30 09:50:48
回答 1查看 45关注 0票数 1

我在Symfony3中有下面的XML文件,我想将一个MYSQL索引添加到列videoPublisherDate中,因为我将对它进行大量查询并根据它进行排序。我可以通过PHPMYADMIN手动添加它,但我想知道如何才能更新下面的xml以便能够自动完成。

谢谢

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
  <entity name="AppBundle\Entity\Videos" table="videos">
    <unique-constraints>
        <unique-constraint columns="video_id" name="search_idx_videos" />
    </unique-constraints>
    <id name="id" type="integer" column="id">
      <generator strategy="IDENTITY"/>
    </id>
    <field name="videoSource" type="text" column="video_source" length="65535" nullable="false">
      <options>
        <option name="fixed"/>
      </options>
    </field>
    <field name="videoId" type="string" column="video_id" length="50" nullable="false">
      <options>
        <option name="fixed"/>
      </options>
    </field>
    <field name="videoTitle" type="text" column="video_title" length="65535" nullable="false">
      <options>
        <option name="fixed"/>
      </options>
    </field>
    <field name="videoImage" type="text" column="video_image" length="65535" nullable="false">
      <options>
        <option name="fixed"/>
      </options>
    </field>
    <field name="videoPublisher" type="text" column="video_publisher" length="65535" nullable="false">
      <options>
        <option name="fixed"/>
      </options>
    </field>
    <field name="videoPublisherId" type="text" column="video_publisher_id" length="65535" nullable="false">
      <options>
        <option name="fixed"/>
      </options>
    </field>
    <field name="videoPublisherDate" type="text" column="video_publisher_date" length="65535" nullable="false">
      <options>
        <option name="fixed"/>
      </options>
    </field>
    <field name="videoLength" type="integer" column="video_length" nullable="false">
      <options>
        <option name="unsigned"/>
      </options>
    </field>
    <field name="videoActive" type="integer" column="video_active" nullable="false">
      <options>
        <option name="unsigned"/>
        <option name="default">1</option>
      </options>
    </field>
    <field name="videoTags" type="text" column="video_tags" length="65535" nullable="false">
      <options>
        <option name="fixed"/>
      </options>
    </field>
  </entity>
</doctrine-mapping>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-30 10:29:04

您可以在xml定义中添加索引,就像处理唯一约束一样:

代码语言:javascript
复制
<indexes>
    <index name="name_videoPublisherDate" columns="video_publisher_date"/>
</indexes>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47012240

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档