dev-master
9999999-dev https://github.com/TiiToo/PDOAccessBundleLibrary for support of the pdo_dblib (MSSQL) driver in Doctrine
MIT
The Requires
- php >=5.3.2
- doctrine/dbal >=2.1.0
by Tito
doctrine pdo mssql dblib pdo_dblib
Library for support of the pdo_dblib (MSSQL) driver in Doctrine
Doctrine extension which allows to read Microsoft Access (.mdb) files via Doctrine DBAL in Symfony2., (*1)
It uses the PDO_ODBC PHP driver, so I think it could work with any connection, not only MS Access databases. It has been tested only on microsoft Windows XP., (*2)
It is not intented for ORM mapping, I've only used to import data from a older Microsoft Access program to Symfony2., (*3)
This extension is based on PDODblibBundle, (*4)
Configure php.ini in your apache server. Add:, (*5)
extension=php_pdo_odbc.dll
Then, restart apache2 server, (*6)
Add the following lines into deps file:, (*7)
[ClalarcoPDOAccessBundle] git=git://github.com/clalarco/PDOAccessBundle.git target=/bundles/Clalarco/PDOAccessBundle version=origin/master
Register it in the autoload.php
file:, (*8)
``` php <?php // app/autoload.php, (*9)
$loader->registerNamespaces(array( 'Clalarco' => DIR.'/../vendor/bundles', ));, (*10)
Now, run the vendors script to download the bundle: ``` bash $ php bin/vendors install
** Note: ** You need to separate the default connection in doctrine. Check Symfony2 Doctrine configuration., (*11)
The way I created a connection is via config.yml (or config_dev.yml). In windows it works using:, (*12)
# config.yml doctrine: dbal: connections: msaccess: driver_class: Clalarco\PDOAccessBundle\Doctrine\DBAL\Driver\PDOMdbLib\Driver host: "{Microsoft Access Driver (*.mdb)};Dbq=C:\path_to\file.mdb" user: Admin password: your_password
Replace C:\path_to\file.mdb with your path, and your_password with your password, if any, blank otherwise. 'msaccess' name can also been renamed., (*13)
In your controller, add the following lines to get the connection if your connection name is 'msaccess':, (*14)
<?php class MyController extends Controller { public function myAction() { ... $conn = $this->get('doctrine.dbal.msaccess_connection'); ... // Once the connection is created, SQL queries are accepted. // Check Doctrine DBAL documentation for more information. $rows = $conn->fetchAll('SELECT * FROM my_table'); ... } }
If a the connection is used in a command, the command to get the connection is:, (*15)
$conn = $this->getContainer()->get('doctrine')->getConnection('msaccess');
Library for support of the pdo_dblib (MSSQL) driver in Doctrine
MIT
doctrine pdo mssql dblib pdo_dblib