承接 jhavenz/laravel-batch-update 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

jhavenz/laravel-batch-update

最新稳定版本:0.0.1

Composer 安装命令:

composer require jhavenz/laravel-batch-update

包简介

batch updates for Eloquent models

README 文档

README

There's always been a missing bit when you want don't want to 'upsert', which Laravel covers, and you don't want to 'insert'. When you just need to 'update' all the rows, each having their own varying data set, then this package will help you out.

Requirements

- PHP: >= 8.1

Installation

You can install the package via composer:

composer require jhavenz/laravel-batch-update

Usage

Notes:

  • This package has been used a bit in my projects and is working nicely so far, but it's still in an infant and I have to write the test suite. Please lmk if you see an issue or have an idea to add.
  • I'm aware that I'm bypassing the bindings as I'm building the query, but since I'm generally using this logic when I wan to map 100s of rows, then fire the query off, I've hit limitations against the database where there's 'too many bindings' for the db engine to handle.

Thoughts?.. It's better like this, right? Unless, of course, you're passing user input to your db... in that case, I can't imagine you'd be batch updating while the user is waiting anyway.

Update multiple rows, each having their own values..and you only want to update: (not updateOrCreate, upsert, findOrCreate, etc.) e.g.

use Jhavenz\LaravelBatchUpdate\BatchedUpdate;

// 
(new BatchedUpdate(User::class))->update(
    values: [
        [
            'user_id' => 123,
            'name' => 'john doe',
            'email' => 'john@example.com',
        ],
        [
            'user_id' => 234,
            'name' => 'jane doe',
            'email' => 'jane@example.com',
        ],
        // ... a whole bunch of mapped data (in memory), then 1 query gets executed
    ],
    index: <string> /** Give an index here, or leave null and the Model's key will be used  */
    quoted: <bool> /** have you quoted the value, or should I ?..   */
);

Testing

#TODO - composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固