PHP code example of rajbatch / batchquery

1. Go to this page and download the library: Download rajbatch/batchquery 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/ */

    

rajbatch / batchquery example snippets

 
    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'
            ],
        ];
  
 
 use Rajbatch\Batchquery\Batchquery;
 
 
        $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);
   
 
    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'
            ],
        ];
  
 
 use Rajbatch\Batchquery\Batchquery;
 
 
        $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);