GithubHelp home page GithubHelp logo

odbc-driver's Introduction

ODBC Driver for Laravel

A simple ODBC driver for Laravel 5.5+.

Prerequisites

Enable the pdo_odbc PHP extension

Installation

composer require dbt/odbc-driver

Laravel will automatically discover the service provider.

Configuration

In your database.php config, you'll need to add the ODBC connection configuration, eg:

'odbc' => [
    'driver'   => 'odbc',
    'dsn'      => env('ODBC_DSN'),
    'host'     => env('ODBC_HOST'),
    'database' => env('ODBC_DB'),
    'username' => env('ODBC_USERNAME'),
    'password' => env('ODBC_PASSWORD'),
],

Custom Grammar

To use SQL Server or other database engines, set the grammar in the config:

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

Usage

Use the connection like any other, via the query builder or with Eloquent.

For Eloquent, you'll need to specify the model's connection:

class Users extends Eloquent {
    /** @var string */
    protected $connection = 'odbc';
}

Connection String

You may need to use some trial and error to figure out what your connection string should look like. Consult your vendor's database documentation.

It could be a connection path:

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

Or a connection name:

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

Or something as simple as:

'dsn' => 'odbc:dbname',

Contributions & License

Contributions are welcome.

MIT Licensed. Do as you wish.

odbc-driver's People

Contributors

danielsdeboer avatar justsanjit avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.