2

I've got two scenarios, using the following statement:

 INSERT INTO areas (name, polygon) VALUES (?, POLYGON(?,?,?,?,?,?))

Will result in errors like this:

Illegal non geometric ''58.03665463092348 14.974815566795314'' value found during parsing

What seems to be the problem here is that my lat and longitudes are quoted as texts within the POLYGON().

However,according to the WKT format I need another set of () in my statement:

  INSERT INTO areas (name, polygon) VALUES (?, POLYGON((?,?,?,?,?,?)))

which will only result in the following error:

 Operand should contain 1 column(s)

I'm at a loss here, how do I use prepared statements along with mysql spatial information?

Rachel Gallen
  • 27,943
  • 21
  • 72
  • 81
Bisa
  • 154
  • 1
  • 1
  • 9
  • Turns out if I simply toss everything into a query without first preparing a statement (not even escaping the values) it works like a charm... but I really want to escape the input since it is user generated, any hints as of why I cannot escape the lat/longitude data? – Bisa Oct 02 '11 at 13:10
  • It would help to see the table's schema. – octopusgrabbus Oct 02 '11 at 15:17
  • It's a simple polygon column along with a spatial index: CREATE TABLE `areas` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(45) COLLATE utf8_bin DEFAULT NULL, `polygon` polygon NOT NULL, PRIMARY KEY (`id`), SPATIAL KEY `spatial` (`polygon`) ) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COLLATE=utf8_bin$$ – Bisa Oct 02 '11 at 18:01

0 Answers0