jeg prøvede for sjov at lave en lille test på Northwind.mdb.
mere fordi jeg ikke selv før havde kørt PDO mod access.
har tidligere brugt rent ODBC
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>demo</title>
<style type="text/css">
</style>
</head>
<body>
<?php
//
https://www.sanwebe.com/2011/08/microsoft-access-using-php-pdo $db_username = ''; //username
$db_password = ''; //password
//path to database file
$database_path = "C:/util/xampp/htdocs/test/access/Northwind.mdb"; //check file exist before we proceed
if (!file_exists($database_path)) {
die("Access database file not found !");
}
//create a new PDO object
$conn = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$database_path; Uid=$db_username; Pwd=$db_password;");
/* test brug at connection */
$data = array();
$sql = "select * from Countries";
if ($stmt = $conn->prepare($sql)) {
/* Eksekver forespørgslen */
$stmt->execute();
/* Hent rækker og udskriv data */
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$data[] = $row['Country'];
}
} else {
/* Der er opstået en fejl */
echo 'Der opstod en fejl i erklæringen: ' . $conn->error;
}
// test udskriv af array
print_r($data);
?>
</body>
</html>