[mapserver-users] MAPSCRIPT - queryByAttributes on WFS layer

Charlotte DECLERCQ c.declercq at alkante.com
Wed Jan 6 03:07:43 EST 2010


Hello Daniel and thanks for the quick answer.

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

doesn't seem to work with $m_Requete : upper(gid) = upper(\'140\').

Is it possible to do some comparison like gid > 140 ... on a WFS layer?
I know it is possible on other types of layers.

-- 
Charlotte DECLERCQ

ALKANTE SAS
Ingénieur R&D SIG
1, rue du Chêne Morand
35 510 Cesson-Sévigné
Bur: + 33 (0) 2 99 22 25 70
fax : + 33 (0) 2 99 32 12 76

----- Mail Original -----
De: "Daniel Morissette" <dmorissette at mapgears.com>
À: mapserver-users at lists.osgeo.org
Envoyé: Mardi 5 Janvier 2010 17:10:28
Objet: Re: [mapserver-users] MAPSCRIPT - queryByAttributes on WFS layer

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
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users





More information about the mapserver-users mailing list