Question on queryByAttributes - multiple fields

Sean Gillies sgillies at FRII.COM
Mon Nov 29 16:21:15 PST 2004


On Nov 29, 2004, at 4:55 PM, Cord Thomas wrote:

> Hello all
>
> Using MapServer 4.4x and Perl Mapscript on Linux against a PostGIS
> database, i am having difficulty with the queryByAttributes method on a
> polygon layer.
>
> I include my MAP snippet below, but basically, my code is this:
>
>   my $res = $mapLayer->queryByAttributes($map, $qryFlds,
>                                          $qryVals,
> $mapscript::MS_MULTIPLE);
>
> where $qryFlds = "stateid,name"
> and   $qryVals = "(stateid='ME' and name='Knox')"
>
> Is this the valid way to specify multiple fields - how can i get
> mapserver
> to dump the full query string to the log file?  i have a log file
> setup,
> and if i screw up the query string, it throws an error, but these
> criteria
> are right and mapserver reports this:
>
> - msQueryByAttributes(): Search returned no results. No matching
> record(s)
> found.
>
> thanks in advance
>

Thomas,

The query mode argument (MS_MULTIPLE) refers to how many *results* you
want, not how many attributes.  You can only query by one attribute
at a time, the method should have been named "queryByAttribute" singular
not plural.  I don't know the history of the name.

Adam Ryan has this trick he uses to AND attribute queries.  It involves
making a query, then saving it to a file with 'saveQuery', making a new
query and then adding the results from the saved query using
queryByIndex.

Maybe he'll see this thread and explain.

Thanks for trying out the 4.4 beta.  What do you think so far?  Are the
mapscript docs under mapscript/doc helpful?  In the final 4.4.0 release
there will be three HOWTOs: imagery, querying, and mapfile.

cheers,
Sean



More information about the MapServer-users mailing list