简体   繁体   中英

How to do fulltext search with doctrine?

WHERE column = value    ->add(column, value);
WHERE column <> value   ->add(column, value, Criteria::NOT_EQUAL);
Other Comparison Operators  
> , <   Criteria::GREATER_THAN, Criteria::LESS_THAN
>=, <=  Criteria::GREATER_EQUAL, Criteria::LESS_EQUAL
IS NULL, IS NOT NULL    Criteria::ISNULL, Criteria::ISNOTNULL
LIKE, ILIKE     Criteria::LIKE, Criteria::ILIKE
IN, NOT IN  Criteria::IN, Criteria::NOT_IN
Other SQL Keywords  
ORDER BY column ASC     ->addAscendingOrderByColumn(column);
ORDER BY column DESC    ->addDescendingOrderByColumn(column);
LIMIT limit     ->setLimit(limit)
OFFSET offset   ->setOffset(offset)
FROM table1, table2 WHERE table1.col1 = table2.col2     ->addJoin(col1, col2)
FROM table1 LEFT JOIN table2 ON table1.col1 = table2.col2   ->addJoin(col1, col2, Criteria::LEFT_JOIN)
FROM table1 RIGHT JOIN table2 ON table1.col1 = table2.col2  ->addJoin(col1, col2, Criteria::RIGHT_JOIN)

The above are all basic operations,what's the equivalent for fulltext search?

The Doctrine documentation about Searching describes this pretty well.

Wrap up:

  • You have to add the behavior Searchable to your model definition and configure which fields should be indexed.
  • You might have to set up some other stuff that is explained in the documentation.
  • You can perform a search with search , eg:

     $newsItemTable = Doctrine_Core::getTable('NewsItem'); $results = $newsItemTable->search('test'); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM