Question on queryByAttributes - multiple fields
Eduin Carrillo
yecarrillo at YAHOO.COM
Tue Nov 30 14:57:46 PST 2004
This is my code snipped for Php/MapScript. I sent it previously, but cant find
it:
Make queries as index.php?QATTLAYER=mylayer&QATTFIELD=myfield&QATTSTRING=value
It works for this queries like "myfield=value"
QATTFIELD=myfield
QATTSTRING=value
But can't figure how make it work for queries like "myfield=value AND
otherfield=othervalue"
Note that queries are saved for future use and a cookie is set to show the same
queried shapes in the next screen.
$mapPrefix = "mymap_"
//===================
//QUERY BY ATTRIBUTES
//===================
if (strlen($_REQUEST['QATTLAYER']) > 0 and
strlen($_REQUEST['QATTFIELD']) > 0 and
strlen($_REQUEST['QATTSTRING']) > 0) {
mt_srand((double)microtime()*1000000);
$qfn = mt_rand() . ".gix";
//Query in all map extension
$mapMinXTmp = floatval($oMap->extent->minx);
$mapMinYTmp = floatval($oMap->extent->miny);
$mapMaxXTmp = floatval($oMap->extent->maxx);
$mapMaxYTmp = floatval($oMap->extent->maxy);
$oMap->setextent($mapMinX0, $mapMinY0, $mapMaxX0, $mapMaxY0);
$qLayer = $oMap->getLayerByName(stripslashes($_REQUEST['QATTLAYER']));
//Do query, prevent showing errors
$qresult =
@$qLayer->queryByAttributes(stripslashes($_REQUEST['QATTFIELD']),
stripslashes($_REQUEST['QATTSTRING']),
MS_MULTIPLE);
//Restore previous extent
$oMap->setextent($mapMinXTmp, $mapMinYTmp, $mapMaxXTmp, $mapMaxYTmp);
//Save query for future use
if ($qresult == MS_SUCCESS) {
$successQuery = TRUE;
@$oMap->savequery(strval($oMap->web->imagepath) . $qfn);
setcookie($mapPrefix . "_QFILE", $qfn);
} else {
setcookie($mapPrefix . "_QFILE", '');
}
}
=====
Eduin Yesid Carrillo Vega
yecarrillo at yahoo.com
COLOMBIA
_________________________________________________________
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com
More information about the MapServer-users
mailing list