2017 © Pedro Peláez
 

library odbc

ODBC Connector for Laravel

image

tck/odbc

ODBC Connector for Laravel

  • Sunday, September 18, 2016
  • by bencarter78
  • Repository
  • 4 Watchers
  • 16 Stars
  • 7,273 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 12 Open issues
  • 2 Versions
  • 13 % Grown

The README.md

Laravel ODBC Connector

This is a simple ODBC connector for Laravel 4/5., (*1)

Installation

Add this to the require section in your composer.json file, (*2)

"tck/odbc": "dev-master"

In your config/app.php file add the Service Provider to the service providers array like so..., (*3)

'TCK\Odbc\OdbcServiceProvider',

Now in your config/database.php you will need to add your connection details, it'll look something like this..., (*4)

'odbc'   => [
    'driver'   => 'odbc',
    'dsn'      => 'odbc:DB_CONNECTION_STRING', //
    'host'     => 'DB_HOST',
    'database' => 'DB_NAME,
    'username' => 'DB_USERNAME',
    'password' => 'DB_PASSWORD',
],

Custom Grammar

To use SQL Server or other database engines, set the grammar in the config:, (*5)

'odbc'   => [
    ...
    'grammar' => [
        'query' => Illuminate\Database\Query\Grammars\SqlServerGrammar::class,
        'schema' => Illuminate\Database\Schema\Grammars\SqlServerGrammar::class,
    ],
],

Usage

Now in your app you can do something like..., (*6)

$data = DB::connection('odbc')->get('tableName')->all();

Alternatively, in an Eloquent model you could something like this, (*7)

class Users extends Eloquent {

    protected $connection = 'odbc';
}

DB_CONNECTION_STRING - Something to note

Dependant upon your database configuration, I personally had some difficulty in working out what the DB_CONNECTION_STRING needed to be., (*8)

This was some trial and error (with a hell of a lot of Googling!) but you could either use a path, something like..., (*9)

'dsn'      => 'odbc:\\\\path\to\my\database',

Or a connection name, (*10)

'dsn'      => 'odbc:\\\\my-connection-name',

Hopefully, this will help you!, (*11)

The Versions

18/09 2016

dev-master

9999999-dev

ODBC Connector for Laravel

  Sources   Download

MIT

The Requires

 

by Avatar tck

21/03 2015

1.0.x-dev

1.0.9999999.9999999-dev

ODBC Connector for Laravel

  Sources   Download

MIT

The Requires

 

by Avatar tck