royopa / ms-access-dbal-driver
A DBAL driver to use with MS Access
Installs: 5 308
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 2
Open Issues: 1
Requires
- php: >=5.3.0
- doctrine/dbal: ~2.5
Requires (Dev)
- phpunit/phpunit: 4.0.*
This package is auto-updated.
Last update: 2024-10-29 04:47:21 UTC
README
DBAL Driver to use with Microsoft Access.
Requiring/Loading
If you're using Composer to manage dependencies, you can include the following in your composer.json file:
{ "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>'; }