[mapserver-users] Fwd: setfilter

Patricio Gigoux pgigoux at munistgo.cl
Mon Mar 25 09:06:48 EST 2002


El Vie 22 Mar 2002 18:46, Daniel Morissette escribió:
> > 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\"" );


Thank you

my filter is ready, but it work with:
$layer->setFilter("([CAMPO]=$var)");





More information about the mapserver-users mailing list