PHP code example of ajcastro / insert-update-many

1. Go to this page and download the library: Download ajcastro/insert-update-many library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ajcastro / insert-update-many example snippets


$users = factory(User::class, 10)->make();
User::insertMany($users);

User::updateMany($users); // update many models using id as the default key
User::updateMany($users, 'id'); // same as above
User::updateMany($users, 'username'); // use username as key instead of id


User::updateMany($users, 'id', ['email', 'first_name', 'last_name']);