i have a problem with the F3 Framework.
I'm trying to search for some text, which was typed by the user.
Here some statement:
$db->exec(array("Select userid,username,section from user
WHERE section=:sectionId
AND username ILIKE '%?%'"),
array(':sectionId' => $sectionId),
array( 1=> $queryString),
NULL));
If there is some typo sorry, but i'm not allowed to post code from a productive system.
This statement return an empty array.
I have replaced the variables with Strings and tested it with psql, but it returns one match.
Someone an idea?
Edit:
Answer From Sn0opy:
$db->exec(array("Select userid,username,section from user
WHERE section=:sectionId
AND username ILIKE '%?%'"),
array(':sectionId' => $sectionId, 1 => $queryString));
The Problem is, in Postgresql it is $1,$2,$3 and not '?' .
My Solution (thanks again to Sn0opy for his reply) :
You have to concat the the String
('%'|| :queryString || '%')
This works now :
$db->exec(array("Select userid,username,section from user
WHERE section=:sectionId
AND username ILIKE ('%'|| :queryString || '%') ),
array(':sectionId' => $sectionId, ':queryString' => $queryString));
If you don't concat the String, you will get this error :
ERROR: could not determine data type of parameter $1