So how can one specify the storage engine to use for a given entity in Doctrine 2?
那么如何在Doctrine 2中指定用于给定实体的存储引擎?
I'm creating a table that needs a full text index and only the MyISAM storage engine supports full text indexing in MySQL.
我正在创建一个需要全文索引的表,只有MyISAM存储引擎支持MySQL中的全文索引。
As a side: it looks like Doctrine 2 doesn't support full text indexing out of the box? Nor full text searches? Is that correct?
作为一方:看起来Doctrine 2不支持开箱即用的全文索引?也不是全文搜索?那是对的吗?
3 个解决方案
#1
21
I'm two years too late, but knowing this is important since it isn't documented for some reason, we have been struggling to achieve this but this is the solution
我已经晚了两年,但知道这很重要,因为它没有记录的原因,我们一直在努力实现这一点,但这是解决方案
/**
* ReportData
*
* @ORM\Table(name="reports_report_data",options={"engine":"MyISAM"})
* @ORM\Entity(repositoryClass="Jac\ReportGeneratorBundle\Entity\ReportDataRepository")
*/
class ReportData
{
#2
6
Update:
See the comment about adding "@Table(name="table_name",options={"engine"="MyISAM"})" , it is the better answer.
请参阅有关添加“@Table(name =”table_name“,options = {”engine“=”MyISAM“})”的评论,这是更好的答案。
======= Original Below ===========
=======原文下面===========
This is untested code aimed to help you get to an answer, you will need to read a lot of Doctrine2 code to figure out what you want though. I spent about 30mins reading code and couldnt find a way to push the $options array through the ORM layer to this DBAL layer function.
这是一个未经测试的代码,旨在帮助您获得答案,您需要阅读很多Doctrine2代码来找出您想要的内容。我花了大约30分钟阅读代码并且无法找到将$ options数组通过ORM层推送到此DBAL层函数的方法。
check out Doctrine/DBAL/Platforms/MySQLPlatform.php
查看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 }
try hard coding what engine want in there. It will almost certainly break stuff though (eg, foreign keys dont work in MyISAM)
尝试在那里编写引擎想要的硬编码。它几乎肯定会破坏东西(例如,外键在MyISAM中不起作用)
#3
1
If you're using doctrine2 migrations ..
如果您正在使用doctrine2迁移..
$table = $schema->createTable('user');
$table->addColumn('id', 'integer');
$table->addOption('engine' , 'MyISAM');
$table->setPrimaryKey(array('id'));
#1
21
I'm two years too late, but knowing this is important since it isn't documented for some reason, we have been struggling to achieve this but this is the solution
我已经晚了两年,但知道这很重要,因为它没有记录的原因,我们一直在努力实现这一点,但这是解决方案
/**
* ReportData
*
* @ORM\Table(name="reports_report_data",options={"engine":"MyISAM"})
* @ORM\Entity(repositoryClass="Jac\ReportGeneratorBundle\Entity\ReportDataRepository")
*/
class ReportData
{
#2
6
Update:
See the comment about adding "@Table(name="table_name",options={"engine"="MyISAM"})" , it is the better answer.
请参阅有关添加“@Table(name =”table_name“,options = {”engine“=”MyISAM“})”的评论,这是更好的答案。
======= Original Below ===========
=======原文下面===========
This is untested code aimed to help you get to an answer, you will need to read a lot of Doctrine2 code to figure out what you want though. I spent about 30mins reading code and couldnt find a way to push the $options array through the ORM layer to this DBAL layer function.
这是一个未经测试的代码,旨在帮助您获得答案,您需要阅读很多Doctrine2代码来找出您想要的内容。我花了大约30分钟阅读代码并且无法找到将$ options数组通过ORM层推送到此DBAL层函数的方法。
check out Doctrine/DBAL/Platforms/MySQLPlatform.php
查看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 }
try hard coding what engine want in there. It will almost certainly break stuff though (eg, foreign keys dont work in MyISAM)
尝试在那里编写引擎想要的硬编码。它几乎肯定会破坏东西(例如,外键在MyISAM中不起作用)
#3
1
If you're using doctrine2 migrations ..
如果您正在使用doctrine2迁移..
$table = $schema->createTable('user');
$table->addColumn('id', 'integer');
$table->addOption('engine' , 'MyISAM');
$table->setPrimaryKey(array('id'));