定制 elysiumrealms/database-router 二次开发

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

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

elysiumrealms/database-router

最新稳定版本:1.0.1

Composer 安装命令:

composer require elysiumrealms/database-router

包简介

A Database Router isolate Read Write Connections

README 文档

README

Description

Database Router is an extension for databases using master-slave architecture. This extension ensures that the default connection uses a read-write capable database host and extends an optional router connection to partially apply read-write isolation strategies based on business logic.

Installation

  1. Install elysiumrealms/database-router.

    composer require elysiumrealms/database-router
  2. Configure config/database.php and config/app.php.

    php artisan db:router:install

Read from DB_READ_HOST

To perform read operations using the read host, you can use the following methods:

$model = Model::router()->first();
$model = Admin::where('id', 1)->router()->first();
$model = Admin::router()->where('id', 1)->first();
DB::table('users')->router()->find(1);

Update with DB_WRITE_HOST

To perform update operations using the write host, you can use the following methods:

$model = Model::router()
    ->update(['name' => 'new-name']);
$model = Admin::where('id', 1)->router()
    ->update(['name' => 'new-name']);
$model = Admin::router()->where('id', 1)
    ->update(['name' => 'new-name']);
DB::table('users')->router()
    ->update(['name' => 'new-name']);

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固