[postgis-users] Quote problem in query

Stefan Schwarzer stefan.schwarzer at grid.unep.ch
Mon Apr 24 04:59:37 PDT 2006


Hi there,

I just ran into a problem where I can't see and find a way out...

In a php file I have the command (writing the .map file for mapserver  
dynamically):

	fwrite($fp, "DATA 'the_geom FROM (SELECT ");

	fwrite($fp, $complex_selection." WHERE table.id = other_table.id) AS  
foo USING UNIQUE uid USING srid=-1' ");

Now, I would like to add another WHERE clause, like

	... AND table.name = 'Algeria'

But then I ran into the problem that I have two time the apostrophe,  
so the query get's actually truncated at this point:

	fwrite($fp, "DATA 'the_geom FROM (SELECT ");

	fwrite($fp, $complex_selection." WHERE table.id = other_table.id AND  
table.name = '

Error message naturally then.

Is there any way to use magic quotes or something similar to "mimic"  
the apostrophe for the country name clause?

Thanks for any hints.





More information about the postgis-users mailing list