This topic is locked
[SOLVED]

 Handling of MySQL GEOMETRY objects

6/22/2009 7:54:14 AM
PHPRunner General questions
R
rockdoc author

Hi,
I'm trying to code an edit page to display and update a MySQL geometry column of type POINT. For the purposes of this discussion we'll assume the column in my table is called 'geom'.
To display the POINT column on the edit page in a human-readable manner I include the incantation 'AsText(geom) as geomText' in my defining SQL query. This displays the point value in the format 'POINT(10 20)'.
Based on the above SQL query, within my Before Record Update event I can refer to $values['geom'] and $values['geomText'], using the latter to update the former, e.g.
.")";

$unset($values['geomText']);
NB: The AsText() and GeomFromText() functions are standard MySQL functions for converting from a geometry object to text and back again.
However, the aforementioned code snippet fails with the message:
"Cannot get geometry object from data you send to the GEOMETRY field"
which seems to suggest that PHPRunner is expecting to assign a geometry-valued object to $values['geom'], rather than the SQL string shown above (which should generate a geometry object if it's executed).
Is it possible to add/update MySQL geometry objects using PHPRunner? If so, where am I going wrong?
Thanks in advance,
Phil

J
Jane 6/24/2009

Hi,
I recommend you to use After record updated event for this purpose.

Here is a sample:

global $conn;

$update = "update tablename set ...";

db_exec($update,$conn);