Jump to content

[help] Searh Attribute Using Querybyattributes In Phpmapscript


eko_wardoyo

Recommended Posts

i have some problem about search attribute using function querybyattributes in phpmapscript. i use postgis for search spatial data.here is the script:<?$qlayer=strtolower($_GET["qlayer"]); $qitem=strtolower($_GET["qitem"]); $qstring=strtoupper($_GET["qstring"]); $querystring=strval($qstring); if(!empty($qlayer)&&!empty($qitem)&&!empty($qstring)){ $oLayerString=$GLOBALS["map"]->getLayerByName($qlayer); $myquery=$oLayerString->queryByAttributes($qitem,$qitem."=".$querystring,MS_SINGLE); $GLOBALS["gShowQueryString"]=TRUE; } ?>and here is the error that i have got:Warning: [MapServer Error]: prepare_database(): Error declaring cursor: ERROR: syntax error at or near "NGANTANG" LINE 1: ...,'NDR'),gid::text from client WHERE (sitelink=UPJ NGANTANG) ... ^ With query string: DECLARE mycursor BINARY CURSOR FOR SELECT "sitelink"::text,asbinary(force_collection(force_2d(the_geom)),'NDR'),gid::text from client WHERE (sitelink=UPJ NGANTANG) and (the_geom && setSRID( 'BOX3D(-168.293946139 335.281286999498,1831.65709314 1834.4621130005)'::BOX3D,find_srid('','client','the_geom') )) in C:\ms4w\apps\pattindo\htdocs\btspattindo.php on line 583

Link to comment
Share on other sites

There isn't enough information there to solve that, you'll probably need to ask whoever made the map class.
i made the mapfile by myselfi have tried to query the script in shp database, its fine and there is no error but if i use postgis database i got that error
Link to comment
Share on other sites

What is $GLOBALS['map']? Is that a standard PHP class or is that a custom class? That's where the error is coming from, if you made that class yourself then you should look in the prepare_database method of the MapServer class to find the query where it's trying to declare the cursor. It looks like it's trying to use an identifier for the sitelink but it needs to be quoted or escaped somehow, the identifier has a space in it.I don't know what you mean by "mapfile", but did you write this PHP class that you're trying to use? The class definition is what contains the error.

Link to comment
Share on other sites

$GLOBALS["map"] is class of mapobject that contains function and member of mapobject but we must create the object first, for example:map=ms_newMapObj();i've solved the problem, i must add quote to variable $querystring like you've said :)i changed the script like this:$myquery=$oLayerString->queryByAttributes($qitem,$qitem."='$qstring'",MS_SINGLE);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...