2

With Propel2 and MySQL/InnoDB, I want to execute a fulltext query on the VARCHAR columns title and director of a table movies. In plain SQL this would read

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

How can this query be constructed with the Propel2 framework?


Note on creating a FULLTEXT index in schema.xml

I succeeded in creating the FULLTEXT index with the Propel2 schema.xml file by including:

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

All that's missing is the query. :) Any ideas?

1 Answer 1

2

You can use the following code:

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

See the Propel documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.