masterpis/db2as400
Composer 安装命令:
composer require masterpis/db2as400
包简介
Packages for Db2 As400 connection. Connection based on general connection string COM and ODBC
README 文档
README
Packages for managing connection to Db2 As400 using driver COM dot net and ODBC. It is built on lumen laravel. It is a collection of attributes and methods to simplify connection to DB2 As400. The main purpose of this library is standarization of code in my small organization. It will provide basic operation of database connection.
How to use it on your project.
Running this script on your lumen / laravel project directory
composer require masterpis/db2as400
Database configuration on .env on laravel or lumen project
If you use ODBC Driver, you can use configuration below :
DB2_DRIVER=ODBC
DB2_CATALOG=
DB2_HOST=192.168.x.xx
DB2_USERNAME=user_odbc
DB2_PASSWORD=pass_odbc
if you use COM Driver, you can use configuration below:
DB2_DRIVER=COM
DB2_CATALOG=S651658X
DB2_HOST=192.168.x.xx
DB2_USERNAME=user_com
DB2_PASSWORD=pass_com
if you have multiple env ODBC
DB2_DRIVER=ODBC
DB2_CATALOG=
DB2_HOST=192.168.x.xx|192.168.xx.xxx
DB2_USERNAME=user1|user2
DB2_PASSWORD=pass1|pass2
if you have multiple env COM
DB2_DRIVER=COM
DB2_CATALOG=S651658X|S651658Y
DB2_HOST=192.168.x.xx|192.168.xx.xxx
DB2_USERNAME=user1|user2
DB2_PASSWORD=pass1|pass2
Open your Model, remove default eloquent and load this packages by this code
use Masterpis\Db2as400\Model;
Change extends from default eloquent to this packages
<?php
namespace App;
use Masterpis\Db2as400\Model;
class Employee extends Model{
protected $table ="oplenhp.employee";
protected $fields= ["id", "name", "phone"];
public function __construct(){
parent::__construct();
}
}
?>
Use your model on controller
<?php
namespace App\Http\Controllers;
use App\Employee;
use Laravel\Lumen\Routing\Controller as BaseController;
class TestController extends BaseController{
public function get()
{
$mmusid = new Employee;
$mmusid->where(['id'=>'1']);
$a=$mmusid->first();
dd($a)
}
}
Methods reference:
Clause configuration. Call method before method where();
/**
* The query clause like.
* @param array
* @return void
*/
$mmusid->like($like)
/**
* The query clause order
* @param array
* @return void
*/
$mmusid->orderBy($order)
/**
* The query clause limit
* @param int
* @return void
*/
$mmusid->limit($limit)
/**
* The server RDBMS, for multiple env only
* @param int
* @return void
*/
$mmusid->setServer($server)
/**
* The user in charge. Registered user running commands
* @param @string
* @return void
*/
$mmusid->setUser($user)
Main method
/**
* The query clause where
* @param array $where
* Simple clause where ex. ["field"=>"keyword"]
* Complex clause on where ex
* [""=>"(field1='".$keyword1."' or field2='".$keyword2."') and field2 like '%".keyword3."%'"]
* @param string $console
* NULL, CONSOLE will display query generated, ASPARAM will assign query to var $query
* @return void
*/
$mmusid->where($where=NULL, $console=NULL)
/**
* Get list array of executed query
* @return array
* @return false
*/
$mmusid->get()
/**
* Get single array of executed query
* @return array
* @return false
*/
$mmusid->first()
/**
* @param array filter
* @return int
*/
// generate select count(*) from xxx
$mmusid->count($filter=NULL)
// Generate insert into query
/**
* @var array $person
* @var string $console=NULL
* return void
*/
$mmusid=>insert($person)
//Generate delete query
/**
* @var array $filter=NULL
* @var string $console=NULL
* @return void
*/
$mmusid->delete($filter)
```
> Compability
You have to install driver COM or ODBC to make it run.
If you have iSeries packages like iSeries Navigator, you can install it, the driver automatically installed
masterpis/db2as400 适用场景与选型建议
masterpis/db2as400 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 12 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「query」 「odbc」 「Connection」 「db2」 「as400」 「COM」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 masterpis/db2as400 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 masterpis/db2as400 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 masterpis/db2as400 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
laravel-ibmi is a simple DB2 & Toolkit for IBMi service provider for Laravel. It provides DB2 Connection by extending the Illuminate Database component of the laravel framework. Plus it also provides Toolkit for IBMi so that you can access IBMi resources with same credentials.
Query filtering in your frontend
Dibi is Database Abstraction Library for PHP
Anax Database Active Record module for model classes.
Small service to parse database connection string into parts
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-13