all data type in PHP PDO query to ms access are strings? Need help to retrieve numeric types


I'm trying to connect from PHP to a ms access database and, with help from here, so far so good!

But all data retrieved is "String" type, even date/time and numeric fields are converted to string in php. And some numeric values only show a string with "E2".

Here is my code:

$dbName = "database.accdb";
$conn2 = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=$dbName;Uid=Admin");
$stmt = $conn2->prepare("SELECT * FROM table");
$result= $stmt->fetchAll();

There are numeric fields, string fields, and date/time fields in that table, but the array $result has data type "String" in all elements. Used gettype() to check.

The problem is that numeric values get converted sometimes to "0.0353125" (for example) or only "E-3" or "E-2"

How can I get the correct value in my $result array? What am I doing wrong?

Thanks a lot

People are also looking for solutions to the problem: How to develop a real time system using PHP & MySQL


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.