2

Since a couple of days I have one application (on a Clients server I do not have full access to yet) that refuses to obey the PDO::ATTR_STRINGIFY_FETCHES=false setting.

Code below should return integer (as it does on my own servers)

Yet on one server (I mailed them this testcode) it returns string

$PDO = new PDO("mysql:host=" . DB_SERVER . ";dbname=" . DB_NAME . ";charset=utf8", DB_USER, DB_PASS);
$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$PDO->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$PDO->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
$stmt = $PDO->prepare("SELECT * FROM information_schema.tables WHERE table_name='TABLES';");
$stmt->execute();
$tables = $stmt->fetch(PDO::FETCH_ASSOC);
echo "<H1>" . gettype($tables['VERSION']) . "</H1>";
var_dump($tables);

Setting PDO::ATTR_STRINGIFY_FETCHES=true of course exhibits the same behaviour on my own servers, as PDO by default returns integers as strings.

But the application requires integers to be integers in PHP.

As said; I do not yet have access to that server. Any pointers though?

Update

I finally got some phpinfo()

MySQLND is (for unknown reason) now missing (it was there before as the application ran fine)

Have directed sys-admins to blogs on activating MySQLND (again)

How to enable mysqlnd for php?

Danny '365CSI' Engelman
  • 16,526
  • 2
  • 32
  • 49
  • 1
    What version of PHP are they running? [This answer](https://stackoverflow.com/a/1197041/1491895) says it requires PHP 5.3 with the MYSQLND driver. – Barmar Aug 24 '18 at 19:19
  • Don't know the details yet. They claim they haven't changed anything; application ran fine for years. Hoping someone will copy/paste above code and experiences similar issue. – Danny '365CSI' Engelman Aug 24 '18 at 19:29
  • They always claim that. If the behavior changed, something must have changed. – Barmar Aug 24 '18 at 19:30
  • Run `phpinfo()` on their server and compare it to yours. – Barmar Aug 24 '18 at 19:31
  • I have finally seen a screenshot (argh!.. governments) of their phpInfo() **There is no MySQLND section**; Plenty of blogs on how to enable it; can't read anywhere how it could have been disabled. I know the Native Driver was there before, because the application does strict comparisons thus required Integers – Danny '365CSI' Engelman Aug 25 '18 at 12:54

0 Answers0