定制 dipeshkhatiwada/odbc-connector 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dipeshkhatiwada/odbc-connector

Composer 安装命令:

composer require dipeshkhatiwada/odbc-connector

包简介

ODBC Driver for Laravel 8.* to connect with external database

README 文档

README

A simple ODBC driver for Laravel 8.*. Requires PHP version 8+.

Prerequisites

Enable the pdo_odbc PHP extension.

For other database engines (for instance MS SQL Server), you'll need to install the appropriate PHP extension(s).

Installation

composer require dipeshkhatiwada/odbc-connector

Laravel will automatically discover the service provider.

Configuration

In your database.php config, configure your connection using the odbc driver:

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

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',

For SQL server, you'll need to specify the DSN, the user, and the password. For example:

'dsn' => 'sqlsrv:Driver=ODBC Driver 18 for SQL Server;Server=tcp:localhost,1433;TrustServerCertificate=1;Encrypt=1;'
'username' => 'sa',
'password' => 'my-super-secret-password',

Contributions & License

Contributions are hearty welcome.

MIT Licensed.You can wish to modify.

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-05