cognitus / php7-mga

source code for build .rpm php7 in mageia 6
1 stars 0 forks source link

mysql PDO driver always returns numbers as strings #4

Open waclaw66 opened 6 years ago

waclaw66 commented 6 years ago

Hi. Currently I'm testing the latest version 7.1.11 of PHP7 from this source. Everything works fine except for one thing. Some of my sites use PDO driver to access mysql database. They set PDO::ATTR_STRINGIFY_FETCHES to false and expect returned numbers as numbers not strings. Setting this attribute to false has no influence to the results and numbers are returned always as strings. I made an example code which demonstrates this issue. If it's possible could you please test it on some mysql database? I'm not sure where is the problem. Thanks!

<?php
    $pdo = new PDO('mysql:host=localhost;dbname=test_db', 'user', 'password', [
        PDO::ATTR_STRINGIFY_FETCHES => false,
        PDO::ATTR_EMULATE_PREPARES => false,
    ]);

    $data = $pdo->query("SELECT number FROM table")->fetchAll();
    var_dump($data);
?>

phpinfo of my server... https://drive.google.com/file/d/1Zk5cVcBmNYVpLDRoriVMPX6vtosB1mia/view?usp=sharing

cognitus commented 6 years ago

it's a bug of pdo driver https://bugs.php.net/bug.php?id=44341 , https://stackoverflow.com/questions/16129432/why-not-pdo-mysql-return-integer however, i remember it's work well with php 5.5.x maybe was broken or something... this Weekend i'll see what happened.

waclaw66 commented 6 years ago

Yes, it was a bug in the past, but it works well on my production 5.6.31 :/ Therefore I suspect some configuration on my testing server.

cognitus commented 6 years ago

today i had some time for review so, good news! it was my foul... when I forked php 7 from openmandriva, I remove some files and updates some configs acording to mageia, but i forget review the lines about mysqlnd and mysqli (/facepalm)

now, recompile and try it and thanks for warning me

waclaw66 commented 6 years ago

Wow, thanks for such of fast support. Now it works properly. Thanks! One remark, besides timezonedb and suhosin, it's also needed to rebuild redis and sasl extension.