Closed rodrigozietlow closed 5 years ago
Apologies for the late reply, the problem here is that you have nothing to OR
. FIND_OR
will OR
together everything inside it.
The following should work, although it's a bit more verbose:
filter([
\Maphper\Maphper::FIND_OR => [
\Maphper\Maphper::FIND_LIKE => [
"description" => "%$nomeProj%"
],
\Maphper\Maphper::FIND_LIKE => [
"name" => "%$nomeProj%"
]
]
])
You have to wrap the FIND_LIKE's in an array also to avoid duplicate keys
filter([
\Maphper\Maphper::FIND_OR => [
[\Maphper\Maphper::FIND_LIKE => [
"description" => "%$nomeProj%"
]] ,
[\Maphper\Maphper::FIND_LIKE => [
"name" => "%$nomeProj%"
]]
]
])
filter([ \Maphper\Maphper::FIND_OR => [ \Maphper\Maphper::FIND_LIKE => [ "description" => "%$nomeProj%" ], \Maphper\Maphper::FIND_LIKE => [ "name" => "%$nomeProj%" ] ] ])
This worked, thank you.
How did you manage to avoid the issue of duplicate keys with that code?
I'm trying to filter by both name and description of a query on a search function, but I have not found the way to do it yet. What I tried:
But doing so results in
SELECT * FROM projeto WHERE (((description LIKE :description AND name LIKE :name)))
And doing the opposite, wrapping
FIND_OR
inside aFIND_LIKE
, the query just freaks outSELECT * FROM projeto WHERE (((description :description OR name :name)))
.Am I missing something or it isn't possible?