Bug #69974 [NEW]: PDO MySQL with PDO::MYSQL_ATTR_DIRECT_QUERY fetching MySQL DECIMAL as string

From: Date: Wed, 01 Jul 2015 05:52:33 +0000
Subject: Bug #69974 [NEW]: PDO MySQL with PDO::MYSQL_ATTR_DIRECT_QUERY fetching MySQL DECIMAL as string
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194025@lists.php.net to get a copy of this message
From:             os at irj dot ru
Operating system: Debian Sid 64
PHP version:      7.0.0alpha2
Package:          PDO MySQL
Bug Type:         Bug
Bug description:PDO MySQL with PDO::MYSQL_ATTR_DIRECT_QUERY fetching MySQL DECIMAL as string

Description:
------------
PHP 7 PDO MySQL with PDO::MYSQL_ATTR_DIRECT_QUERY fetching MySQL DECIMAL
type as string type, but expected any type of number type (etc.
double).

Tested at Debian sid X64 with latest packages


Test script:
---------------
<?php
declare(strict_types=1);

/*
 
create database php7 default charset 'utf8';

    use php7;

create table types (
  id int unsigned not null primary key,
  signed_int int signed,
  unsigned_int int unsigned,
  signed_float float signed,
  unsigned_float float unsigned,
  signed_decimal decimal(10,2) signed,
  unsigned_decimal decimal(10,2) unsigned
  );
  
insert into
  types
  (id, signed_int, unsigned_int, signed_float,
unsigned_float,
signed_decimal, unsigned_decimal)
values
  ('1', '-30', '44', '-300.33', '334.00033',
'-324.34', '64.23')
; 
*/


$dbh = new PDO(
"mysql:host=localhost;dbname=php7;unix_socket=/var/run/mysqld/mysqld.sock",
"root" );
$dbh->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, false);
$sth = $dbh->prepare("select * from types");
$sth->execute();

$row = $sth->fetchObject("stdClass");


print "Type of id:" . gettype( $row->id ) . "\n";
print "Type of signed_int:" . gettype( $row->signed_int )  .
"\n";
print "Type of unsigned_int:" . gettype( $row->unsigned_int )  .
"\n";
print "Type of signed_float:" . gettype( $row->signed_float )  .
"\n";
print "Type of unsigned_float:" . gettype( $row->unsigned_float )  .
"\n";
print "Type of signed_decimal:" . gettype( $row->signed_decimal )  .
"\n";
print "Type of unsigned_decimal:" . gettype( $row->unsigned_decimal ) 
. "\n";


Expected result:
----------------
Type of id:integer
Type of signed_int:integer
Type of unsigned_int:integer
Type of signed_float:double
Type of unsigned_float:double
Type of signed_decimal:double
Type of unsigned_decimal:double

Actual result:
--------------
Type of id:integer
Type of signed_int:integer
Type of unsigned_int:integer
Type of signed_float:double
Type of unsigned_float:double
Type of signed_decimal:string
Type of unsigned_decimal:string

-- 
Edit bug report at https://bugs.php.net/bug.php?id=69974&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=69974&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=69974&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=69974&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=69974&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=69974&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=69974&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=69974&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=69974&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=69974&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=69974&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=69974&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=69974&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=69974&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69974&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=69974&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=69974&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=69974&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69974&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=69974&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=69974&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#194025) next »