Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zoilomora/doctrine-dbal-msaccess
An implementation of the doctrine/dbal library to support Microsoft Access databases in Microsoft OS.
https://github.com/zoilomora/doctrine-dbal-msaccess
dbal doctrine microsoft microsoft-access
Last synced: about 2 months ago
JSON representation
An implementation of the doctrine/dbal library to support Microsoft Access databases in Microsoft OS.
- Host: GitHub
- URL: https://github.com/zoilomora/doctrine-dbal-msaccess
- Owner: zoilomora
- License: mit
- Created: 2020-11-14T14:58:22.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-26T17:33:38.000Z (about 4 years ago)
- Last Synced: 2024-07-23T14:14:14.462Z (5 months ago)
- Topics: dbal, doctrine, microsoft, microsoft-access
- Language: PHP
- Homepage: https://packagist.org/packages/zoilomora/doctrine-dbal-msaccess
- Size: 84 KB
- Stars: 15
- Watchers: 3
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Doctrine DBAL for Microsoft Access
An implementation of the [doctrine/dbal](https://github.com/doctrine/dbal) library to support **Microsoft Access databases** in **Microsoft OS**.There are some functionalities that are not supported by Microsoft Access in a PDO-based connection. For these functionalities the implementation uses a direct connection through ODBC.
## OS Requirements
- Microsoft Access Database Engine Redistributable ([2010](https://www.microsoft.com/download/details.aspx?id=13255) or [2016](https://www.microsoft.com/download/details.aspx?id=54920)).
- Register a **DSN** in **ODBC Data Source Administrator** `odbcad32.exe`.## Installation
1) Install via [composer](https://getcomposer.org/)
```shell script
composer require zoilomora/doctrine-dbal-msaccess
```### Register a **DSN**
We don't need to reinvent the wheel, on the internet there are hundreds of tutorials on how to set up a DSN for Microsoft Access.
I leave you a [video](https://www.youtube.com/watch?v=biSjA8ms_Wk) that I think explains it perfectly.Once the DSN is configured we will have to configure the connection in the following way:
```php
$connection = \Doctrine\DBAL\DriverManager::getConnection(
[
'driverClass' => \ZoiloMora\Doctrine\DBAL\Driver\MicrosoftAccess\Driver::class,
'driverOptions' => [
'dsn' => 'name of the created dsn',
],
]
);
```## Discovered problems
### Character encoding problems
The default character encoding in Access databases is [Windows-1252](https://en.wikipedia.org/wiki/Windows-1252).
If you want to convert the data to UTF-8, a simple solution would be:```php
$field = \mb_convert_encoding($field, 'UTF-8', 'Windows-1252');
```If you want all the data to be encoded automatically to UTF-8 (with the performance reduction that it may imply)
configure the driver as follows:```php
$connection = \Doctrine\DBAL\DriverManager::getConnection(
[
'driverClass' => \ZoiloMora\Doctrine\DBAL\Driver\MicrosoftAccess\Driver::class,
'driverOptions' => [
'dsn' => 'name of the created dsn',
'charset' => 'UTF-8',
],
]
);
```## License
Licensed under the [MIT license](http://opensource.org/licenses/MIT)Read [LICENSE](LICENSE) for more information