<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:mv="http://macVmlSchemaUri" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@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:Calibri;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:Calibri;
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-compose;
        font-family:Calibri;
        color:windowtext;}
span.msoIns
        {mso-style-type:export-only;
        mso-style-name:"";
        text-decoration:underline;
        color:teal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        font-family:Calibri;}
@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="1027"/>
</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 bgcolor="white" lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">I cannot get the IN operator to work with queryByAttributes in the new version of php_mapscript. I see nothing obvious mentioned in the migration guide and have found no examples in the documentation on the
 syntax expected by Mapserver 7.0.2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The following queryByAttribute using an IN clause worked with MapServer version 6.4.2.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt">queryByAttributes(site_id,(site_id IN (4243,4468,3142)),MS_MULTIPLE);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The following select was created.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt">msPostGISLayerWhichShapes query: select "site_id","county","station_location","longitude","latitude","status",encode(ST_AsBinary(ST_Force2D("the_geom"),'NDR'),'hex') as geom,"site_id"
 from (select p.site_id,p.the_geom,p.county,p.station_location, p.longitude,p.latitude,p.status from precip.station p) as foo where the_geom && ST_GeomFromText('POLYGON((1026879.66418811 54774.2883737648,1026879.66418811 1331032.73787942,2999091.34586756 1331032.73787942,2999091.34586756
 54774.2883737648,1026879.66418811 54774.2883737648))',2266) and (site_id IN (4243,4468,3142))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The same queryByAttribute as above fails with Mapserver version 7.0.2 and listed below is the select statement that is created.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt">msPostGISLayerWhichShapes query: select "site_id","county","station_location","longitude","latitude","status",encode(ST_AsBinary(ST_Force2D("the_geom"),'NDR'),'hex') as geom,"site_id"
 from (select p.site_id,p.the_geom,p.county,p.station_location, p.longitude,p.latitude,p.status from precip.station p) as foo where the_geom && ST_GeomFromText('POLYGON((1026879.66418811 54774.2883737648,1026879.66418811 1331032.73787942,2999091.34586756 1331032.73787942,2999091.34586756
 54774.2883737648,1026879.66418811 54774.2883737648))',2266) and ((4243.000000,4468.000000,3142.000000))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The select statement created by 7.0.2 is incorrect with the parameters that I passed in in the previous version.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Specifically, the final and of the where clause went from 'and (site_id IN (4243,4468,3142))' to 'and ((4243.000000,4468.000000,3142.000000))'.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I then tried to figure out the correct syntax of a mapserver expressions and added brackets around the parameter.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt">queryByAttributes(site_id,([site_id] IN (4243,4468,3142)),MS_MULTIPLE);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">This gave the following select statement.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt">msPostGISLayerWhichShapes query: select "site_id","county","station_location","longitude","latitude","status",encode(ST_AsBinary(ST_Force2D("the_geom"),'NDR'),'hex') as geom,"site_id"
 from (select p.site_id,p.the_geom,p.county,p.station_location, p.longitude,p.latitude,p.status from precip.station p) as foo where the_geom && ST_GeomFromText('POLYGON((1026879.66418811 54774.2883737648,1026879.66418811 1331032.73787942,2999091.34586756 1331032.73787942,2999091.34586756
 54774.2883737648,1026879.66418811 54774.2883737648))',2266) and ("site_id"(4243.000000,4468.000000,3142.000000))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Now the where clause looks like ("site_id"(4243.000000,4468.000000,3142.000000)). This is close but the IN disappears between site_id and the list of values.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The only way I can get this to work is to use a regular expression. This seems like a work around since an integer field is being cast as text in order to do a regular expression.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt">queryByAttributes(site_id,([site_id] ~* "^(4243|4468|3142)$"),MS_MULTIPLE);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Resulting select statement.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt">msPostGISLayerWhichShapes query: select "site_id","county","station_location","longitude","latitude","status",encode(ST_AsBinary(ST_Force2D("the_geom"),'NDR'),'hex') as geom,"site_id"
 from (select p.site_id,p.the_geom,p.county,p.station_location, p.longitude,p.latitude,p.status from precip.station p) as foo where the_geom && ST_GeomFromText('POLYGON((1026879.66418811 54774.2883737648,1026879.66418811 1331032.73787942,2999091.34586756 1331032.73787942,2999091.34586756
 54774.2883737648,1026879.66418811 54774.2883737648))',2266) and ("site_id"::text ~* '^(4243|4468)$')<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">How do I properly format the query string for queryByAttributes to search for an attribute using a where in clause?  Is the regular expression approach the only way to accomplish the search? 
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Thanks for the help,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Paul<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">  <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
</body>
</html>