<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Ticket is
<a href="https://github.com/mapserver/mapserver/issues/5490">https://github.com/mapserver/mapserver/issues/5490</a>... --Steve<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Carlos Ruiz [mailto:boolean10001@yahoo.com]
<br>
<b>Sent:</b> Thursday, October 12, 2017 12:55 PM<br>
<b>To:</b> Lime, Steve D (MNIT) <steve.lime@state.mn.us>; mapserver-users@lists.osgeo.org; Sven Schroeter <schroeter@netgis.de><br>
<b>Subject:</b> Re: AW: RE: [mapserver-users] php Mapscript queryByAttributes<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif">Sven,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif">This is a good workarround. It's weird why the IN operator is not working for Postgres but as Steve wrote, a ticket will be opened.<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
<div id="ydpa827a8b9yahoo_quoted_8452689460">
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">On Thursday, October 12, 2017, 8:04:46 AM CDT, Sven Schroeter <<a href="mailto:schroeter@netgis.de">schroeter@netgis.de</a>> wrote:
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Hi Steve and Carlos,<br>
<br>
thanks for your support. <br>
<br>
When I understand it correctly, I can not use the IN operator in conjunction with queryByAttributes in Mapserver 7 (mapscript) ?<br>
I use this function so far for the transfer of different IDs (whether integer or string) to read out a subset of POSTGIS tables.<br>
I have now tried the following and it works:<br>
<br>
$qstring = "([gid] = '1' || [gid] = '2' || [gid] = '4' || [gid] = '11')";<br>
$query_layer->queryByAttributes("gid",$qstring,MS_MULTIPLE);<br>
<br>
Maybe it is possible to get the IN operator back in the future?<br>
<br>
Sven<o:p></o:p></span></p>
<div id="ydpa827a8b9yqtfd80733">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><br>
Von: Lime, Steve D (MNIT) [mailto:<a href="mailto:steve.lime@state.mn.us" target="_blank">steve.lime@state.mn.us</a>]
<br>
Gesendet: Mittwoch, 11. Oktober 2017 23:33<br>
An: Carlos Ruiz; <a href="mailto:mapserver-users@lists.osgeo.org" target="_blank">
mapserver-users@lists.osgeo.org</a>; Sven Schroeter<br>
Betreff: RE: RE: [mapserver-users] php Mapscript queryByAttributes<br>
<br>
Ugh, my bad. At least with the LIKE operator it’s because MapServer doesn’t support it. Using a regex should work depending on your back-end. Which reminds me, which backend are you using? I need to investigate the IN operator. It maybe that I can come up with
 a work around for Sven using the native SQL that worked previously since that can still be set as a processing option. Will report back…<br>
<br>
Steve<br>
<br>
From: Carlos Ruiz [mailto:<a href="mailto:boolean10001@yahoo.com" target="_blank">boolean10001@yahoo.com</a>]
<br>
Sent: Wednesday, October 11, 2017 4:03 PM<br>
To: <a href="mailto:mapserver-users@lists.osgeo.org" target="_blank">mapserver-users@lists.osgeo.org</a>; Sven Schroeter <<a href="mailto:schroeter@netgis.de" target="_blank">schroeter@netgis.de</a>>; Lime, Steve D (MNIT) <<a href="mailto:steve.lime@state.mn.us" target="_blank">steve.lime@state.mn.us</a>><br>
Subject: Re: RE: [mapserver-users] php Mapscript queryByAttributes<br>
<br>
Hey Steve,<br>
<br>
> the IN operator works off a delimited list, try queryByAttributes("gid", "([gid] IN ‘100,101’)", MS_MULTIPLE);. Any whitespace > is considered part of the tokens in a list.<br>
<br>
I have tried this and it doesn't work. There's a query error because Mapserver try to add the following: and ("gid"'100,101')<br>
<br>
> This is close, it’s a logical expression but you’re comparing a number against a string. It should be
<br>
> queryByAttributes("municipio", "(‘[municipio]’ LIKE 'G%')", MS_MULTIPLE);<br>
<br>
I have tried this and it doesn't work. There's a query error because Mapserver try to add the following: and ("municipio"::text'G%')<br>
<br>
Maybe this happens because the MS4W version (3.1.3) with Mapserver CGI 7.0.1<br>
<br>
<br>
On Wednesday, October 11, 2017, 2:31:41 PM CDT, Lime, Steve D (MNIT) <<a href="mailto:steve.lime@state.mn.us" target="_blank">steve.lime@state.mn.us</a>> wrote:
<br>
<br>
<br>
The query syntax is given in MapServer expression syntax. I think there’s a logical expression for why you’re seeing these results:<br>
<br>
  queryByAttributes("gid", "gid > 100", MS_MULTIPLE) // does not found anything<br>
<br>
is evaluated as gid = “gid > 100”. Valid but not what you’re looking for. Your last example is the right way to do it - queryByAttributes("gid", "([gid] > 100)", MS_MULTIPLE);. If MapServer sees the qstring is a logical expression then it ignores the qitem.<br>
  queryByAttributes("gid", "100", MS_MULTIPLE) // found one result<br>
<br>
is evaluated as gid = 100 which makes sense.<br>
<br>
  queryByAttributes("municipio", "'GUADALAJARA'", MS_MULTIPLE) // found one result<br>
<br>
is evaluated as municipio = GUADALAJARA which makes sense. I don’t think you need the interior quotes around GUADALAJARA though.<br>
<br>
  queryByAttributes("municipio", "municipio LIKE 'G%'", MS_MULTIPLE) // does not found anything<br>
<br>
like the first example this evaluates as municipio = "municipio LIKE 'G%'", not what you want. See below…<br>
<br>
  queryByAttributes("gid", "([gid] IN (100, 101))", MS_MULTIPLE); // query error<br>
<br>
the IN operator works off a delimited list, try queryByAttributes("gid", "([gid] IN ‘100,101’)", MS_MULTIPLE);. Any whitespace is considered part of the tokens in a list.<br>
<br>
  queryByAttributes("municipio", "([municipio] LIKE 'G%')", MS_MULTIPLE); // query error<br>
<br>
This is close, it’s a logical expression but you’re comparing a number against a string. It should be queryByAttributes("municipio", "(‘[municipio]’ LIKE 'G%')", MS_MULTIPLE);<br>
<br>
Steve<br>
<br>
From: mapserver-users [mailto:<a href="mailto:mapserver-users-bounces@lists.osgeo.org" target="_blank">mapserver-users-bounces@lists.osgeo.org</a>] On Behalf Of Carlos Ruiz<br>
Sent: Wednesday, October 11, 2017 1:36 PM<br>
To: <a href="mailto:mapserver-users@lists.osgeo.org" target="_blank">mapserver-users@lists.osgeo.org</a>; Sven Schroeter <<a href="mailto:schroeter@netgis.de" target="_blank">schroeter@netgis.de</a>><br>
Subject: Re: [mapserver-users] php Mapscript queryByAttributes<br>
<br>
Sven,<br>
<br>
Doing some tests, queryByAttributes does not accept LIKE nor IN, just single values or simple operators (I am using PostGIS).<br>
<br>
queryByAttributes("gid", "gid > 100", MS_MULTIPLE) // does not found anything<br>
queryByAttributes("gid", "100", MS_MULTIPLE) // found one result<br>
queryByAttributes("municipio", "'GUADALAJARA'", MS_MULTIPLE) // found one result<br>
queryByAttributes("municipio", "municipio LIKE 'G%'", MS_MULTIPLE) // does not found anything<br>
queryByAttributes("gid", "([gid] IN (100, 101))", MS_MULTIPLE); // query error<br>
queryByAttributes("municipio", "([municipio] LIKE 'G%')", MS_MULTIPLE); // query error<br>
queryByAttributes("gid", "([gid] > 100)", MS_MULTIPLE); // found 25 results<br>
<br>
MS4W version is 3.1.3<br>
<br>
Try to solve it by using FILTER, which allows more complex expressions:<br>
<br>
$layer->setFilter("gid IN (100, 101)");<br>
<br>
<br>
Cheers<br>
<br>
On Wednesday, October 11, 2017, 10:55:17 AM CDT, Sven Schroeter <<a href="mailto:schroeter@netgis.de" target="_blank">schroeter@netgis.de</a>> wrote:
<br>
<br>
<br>
Hi,<br>
<br>
Old Server: PHP 5.4.36 with MS 6.4.1 (MS4W)<br>
New Server: PHP 5.6.31 with MS 7.0.6 (MS4W 3.2.2)<br>
<br>
My Test Script:<br>
<br>
$qfield = 'gid';<br>
$qstring = "gid IN (1,2,3)";<br>
@$datQuery = $query_layer->queryByAttributes($qfield,$qstring,MS_MULTIPLE);<br>
<br>
Works fine on the old Server, on the new Server no result.<br>
<br>
I have tried to change the query expression, i.e.:<br>
$qstring = "('[gid]' in '1,2,3')";<br>
<br>
No result on old server and new...<br>
<br>
How can I get it run on MS7?<br>
<br>
<br>
<br>
Thanks + greetings <br>
Sven <br>
<br>
<br>
<br>
**************************************<br>
NETGIS GbR<br>
Benediktinerstr. 32a<br>
54292 Trier<br>
Tel.: 0651-1704731<br>
Fax: 0651-1704733<br>
<a href="mailto:schroeter@netgis.de" target="_blank">schroeter@netgis.de</a><br>
<a href="http://www.netgis.de">www.netgis.de</a><br>
<br>
<br>
_______________________________________________<br>
mapserver-users mailing list<br>
<a href="mailto:mapserver-users@lists.osgeo.org" target="_blank">mapserver-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/mapserver-users" target="_blank">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a><o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>