Skip to content

The pedram-davoodi/multi-update package provides a simple way to perform multi-row updates on a database table using Laravel's Eloquent ORM. It offers a convenient method that allows you to update multiple rows with different values based on given conditions, making it a useful tool for developers working with large datasets.

Notifications You must be signed in to change notification settings

pedram-davoodi/multi-update

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Update

Multi-Update is a laravel package that allows you to update multiple rows in a database table with a single SQL statement. This package is useful when you need to update multiple rows with different values based on different conditions.

Installation

You can install Multi-Update using Composer.

composer require pedram/multi-update

Usage

To use Multi-Update, you need to call the updateMultipleRows method on a model or a query builder instance. This method takes two parameters: an array of fields and their corresponding values to update, and a variable-length argument list of conditions to apply to the update statement.

use PedramD\MultiUpdate\MultiUpdate;

MyModel::updateMultipleRows($params, $condition1, $condition2, ...);

Here's an example of how you can use Multi-Update to update multiple rows in a database table:

use PedramD\MultiUpdate\MultiUpdate;

MyModel::updateMultipleRows([
    'column1' => [
        'condition1' => 'value1',
        'condition2' => 'value2',
        'condition3' => 'value3',
    ],
    'column2' => [
        'condition4' => 'new_value',
    ],
], 'column5 > 0', 'column6 = "some_value"');

In the above example, we are updating two columns column1 and column2. The column1 is updated based on three different conditions, and the column2 is updated based on one condition. We have also added two additional conditions to apply to the update statement.

Contributing

Contributions to Multi-Update are welcome and encouraged! If you find a bug or have a feature request, please open an issue on the GitHub repository. If you would like to contribute code, please fork the repository and submit a pull request.

When submitting a pull request, please make sure to follow the PSR-2 coding standards for any new functionality or bug fixes.

License

Multi-Update is open-sourced software licensed under the MIT license.

About

The pedram-davoodi/multi-update package provides a simple way to perform multi-row updates on a database table using Laravel's Eloquent ORM. It offers a convenient method that allows you to update multiple rows with different values based on given conditions, making it a useful tool for developers working with large datasets.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages