[mapserver-users] Fwd: setfilter

Daniel Morissette morissette at dmsolutions.ca
Fri Mar 22 14:46:32 PST 2002


> From: Patricio Gigoux <pgigoux at munistgo.cl>
> 
> I have tested it from map file and no problem, but when I had tried from PHP
> file give me troubles or better said have displayed nothing. I have used the
> next whitout success:
> layer->setfilter("CAMPO='$var'");
> 

I believe the correct syntax would be:
 
 $layer->setFilter("([CAMPO]='$var')");

You need:
 - Square brackets around field names
 - Parenthesis around the expression to indicate that it's a logical
   expression.

Note that since you're evaluating a single attribute value, then using a
constant expression instead of a logical expression would be more
efficient:

  $layer->set("filteritem", "CAMPO");
  $layer->setFilter( "\"$var\"" );

-- 
------------------------------------------------------------
 Daniel Morissette               morissette at dmsolutions.ca
 DM Solutions Group              http://www.dmsolutions.ca/
------------------------------------------------------------
  Don't put for tomorrow what you can do today, because if 
      you enjoy it today you can do it again tomorrow.



More information about the MapServer-users mailing list