1. Go to this page and download the library: Download isaacdew/load-data 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/ */
isaacdew / load-data example snippets
use Isaacdew\LoadData\LoadData;
LoadData::from(storage_path('path/to/file.csv'))
->to('tablename')
->fieldsTerminatedBy(',')
->fieldsEnclosedBy('"', optionally: true)
->load();
use Isaacdew\LoadData\LoadData;
LoadData::from(storage_path('path/to/file.csv'))
->to('tablename')
->ignoreHeader()
->load();
use Isaacdew\LoadData\LoadData;
LoadData::from(storage_path('path/to/file.csv'))
->to('tablename')
->truncateBeforeLoad()
->load();
use Isaacdew\LoadData\LoadData;
LoadData::from(storage_path('path/to/file.csv'))
->to('tablename')
->fieldsTerminatedBy(',')
->fieldsEnclosedBy('"', optionally: true)
->columns([
'column_one',
'column_two',
'column_three',
'date_column'
])
->setColumn('date_column', "STR_TO_DATE(@date_column, '%c/%d/%Y')") // Convert MM/DD/YYYY to a MySQL date
->load();