PDO returns all data as strings?!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I just noticed a weird behaviour of PDO for my SQLite database and found a hint online. Just wanted to check here.

Is it correct that PDO will return all queried values from the fetch method as string, no matter the actual data type? I couldn't find that notice by glancing over the documentation. (Such an unexpected note should be very well visible.)

If that's the case, can it be fixed immediately (for PHP 7.4 and later)? Or what alternatives to PDO could I use for SQLite only? I need prepared statements and parameter binding.

I know how SQLite handles data types, and it includes remembering the type that was given to it. If PHP/PDO then destroys it, it's of very limited use.

My code looks like this:

    $ps = $this->connection->prepare('select * from table');
    $ps->execute();
    $record = $ps->fetch(PDO::FETCH_ASSOC);

-Yves



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux