0

I am currently working with php and using doctrine. I have this query that I want to rewrite by using the querybuilder so I can make use of it in my graphql command. It selects a string field that is compared with a like statement. All fine and good however I want it to order by the most exact and shortest match. The query I am converting uses an INSTR command for it and I haven't got the faintest idea how to convert it to this querybuilder thing.

I have found this library that kinda does the trick but it is all weird and not updated or contributed to for a long time so not really reliable.

Does anyone have an idea how I should approach this conversion?

The query I am converting sorta looks like this:

SELECT field
FROM table
WHERE field like '%4321%'
ORDER BY INSTR(field, '4321') ASC, LENGTH(field) ASC, field ASC
Michel Floyd
  • 18,793
  • 4
  • 24
  • 39
Totumus Maximus
  • 7,543
  • 6
  • 45
  • 69

0 Answers0