UPDATE Sector SET start = ST_GeomFromText( ' POINT ( -4.75513748886666 58.2553702983331 ) ', 4326 ), end = ST_GeomFromText( ' POINT ( -4.67682813534559 58.3335955352018 ) ', 4326 ) WHERE uid = 'NC33-341'
Placeholders are not designed for the purposes of building strings, they only occupy the places where separate scalar values can occur (which is to say, not inside an SQL string literal). Two options:
- Prepare a query like UPDATE Sector SET start = ST_GeomFromText( ?, ? ), end = ST_GeomFromText( ?, ? ) WHERE uid = ?. Use Perl string interpolation to generate strings POINT ( -4.67682813534559 58.3335955352018 ) from your point objects: " POINT ( $st->{whatever} $st->{something_else} )" and supply those as placeholder values.
- Build the strings for ST_GeomFromText on the SQL side of the query: UPDATE Sector SET start = ST_GeomFromText( 'POINT(' || ? || ' ' || ? || ')', ? ), end = ST_GeomFromText( 'POINT(' || ? || ' ' || ? || ')' WHERE uid = ?. Supply individual parts of $st and $ed as placeholder parameters.
Both options look yucky. Is there another constructor for your
POINT objects that accepts coordinates separately? Note that you can't use
$st->sql in a placeholder because placeholders only work for individual scalar values, not arbitrary pieces of SQL code. Indeed, that would destroy the entire purpose of placeholders and make SQL injections possible.