library ms-access-dbal-driver
A DBAL driver to use with MS Access
royopa/ms-access-dbal-driver
A DBAL driver to use with MS Access
- Wednesday, May 27, 2015
- by royopa
- Repository
- 1 Watchers
- 1 Stars
- 4,215 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 1 Forks
- 1 Open issues
- 1 Versions
- 60 % Grown
MSAccessDBALDriver
, (*1)
DBAL Driver to use with Microsoft Access., (*2)
Requiring/Loading
If you're using Composer to manage dependencies, you can include the following
in your composer.json file:, (*3)
{
"require": {
"royopa/ms-access-dbal-driver": "dev-master"
}
}
Usage
<?php
header('Content-Type: text/html; charset=utf-8');
require 'vendor/autoload.php';
$dsn = 'odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=MyDatabase.mdb;';
try {
$connPdo = new PDO($dsn);
} catch (PDOException $e) {
echo $e->getMessage() . '</br>';
}
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'user' => null,
'password' => null,
'pdo' => $connPdo,
'driverClass' => 'Royopa\Doctrine\DBAL\Driver\MSAccess\Driver\Driver',
);
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
$sql = 'SELECT * FROM myTable';
$stmt = $conn->query($sql);
while ($row = $stmt->fetch()) {
echo $row['columnName'] . '</br>';
}