<html><head></head><body><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div><div>Sven,</div><div><br></div><div>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.</div></div><br><div id="ydpa827a8b9yahoo_quoted_8452689460" class="ydpa827a8b9yahoo_quoted">
                <div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
                    
                    <div>
                        On Thursday, October 12, 2017, 8:04:46 AM CDT, Sven Schroeter <schroeter@netgis.de> wrote:
                    </div>
                    <div><br></div>
                    <div><br></div>
                    <div><div dir="ltr">Hi Steve and Carlos,<br clear="none"><br clear="none">thanks for your support. <br clear="none"><br clear="none">When I understand it correctly, I can not use the IN operator in conjunction with queryByAttributes in Mapserver 7 (mapscript) ?<br clear="none">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 clear="none">I have now tried the following and it works:<br clear="none"><br clear="none">$qstring = "([gid] = '1' || [gid] = '2' || [gid] = '4' || [gid] = '11')";<br clear="none">$query_layer->queryByAttributes("gid",$qstring,MS_MULTIPLE);<br clear="none"><br clear="none">Maybe it is possible to get the IN operator back in the future?<br clear="none"><br clear="none">Sven<br clear="none"><br clear="none"><div class="ydpa827a8b9yqt9574813846" id="ydpa827a8b9yqtfd80733"><br clear="none">Von: Lime, Steve D (MNIT) [mailto:<a shape="rect" href="mailto:steve.lime@state.mn.us" rel="nofollow" target="_blank">steve.lime@state.mn.us</a>] <br clear="none">Gesendet: Mittwoch, 11. Oktober 2017 23:33<br clear="none">An: Carlos Ruiz; <a shape="rect" href="mailto:mapserver-users@lists.osgeo.org" rel="nofollow" target="_blank">mapserver-users@lists.osgeo.org</a>; Sven Schroeter<br clear="none">Betreff: RE: RE: [mapserver-users] php Mapscript queryByAttributes<br clear="none"><br clear="none">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 clear="none"><br clear="none">Steve<br clear="none"><br clear="none">From: Carlos Ruiz [mailto:<a shape="rect" href="mailto:boolean10001@yahoo.com" rel="nofollow" target="_blank">boolean10001@yahoo.com</a>] <br clear="none">Sent: Wednesday, October 11, 2017 4:03 PM<br clear="none">To: <a shape="rect" href="mailto:mapserver-users@lists.osgeo.org" rel="nofollow" target="_blank">mapserver-users@lists.osgeo.org</a>; Sven Schroeter <<a shape="rect" href="mailto:schroeter@netgis.de" rel="nofollow" target="_blank">schroeter@netgis.de</a>>; Lime, Steve D (MNIT) <<a shape="rect" href="mailto:steve.lime@state.mn.us" rel="nofollow" target="_blank">steve.lime@state.mn.us</a>><br clear="none">Subject: Re: RE: [mapserver-users] php Mapscript queryByAttributes<br clear="none"><br clear="none">Hey Steve,<br clear="none"><br clear="none">> 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 clear="none"><br clear="none">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 clear="none"><br clear="none">> This is close, it’s a logical expression but you’re comparing a number against a string. It should be <br clear="none">> queryByAttributes("municipio", "(‘[municipio]’ LIKE 'G%')", MS_MULTIPLE);<br clear="none"><br clear="none">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 clear="none"><br clear="none">Maybe this happens because the MS4W version (3.1.3) with Mapserver CGI 7.0.1<br clear="none"><br clear="none"><br clear="none">On Wednesday, October 11, 2017, 2:31:41 PM CDT, Lime, Steve D (MNIT) <<a shape="rect" href="mailto:steve.lime@state.mn.us" rel="nofollow" target="_blank">steve.lime@state.mn.us</a>> wrote: <br clear="none"><br clear="none"><br clear="none">The query syntax is given in MapServer expression syntax. I think there’s a logical expression for why you’re seeing these results:<br clear="none"> <br clear="none">  queryByAttributes("gid", "gid > 100", MS_MULTIPLE) // does not found anything<br clear="none"> <br clear="none">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 clear="none">  queryByAttributes("gid", "100", MS_MULTIPLE) // found one result<br clear="none"> <br clear="none">is evaluated as gid = 100 which makes sense.<br clear="none"> <br clear="none">  queryByAttributes("municipio", "'GUADALAJARA'", MS_MULTIPLE) // found one result<br clear="none"> <br clear="none">is evaluated as municipio = GUADALAJARA which makes sense. I don’t think you need the interior quotes around GUADALAJARA though.<br clear="none"> <br clear="none">  queryByAttributes("municipio", "municipio LIKE 'G%'", MS_MULTIPLE) // does not found anything<br clear="none"> <br clear="none">like the first example this evaluates as municipio = "municipio LIKE 'G%'", not what you want. See below…<br clear="none"> <br clear="none">  queryByAttributes("gid", "([gid] IN (100, 101))", MS_MULTIPLE); // query error<br clear="none"> <br clear="none">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 clear="none"> <br clear="none">  queryByAttributes("municipio", "([municipio] LIKE 'G%')", MS_MULTIPLE); // query error<br clear="none"> <br clear="none">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 clear="none"> <br clear="none">Steve<br clear="none"> <br clear="none">From: mapserver-users [mailto:<a shape="rect" href="mailto:mapserver-users-bounces@lists.osgeo.org" rel="nofollow" target="_blank">mapserver-users-bounces@lists.osgeo.org</a>] On Behalf Of Carlos Ruiz<br clear="none">Sent: Wednesday, October 11, 2017 1:36 PM<br clear="none">To: <a shape="rect" href="mailto:mapserver-users@lists.osgeo.org" rel="nofollow" target="_blank">mapserver-users@lists.osgeo.org</a>; Sven Schroeter <<a shape="rect" href="mailto:schroeter@netgis.de" rel="nofollow" target="_blank">schroeter@netgis.de</a>><br clear="none">Subject: Re: [mapserver-users] php Mapscript queryByAttributes<br clear="none"> <br clear="none">Sven,<br clear="none"> <br clear="none">Doing some tests, queryByAttributes does not accept LIKE nor IN, just single values or simple operators (I am using PostGIS).<br clear="none"> <br clear="none">queryByAttributes("gid", "gid > 100", MS_MULTIPLE) // does not found anything<br clear="none">queryByAttributes("gid", "100", MS_MULTIPLE) // found one result<br clear="none">queryByAttributes("municipio", "'GUADALAJARA'", MS_MULTIPLE) // found one result<br clear="none">queryByAttributes("municipio", "municipio LIKE 'G%'", MS_MULTIPLE) // does not found anything<br clear="none">queryByAttributes("gid", "([gid] IN (100, 101))", MS_MULTIPLE); // query error<br clear="none">queryByAttributes("municipio", "([municipio] LIKE 'G%')", MS_MULTIPLE); // query error<br clear="none">queryByAttributes("gid", "([gid] > 100)", MS_MULTIPLE); // found 25 results<br clear="none"> <br clear="none">MS4W version is 3.1.3<br clear="none"> <br clear="none">Try to solve it by using FILTER, which allows more complex expressions:<br clear="none"> <br clear="none">$layer->setFilter("gid IN (100, 101)");<br clear="none"> <br clear="none"> <br clear="none">Cheers<br clear="none"> <br clear="none">On Wednesday, October 11, 2017, 10:55:17 AM CDT, Sven Schroeter <<a shape="rect" href="mailto:schroeter@netgis.de" rel="nofollow" target="_blank">schroeter@netgis.de</a>> wrote: <br clear="none"> <br clear="none"> <br clear="none">Hi,<br clear="none"> <br clear="none">Old Server: PHP 5.4.36 with MS 6.4.1 (MS4W)<br clear="none">New Server: PHP 5.6.31 with MS 7.0.6 (MS4W 3.2.2)<br clear="none"> <br clear="none">My Test Script:<br clear="none"> <br clear="none">$qfield = 'gid';<br clear="none">$qstring = "gid IN (1,2,3)";<br clear="none">@$datQuery = $query_layer->queryByAttributes($qfield,$qstring,MS_MULTIPLE);<br clear="none"> <br clear="none">Works fine on the old Server, on the new Server no result.<br clear="none"> <br clear="none">I have tried to change the query expression, i.e.:<br clear="none">$qstring = "('[gid]' in '1,2,3')";<br clear="none"> <br clear="none">No result on old server and new...<br clear="none"> <br clear="none">How can I get it run on MS7?<br clear="none"> <br clear="none"> <br clear="none"> <br clear="none">Thanks + greetings <br clear="none">Sven <br clear="none"> <br clear="none"> <br clear="none"> <br clear="none">**************************************<br clear="none">NETGIS GbR<br clear="none">Benediktinerstr. 32a<br clear="none">54292 Trier<br clear="none">Tel.: 0651-1704731<br clear="none">Fax: 0651-1704733<br clear="none"><a shape="rect" href="mailto:schroeter@netgis.de" rel="nofollow" target="_blank">schroeter@netgis.de</a><br clear="none">www.netgis.de<br clear="none"> <br clear="none"> <br clear="none">_______________________________________________<br clear="none">mapserver-users mailing list<br clear="none"><a shape="rect" href="mailto:mapserver-users@lists.osgeo.org" rel="nofollow" target="_blank">mapserver-users@lists.osgeo.org</a><br clear="none"><a shape="rect" href="https://lists.osgeo.org/mailman/listinfo/mapserver-users" rel="nofollow" target="_blank">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br clear="none"></div></div></div>
                </div>
            </div></div></body></html>