Arshellan
Arshellan

Reputation: 55

Symfony LIKE criteria in Findby()

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() ?

Upvotes: 2

Views: 4013

Answers (1)

Florent Cardot
Florent Cardot

Reputation: 1418

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.

Upvotes: 4

Related Questions