定制 tck/odbc 二次开发

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

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

tck/odbc

Composer 安装命令:

composer require tck/odbc

包简介

ODBC Connector for Laravel

README 文档

README

This is a simple ODBC connector for Laravel 4/5.

Installation

Add this to the require section in your composer.json file

"tck/odbc": "dev-master"

In your config/app.php file add the Service Provider to the service providers array like so...

'TCK\Odbc\OdbcServiceProvider',

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

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

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

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

Alternatively, in an Eloquent model you could something like this

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.

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

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

Or a connection name

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

Hopefully, this will help you!

统计信息

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

GitHub 信息

  • Stars: 24
  • Watchers: 3
  • Forks: 17
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-21