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
-
Install
elysiumrealms/database-router.composer require elysiumrealms/database-router
-
Configure
config/database.phpandconfig/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
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-19