2017 © Pedro Peláez
 

library pdo-access-bundle

Library for support of the pdo_dblib (MSSQL) driver in Doctrine

image

tito/pdo-access-bundle

Library for support of the pdo_dblib (MSSQL) driver in Doctrine

  • Saturday, December 12, 2015
  • by TiiToo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 20 % Grown

The README.md

PDOAccessBundle

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)

Installation

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

Create a connection

** 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');

TODO

  • Improve code documentation.

The Versions

12/12 2015

dev-master

9999999-dev https://github.com/TiiToo/PDOAccessBundle

Library for support of the pdo_dblib (MSSQL) driver in Doctrine

  Sources   Download

MIT

The Requires

 

by Tito

doctrine pdo mssql dblib pdo_dblib