PHP_Mapscript QueryByAttributes on PostGIS layer

Delfos, Jacob Jacob.Delfos at MAUNSELL.COM
Tue Oct 24 04:12:36 EDT 2006


Hi All,
 
My QueryByAttributes PostGIS problem seems to be worse in version 4.10.
In 4.8.4, at least I could do:
 
$oLayer->queryByAttributes("roadname","roadname like 'EMERALD
RD'",MS_MULTIPLE);  // must include SQL operators for query to work
 
But now, even that doesn't work anymore. It seems that it trips over the
single quotes around the value. Without the quotes, I can no longer
search on string values in a PostGIS table. What has been changed since
4.8?
 
My query does:
 
$gotResult = $oLayer->queryByAttributes("pglayer","name like 'new
layer'",MS_MULTIPLE); 
 
 
My log says:
------------ ------------ ------------ ------------ ------------
------------ ------------ ------------
[24-Oct-2006 16:08:28] PHP Warning: [MapServer Error]:
prepare_database(): Error executing POSTGIS DECLARE (the actual query)
statement: 'DECLARE mycursor BINARY CURSOR FOR SELECT
"name"::text,asbinary(force_collection(force_2d(the_geom)),'NDR'),OID::t
ext from pgpoly WHERE (name like ) and (the_geom && setSRID(
'BOX3D(-149999998.5 -99999999,149999998.5
99999999)'::BOX3D,find_srid('','pgpoly','the_geom') ))' Postgresql
reports the error as 'ERROR: syntax error at or near ")" at character
148
------------ ------------ ------------ ------------ ------------
------------ ------------ ------------
 
I'd appreciate it if someone can help me figure this out. I did not see
any bugs in Bugzilla for this.
 
regards,
 
Jacob
 
 
 


________________________________

	From: UMN MapServer Users List
[mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On Behalf Of Delfos, Jacob
	Sent: 19 September 2006 09:06
	To: MAPSERVER-USERS at LISTS.UMN.EDU
	Subject: [UMN_MAPSERVER-USERS] PHP_Mapscript QueryByAttributes
on PostGIS layer - bug or feature?
	
	

	Hi List, 

	I'm trying to perform a QueryByAttributes operation on a PostGIS
layer, but I get an error. Basically, it seems that the where clause
being generated leaves out the attribute name and operator. Am I doing
something wrong?

	My code is: 

	   $gotResult = $oLayer->queryByAttributes("roadname","EMERALD
RD",MS_MULTIPLE); 

	My PHP error is: 

	[19-Sep-2006 08:53:34] PHP Warning:  [MapServer Error]:
prepare_database(): Error executing POSTGIS DECLARE (the actual query)
statement: 'DECLARE mycursor BINARY CURSOR FOR SELECT
roadname::text,asbinary(force_collection(force_2d(the_geom)),'NDR'),gid:
:text from roads WHERE (EMERALD RD) and (the_geom && setSRID(
'BOX3D(-149999998.5 -99999999,149999998.5
99999999)'::BOX3D,find_srid('','roads','the_geom') ))' <br><br>

	It works if I do: 

	$oLayer->queryByAttributes("roadname","roadname like 'EMERALD
RD'",MS_MULTIPLE); 

	Am I supposed to perform the QueryByAttributes operation
differently for different data sources? It gets more difficult if I
don't know in advance whether the type is text or number....

	I searched the list and bugzilla for something similar, but
couldn't find it. I'm using php_mapscript 4.8.3 (I tried using
4.10beta2, but all my mapfiles get invalid map extent errors for some
reason).

	Regards, 

	Jacob 


	JACOB DELFOS
	GIS ANALYST
	Maunsell Australia Pty Ltd
	629 Newcastle Street, Leederville, WA 6007 
	PO Box 81, Leederville, WA 6902 
	Western Australia 
	ABN 20 093 846 925
	
	Tel     + 61 8 9281 6185
	Fax    + 61 8 9281 6297
	jacob.delfos at maunsell.com 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20061024/3ce559a3/attachment.html


More information about the mapserver-users mailing list