It actually seems that I have this problem with all the Doctrine
functions... LOWER was just one...and ILIKE has the same problem.
I implemented both LIKE and ILIKE through a custom function and now also
LIKE does not work.
Here is the code:
class Ilike extends FunctionNode {
protected $field;
protected $value;
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->field = $parser->StringPrimary();
$parser->match(Lexer::T_COMMA);
$this->value = $parser->StringPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
return $this->field->dispatch($sqlWalker) . ' ILIKE ' .
$this->value->dispatch($sqlWalker);
}
}
Do you see something strange that can cause the problem?
Thank you
Il 26/05/2014 13.52, 'Jasper N. Brouwer' via doctrine-user ha scritto:
Hmm.. you probably want a custom expression (in stead of a function). I'm not
sure if you can easily add a custom expression.
In theory it should be possible, because Doctrine uses a parser to convert DQL
to an AST, and then to SQL. But unfortunately I don't know how :(
Maybe others on this list shed some light?
PS: One option I can think of is to use an Output Walker [2] to convert LIKE in
DQL to ILIKE in SQL. So you still use LIKE in your DQL query, but set your
Output Walker as hint when you want it to end up as ILIKE in SQL.
[2]:
http://docs.doctrine-project.org/en/2.1/cookbook/dql-custom-walkers.html#modify-the-output-walker-to-generate-vendor-specific-sql
--
Jasper N. Brouwer
(@jaspernbrouwer)
On 26 May 2014 at 12:54:49, Gianvito Pio ([email protected]) wrote:
Ok, but actually I have to compose a very complex query and it would be
better to be coherent between LIKE (case sensitive) and ILIKE (case
insensitive) in such composition.
As far as you know, is it possible to define a custom infix operator (as
ILIKE)? I would prefer to perform the query as "field ILIKE value" and
not as "ILIKE(field,value)".
Thank you
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.