Search
 
SCRIPT & CODE EXAMPLE
 

PHP

save big data with laravel

ini_set('max_execution_time', 120 ) ; // time in seconds

$insert_data = [];

foreach ($json['value'] as $value)
{
   ...
}
Comment

save big data with laravel

$insert_data = [];

foreach ($json['value'] as $value) {
    $posting_date = Carbon::parse($value['Posting_Date']);

    $posting_date = $posting_date->format('Y-m-d');

    $data = [
        'item_no'                   => $value['Item_No'],
        'entry_no'                  => $value['Entry_No'], 
        'document_no'               => $value['Document_No'],
        'posting_date'              => $posting_date,
        ....
    ];

    $insert_data[] = $data;
}

$insert_data = collect($insert_data); // Make a collection to use the chunk method

// it will chunk the dataset in smaller collections containing 500 values each. 
// Play with the value to get best result
$chunks = $insert_data->chunk(500);

foreach ($chunks as $chunk)
{
   DB::table('items_details')->insert($chunk->toArray());
}
Comment

PREVIOUS NEXT
Code Example
Php :: laravel route model binding 
Php :: wordpress get default date format 
Php :: true not true acf 
Php :: can i back up mysql database from php code? 
Php :: create a button add in laravel 
Php :: laravel search function 
Php :: while loop laravel 
Php :: Laravel Extract Values From Collection Using Pluck() with Relationship 
Php :: get current content type 
Php :: doctrine orm refresh 
Php :: tenary php 
Php :: php variable 
Php :: onclick on image php 
Php :: array_diff php 
Php :: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given in 
Php :: laravel check if query builder is empty 
Php :: optional parameter in laravel 
Php :: avatar generator laravel 
Php :: php round function syntax 
Php :: polymorphism in php 
Php :: date comparison function in php 
Php :: laravel call a static function 
Php :: how to logout in phpmyadmin 
Php :: status validation laravel 
Php :: laravel @env 
Php :: optimize wordpress query 
Php :: drop column laravel migration 
Php :: laravel jobs 
Php :: split functions.php 
Php :: acf field without spaces 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =