multiple field query

Steve Lime Steve.Lime at DNR.STATE.MN.US
Mon Jul 17 14:51:25 PDT 2006


You can create multiple field queries, it's just a matter of getting the query string right, much like
getting SQL right I guess except that might be easier ;-)...

Two things to remember:

  - in MapServer ' = ", you can quote strings with either (in pairs)
  - strings *must* be quoted on both sides of the operand

So:

  $qstring="([CARF_T]=$acarf OR '[CARF_A]'=$acarf)" ;

should probably be:

  $qstring = "('[CARF_T]'='$acarf' OR '[CARF_A]'='$acarf')" ;

Steve

Stephen Lime
Data & Applications Manager

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-259-5473

>>> Blaise <bpicinbono at WORLDONLINE.FR> 7/17/2006 3:38:53 PM >>>
hi there
I've searched a bit in the archives but I can't figure it out.
I am able to query an single field of a dbf table this way :

$amteacarf=42;
$qLayer=$zeMap->getLayerByName("metacarflink");
$result=@$qLayer->queryByAttributes("METACARF",$ametacarf,MS_MULTIPLE);
$res_count = $qLayer->getnumresults();

Now I would like to query a layer for (one field = something) OR (another 
field = something)
I tryed this way :

$qLayer=$zeMap->getLayerByName("tron");
$qstring="([CARF_T]=$acarf OR '[CARF_A]'=$acarf)" ;
$result=@$qLayer->queryByAttributes('CARF_T',$qstring,MS_MULTIPLE);
$res_count = $qLayer->getnumresults();

I tryed different syntaxes but I am a bit lost with single and double quote 
and the right syntax.
For now, I am stuck with processing a double query, which might be more time 
consuming.
Anyone can help, please ?
Thanks
Blaise



More information about the MapServer-users mailing list