This topic is locked

Using mysql function calls in EDIT via $values

6/24/2009 6:48:21 AM
PHPRunner General questions
M
marke author

Hi Jane
I am using mySQL function calls (e.g. GeomFromText) to convert a string into a geometry object in the database.
To do this I use an EDIT event - Before Update - to modify the $values['field'] that will be updated and remove the temporary text version of the field. Something like:

$values['gridNorthPole']="GeomFromText('".$values['textgridvalue']."')";

unset($values['textgridvalue'];


unfortunately when this is concatenated into the sql string it appears as:

update tbltest set description='xyz', gridPoleNorth='GeomFromText(\'POINT(4 7)\')' where id=6


The problem is the quote immediately before GeomFromText - mysql doesn't recognise this as a function call and throws an error; remove the outer quotes and it works fine.
Is there any way for me to use the $values array to include mysql variables - OR - can I get at the final UPDATE sql statement to strip out quotes around the function calls before the query is applied.
thanks
Mark

J
Jane 6/24/2009

Mark,
unfortunately you can use After record added event to update this field manually using MySQL function.