[Mapserver-users] Problem with setFilter
Daniel Morissette
morissette at dmsolutions.ca
Wed Jul 2 19:52:39 PDT 2003
I didn't think you needed the quotes around the [STATE] field name. Did
you try removing the quotes around the field name? e.g.
$oLayer->setFilter("([STATE] = 'ITALY')");
Daniel
Andrea Albano wrote:
>
> Hello everyone.
>
> I have a strange problem in using setFilter function in PHP-Mapscript 3.6.
> I am trying to build an interface that allow the user to set a filter for
> every layer of a Map: a simple html page help the user to build the filter
> expression, then this expression is saved in METADATA section of this layer
> in a entry called FILTER_EXPR:
>
> $oLayer->setMetaData("FILTER_EXPR", $szFiltExp);
>
> Then, before drawing the map, I loop through all the layers and check if the
> current layer have a filter; if so i retrive it:
>
> $szFiltExp1 = $oLayer->getMetaData("FILTER_EXPR");
>
> With this variable, that represent my filter expression, I try to filter the
> layer:
>
> $oLayer->setFilter($szFiltExp1);
> (here
> var_dump($szFiltExp1) ;
> return string(19) "('[STATE]'='ITALY')" and this seems correct!)
>
> But this NEVER WORKS!!! The layer will be empty!!!
> And almost incredible... if I explicitly set the exactly same string via
> code.. WORKS!!!
>
> $szFiltExp2 = "('[STATE]'='ITALY')";
> $oLayer->setFilter($szFiltExp2);
>
> I've tried almost everything:
> string function like eval, var_export, stripslashes,...
> other syntax: like $oLayer->setFilter("\"$szFiltExp1\"");
> single quote string like '(\'[STATE]\'=\'ITALY\')';
> but nothing, nothing, nothing...
>
> Where is the problem: PHP or mapscript setFilter?
> And how really treat his parameter the setFilter function?
>
> Thanks in advance.
> Andrea Albano
>
> PS : sorry for my poor english!
>
More information about the MapServer-users
mailing list