On 03/07/2009 14:47, Zafkiel ... wrote: > Hello, > > I'm trying to add a search function for a layer, using the <searchitem> node. > I've already got some layers with that search implemented and it works fine. > > Here's the searchitem i've added : > <searchitem name="Boats" description="Boats"> > <layer type="postgis" name="Boats"> > <field type="n" name="boat_id" description="Boat id" > wildcard="0" /> > <field type="s" name="boat_name" description="Boat name > wildcard="0"/> > </layer> > </searchitem> > > Here's the data used for this layer (using Mapscript) : > $layer->set("data", "geom FROM (SELECT * FROM boat_position AS p WHERE p.date > = (SELECT max(c.date) FROM coord_boats AS c WHERE c.date <= '$date' AND > c.boat_id = p.boat_id)) as foo using unique boat_id using srid=27582"); > > > boat_position is a view where I join data from 'boats' table (id, name...) > with their coordinates from 'coord_boats' table (geom, date, angle...) > The result is the position of the boats which is the closest to the date > specified with the $date variable. The date is set with a slider that I've > put in the south Layout. > > This layer is drawn fine by pmapper, and the request works fine when I test > it on phpPgAdmin. But the search won't work. I've done many tests and it > seems that the searchitem can't work with postgis data using a SELECT > embedded in a WHERE... > Strangely, the toolbar works fine (you can identify the boats with the > identify button of the toolbar). Only the searchitem doesn't work. The search > works if I replace the select embedded in the where statement by a random > date. > > Anyone has an idea on how to solve this problem ? >
You are missing half of the story to tell... It looks like somewhere in the code you specify an update of the layer definition via Mapscript. Where, and how it reads the $date, who knows. All of these modifications have to be applied on the map object for all sorts of functions that should be aware of it. Identify uses standard functions of Mapscript also for Postgis layers, therefore it might work. For attribute searches on Postgis layers there is a special PGQuery class in squery.php. You have to ensure that your modifications to the map/layer object with the $date is also available there. Armin ------------------------------------------------------------------------------ _______________________________________________ pmapper-users mailing list pmapper-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pmapper-users