Charlotte DECLERCQ wrote:
Hello,

I am trying to launch a query on a WFS layer.
The query is :
$oLayer->queryByAttributes($m_Champs, "\"".stripslashes($m_Requete)."\"", 
MS_MULTIPLE );
with $m_Champs : gid
$m_Requete : upper(gid) = upper(\'140\')

Whereas there is one record matching, mapserver can't find it : No matching 
record(s) found.

I obtain the same result with $m_Requete : gid = '140', or gid = 140, or gid = 
\'140\'

But if $m_Requete is equals to 140, then mapserver returns the element.

Any idea?

Thanks,


If $m_Requete contains a logical expression such as "gid = '140'" then you need to enclose it inside round brackets for the parser to detect that it is a logical expression. If you enclose it inside double quotes (as you did above) then it treats $m_requete as a constant that is matched against $m_champs. That's why things work when you use $m_requete = "140";

So the best fix is to use $m_requete = "140" with the queryByAttributes() statement above since constant expressions are the fastest.

However, if you want to pass a logical expression for some reason, then you should use:

$oLayer->queryByAttributes($m_Champs, "(".stripslashes($m_Requete).")", MS_MULTIPLE );

Daniel
--
Daniel Morissette
http://www.mapgears.com/
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to