2

In a form i have a text input which purpose if to hold names or part of names of some ships.

The current (working) findby is the following:

$shipList = $shipRepo->findBy(array('faction'=>$factionSearch, 'extension'=>$extensionSearch));

Removed some filters for convenience. I use this method so that I don't have to write a giant query in the repository with 8 joints and hunderds of selects clauses.

Example : There is in the database a ship named "Le Superbe". My goal is that this ship will be present in the output if the user inputs "sup" in the text field.

Question : Can I process a LIKE search on the top of current filters in the findBy() ?

Arshellan
  • 55
  • 4
  • Does this answer your question? [How to use a findBy method with comparative criteria](https://stackoverflow.com/questions/14786937#14790069). You can look in [the manual](https://www.doctrine-project.org/projects/doctrine-orm/en/2.8/reference/query-builder.html#the-expr-class) for the exact *expr* you need. – msg Jun 04 '21 at 08:31

1 Answers1

4

Can I process a LIKE search on the top of current filters in the findBy() ?

The answer is no. Doctrine findBy method does not allow you to use LIKE. You will have to use DQL to do this.

Florent Cardot
  • 1,400
  • 1
  • 10
  • 19