[php-src] Issue #14388: PDO Geometry object cannot be bound

From: Date: Fri, 31 May 2024 15:28:50 +0000
Subject: [php-src] Issue #14388: PDO Geometry object cannot be bound
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246998@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/14388 Author: wriver4 ### Description Works ``` <?php $pin = "GeomFromText('POINT( $longitude $latitude )')"; $sql = "UPDATE properties SET pin = $pin WHERE id = '$id'"; echo $sql; // produces UPDATE properties SET pin = GeomFromText('POINT( -77.4366461184819 37.2048908233377 )') WHERE id = '1' $stmt = $dbadmin->query($sql); $stmt->execute() ``` Doesn't work ``` <?php $sql = "UPDATE properties SET pin = '$pin' WHERE id = '$id'"; produces UPDATE properties SET pin = 'GeomFromText('POINT( -77.4366461184819 37.2048908233377 )')' WHERE id = '1' ``` [Fri May 31 14:53:00.639350 2024] [proxy_fcgi:error] [pid 20269:tid 140001413121792] [client 73.216.73.197:48588] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'POINT( -77.4366461184819 37.2048908233377 )')' ``` <?php $sql = "UPDATE properties SET pin = :pin WHERE id = :id"; $stmt = $dbadmin->prepare($sql); $stmt->bindParam(':pin', $pin , PDO::PARAM_STR); $stmt->bindParam(':id', $id, PDO::PARAM_INT); $stmt->execute(); ``` [Fri May 31 15:14:11.539268 2024] [proxy_fcgi:error] [pid 20267:tid 140001587283712] [client 73.216.73.197:51430] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[22003]: Numeric value out of range: 1416 Cannot get geometry object from data you send to the GEOMETRY field in: PDOStatement->execute()\n#1 {main} Using 10.11.6-MariaDB ### PHP Version PHP 8.2 ### Operating System CentOS Linux release 7.9.2009 (Core)

« previous php.bugs (#246998) next »