在Doctrine 2中指定表类型/存储引擎

Mat*_*ogt 13 php mysql myisam full-text-search doctrine-orm

那么如何在Doctrine 2中指定用于给定实体的存储引擎呢?

我正在创建一个需要全文索引的表,只有MyISAM存储引擎支持MySQL中的全文索引.

作为一方:看起来Doctrine 2不支持开箱即用的全文索引?也不是全文搜索?那是对的吗?

Gab*_*Kid 23

我已经晚了两年,但知道这一点非常重要,因为由于某些原因没有记录,我们一直在努力实现这一目标,但这是解决方案

/**
 * ReportData
 *
 * @ORM\Table(name="reports_report_data",options={"engine":"MyISAM"})
 * @ORM\Entity(repositoryClass="Jac\ReportGeneratorBundle\Entity\ReportDataRepository")
 */
class ReportData
{
Run Code Online (Sandbox Code Playgroud)


Mik*_*raf 7

更新:

请参阅有关添加"@Table(name ="table_name",options = {"engine"="MyISAM"})"的评论,这是更好的答案.

=======原文如下===========

这是一个未经测试的代码,旨在帮助您获得答案,您需要阅读大量的Doctrine2代码来找出您想要的内容.我花了大约30分钟阅读代码并且无法找到通过ORM层将$ options数组推送到此DBAL层函数的方法.

查看Doctrine/DBAL/Platforms/MySQLPlatform.php

427         // get the type of the table
428         if (isset($options['engine'])) {
429             $optionStrings[] = 'ENGINE = ' . $options['engine'];
430         } else {
431             // default to innodb
432             $optionStrings[] = 'ENGINE = InnoDB';
433         }
Run Code Online (Sandbox Code Playgroud)

尝试在那里编写引擎想要的硬编码.它几乎肯定会破坏东西(例如,外键在MyISAM中不起作用)

  • 您可以使用`@Table(name ="table_name",options = {"engine"="MyISAM"})为表设置此项. (13认同)