fcarbah / lumen-db2-ext
lumen-db2 是为 Lumen ~6 版本提供的一个简单的 DB2 服务提供者。它通过扩展 Laravel 框架的 Illuminate Database 组件来提供 DB2 连接。
v1.0.4
2020-01-07 20:06 UTC
Requires
- php: >=7.0
- illuminate/database: ^6.0
- illuminate/support: ^6.0
This package is auto-updated.
Last update: 2024-09-08 07:11:59 UTC
README
Lumen-DB2
安装
通过 composer 安装 lumen-db2
composer require fcarbah/lumen-db2
取消注释对 Eloquent 的调用,并将 DB2ServiceProvideer 添加到 bootstrap/app.php
// ... /* |-------------------------------------------------------------------------- | Create The Application |-------------------------------------------------------------------------- | | Here we will load the environment and create the application instance | that serves as the central piece of this framework. We'll use this | application as an "IoC" container and router for this framework. | */ $app = new Laravel\Lumen\Application( realpath(__DIR__.'/../') ); // $app->withFacades(); $app->withEloquent(); // <- Uncomment this // ... /* |-------------------------------------------------------------------------- | Register Service Providers |-------------------------------------------------------------------------- | | Here we will register all of the application's service providers which | are used to bind services into the container. Service providers are | totally optional, so you are not required to uncomment this line. | */ $app->register(MichaelB\Database\DB2\DB2ServiceProvider::class); // <- Add this
配置
创建 app/config/database.php
文件
/* |-------------------------------------------- | Configuration Defaults |-------------------------------------------- */ return [ 'fetch' => PDO::FETCH_CLASS, 'connections' => [ 'as400' => [ 'driver' => 'odbc', // General settings 'host' => '', 'username' => '', 'password' => '', //Server settings 'database' => '', 'prefix' => '', 'schema' => '', 'signon' => 3, 'ssl' => 0, 'commitMode' => 2, 'connectionType' => 0, 'defaultLibraries' => '', 'naming' => 0, 'unicodeSql' => 0, // Format settings 'dateFormat' => 5, 'dateSeperator' => 0, 'decimal' => 0, 'timeFormat' => 0, 'timeSeparator' => 0, // Performances settings 'blockFetch' => 1, 'blockSizeKB' => 32, 'allowDataCompression' => 1, 'concurrency' => 0, 'lazyClose' => 0, 'maxFieldLength' => 15360, 'prefetch' => 0, 'queryTimeout' => 1, // Modules settings 'defaultPkgLibrary' => '', 'defaultPackage' => '', 'extendedDynamic' => 1, // Diagnostic settings 'QAQQINILibrary' => '', 'sqDiagCode' => '', // Sort settings 'languageId' => '', 'sortTable' => '', 'sortSequence' => 0, 'sortWeight' => 0, 'jobSort' => 0, // Conversion settings 'allowUnsupportedChar' => 0, 'ccsid' => 1208, 'graphic' => 0, 'forceTranslation' => 0, // Other settings 'allowProcCalls' => 0, 'DB2SqlStates' => 0, 'debug' => 0, 'trueAutoCommit' => 0, 'catalogOptions' => 3, 'libraryView' => 0, 'ODBCRemarks' => 0, 'searchPattern' => 1, 'translationDLL' => '', 'translationOption' => 0, 'maxTraceSize' => 0, 'multipleTraceFiles' => 1, 'trace' => 0, 'traceFilename' => '', 'extendedColInfo' => 0, 'options' => [ PDO::ATTR_CASE => PDO::CASE_LOWER, PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_PERSISTENT => false ] ] ] ];
驱动设置可以是 'odbc' 用于 ODBC 连接或 'ibm' 用于 pdo_ibm 连接。如果驱动是 'odbc',则数据库必须设置为 ODBC 连接名称。如果驱动是 'ibm',则数据库必须设置为 IBMi 数据库名称 (WRKRDBDIRE)。
用法
参考 Laravel 框架文档。