Answer the question
In order to leave comments, you need to log in
How to add INSTR function to Doctrine2?
Good evening,
I'm using Symfony 2.3 with the underlying doctrine.
you must use the INSTR() function in queries.
I found how to add “my own” function, created a class, but the doctrine swears at the query syntax ...
In general, if someone has a ready-made example, let me see how it all should look.
For myself, I took an example from this function:
github.com/doctrine/doctrine2/blob/90b6d5e293147a0268ca005362ff50343bc6dc0f/lib/Doctrine/ORM/Query/AST/Functions/SubstringFunction.php
In fact, I just removed the third parameter, which I don’t have, but that’s all still doesn't work.
Answer the question
In order to leave comments, you need to log in
probably because the condition should have a comparison with something
and probably because the query should look something like this
SELECT count(*) FROM table1 WHERE INSTR(field1, 'bar') != 0;
Found an example: coolspamforeva.org/?p=292
I did everything as described, but nothing has changed.
My function is parsed, but swears at a further ORDER:
[Syntax Error] line 0, col 107: Error: Expected =, <, <=, <>, >, >=, !=, got 'ORDER'
SELECT n FROM QCoreBundle:Node n WHERE n.name IN (:names) AND n.level IN (:levels) AND INSTR(:path, n.url) ORDER BY n.left DESC
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question