rajbatch/batchquery
Composer 安装命令:
composer require rajbatch/batchquery
包简介
This will help user to execute the batch query in their laravel projects.
README 文档
README
This will help user to execute the batch(bulk) query in their laravel projects.
- Easy to Install.
- Easy to execute.
- Consume very little space, so your project does not get heavy
1. Install
composer require rajbatch/batchquery
Batch(bulk) UPDATE*****
Important parameter needs to be set
1. $table = "your table name where update"; 2. $index = 'user_id'; // (NOTE: $index field must exist in the $data array. // $index performs like WHERE clause to identify // where needs to update the given value ) 3. $set = ['column1','column2]; // (column name to update) 4. $data = [ [ 'user_id'=>1, 'column1' =>'column1_value', 'column2' =>'column2_value' ], [ 'user_id'=>2, 'column1' =>'column1', 'column2' =>'column2_value' ], [ 'user_id'=>3, 'column1' =>'column1', 'column2' =>'column2_value' ], ];
2. Controller
use Rajbatch\Batchquery\Batchquery;
3. In Controller function
$batch = new Batchquery(); $table = "your table name where update"; $index = 'user_id'; $set = ['column1']; $data = [ [ 'user_id'=>1, 'column1' =>'column1_value', 'column2' =>'column2_value' ], [ 'user_id'=>2, 'column1' =>'column1', 'column2' =>'column2_value' ], [ 'user_id'=>3, 'column1' =>'column1', 'column2' =>'column2_value' ], ]; $response = $batch->batchUpdate($index,$table,$set,$data);
Batch(bulk) INSERT*****
Important parameter needs to be set
1. $table = "your table name where insert"; 2. $data = [ [ 'user_id'=>1, 'column1' =>'column1_value', 'column2' =>'column2_value' ], [ 'user_id'=>2, 'column1' =>'column1', 'column2' =>'column2_value' ], [ 'user_id'=>3, 'column1' =>'column1', 'column2' =>'column2_value' ], ];
2. Controller
use Rajbatch\Batchquery\Batchquery;
3. In Controller function
$batch = new Batchquery(); $table = "your table name where insert"; $data = [ [ 'user_id'=>1, 'column1' =>'column1_value', 'column2' =>'column2_value' ], [ 'user_id'=>2, 'column1' =>'column1', 'column2' =>'column2_value' ], [ 'user_id'=>3, 'column1' =>'column1', 'column2' =>'column2_value' ], ]; $response = $batch->batchInsert($table,$data);
统计信息
- 总下载量: 57
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-09