是否可以使用 Propel2 进行全文(匹配)查询?

Are fulltext (match against) queries with Propel2 possible?

使用 Propel2 和 MySQL/InnoDB,我想对 table [=15] 的 VARCHARtitledirector 执行全文查询=].在普通的 SQL 这将读取

SELECT * FROM movies WHERE
    MATCH(title, director) AGAINST("big lebowski" IN NATURAL LANGUAGE MODE);

如何使用 Propel2 框架构造此查询?


在 schema.xml

中创建全文索引的注意事项

我通过包含以下内容成功地使用 Propel2 schema.xml 文件创建了 FULLTEXT 索引:

<index name="fulltext">
  <index-column name="title"/>
  <index-column name="director"/>
  <vendor type="mysql">
    <parameter name="Index_type" value="FULLTEXT"/>
  </vendor>
</index>

只缺少查询。 :) 有什么想法吗?

您可以使用以下代码:

$movies = MovieQuery::create()
    -> where('MATCH(Movie.title, Movie.director) AGAINST(? IN BOOLEAN MODE)',
             'big lebowski')
    -> find();

参见Propel documentation