I have an ms access 2010 database with extension *.accdb
and I manage to connect to the database using PDO and ODBC driver.
I tried to delete either the *.mdb
or *.accdb
and get an error, I don't know why it needs both the extensions.
This is the POC:
<?php
$dbName = 'here be path';
$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=$dbName; Uid=; Pwd=;");
$sql = "SELECT MAX(ID) as MaxID from tbl";
$result = $db->query($sql);
foreach($result as $r) {
var_dump($r);
}
The strange thing is the obtained result:
array (size=2)
'MaxID' => string '21411' (length=5)
0 => string '21411' (length=5)
Why do I get 2 entry for one expected result? How can I obtain only this:
array (size=1)
'MaxID' => string '21411' (length=5)
The second thing is how can I optimize the PDO to get only one result without foreach?