Bug #75937 [Opn->Fbk]: PDO_DBLIB prepare statements quoting numerics

From: Date: Thu, 08 Feb 2018 18:24:51 +0000
Subject: Bug #75937 [Opn->Fbk]: PDO_DBLIB prepare statements quoting numerics
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213869@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75937&edit=1 ID: 75937 Updated by: peehaa@php.net Reported by: equaproduction at gmail dot com Summary: PDO_DBLIB prepare statements quoting numerics -Status: Open +Status: Feedback Type: Bug Package: PDO DBlib Operating System: Centos 7.2 PHP Version: 7.2.2 Block user comment: N Private report: N New Comment: Am I missing something here? You are telling PDO the param must be treated as a string using \PDO::PARAM_STR so indeed it is treated as a string. Previous Comments: ------------------------------------------------------------------------ [2018-02-08 18:21:57] equaproduction at gmail dot com Description: ------------ When using PDO_DBLIB to prepare statements, numerics are quoted and fatal error is returned. PDOStatement::bindValue() PDOStatement::bindParam() OS : Centos 7.2 PHP : 7.2.2 Freetds : 0.95.81 DBMS : Sybase ASE 12.5.4 & Sybase ASE 16.0 Test script: --------------- // create table foo ( n numeric(14,2) null ) $db = new \PDO("dblib:host=$hostname:$port;dbname=$dbname", "$username", "$pw"); $db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $n = 123.45; $query = 'INSERT INTO foo ( n ) values ( :n )'; $stmt = $db->prepare($query); $stmt->bindParam(':n', $n, \PDO::PARAM_STR); $stmt->execute(); Actual result: -------------- SQLSTATE[HY000]: General error: 20018 Implicit conversion from datatype 'VARCHAR' to 'NUMERIC' is not allowed. Use the CONVERT function to run this query. [20018] (severity 16) [INSERT INTO foo ( n ) values ( '123.45' )] ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75937&edit=1

« previous php.bugs (#213869) next »