PHP code example of csv / csvtosql
1. Go to this page and download the library: Download csv/csvtosql 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/ */
csv / csvtosql example snippets
php
// Import vendor autoload
vtosql\TransformCsv();
$csv->file('files/sales.csv') // Source csv file
->table('salse') // Target table name
->transform()
->exportSQL('transform/sales.sql'); // Destination (output the sql file with insert statement)
file()
php
// @param string (csv source file path)
file('folder/file.csv');
php
// @param string (table name)
table('tablename');
php
// @param string (new sql file destination)
exportSQL('exported/file.sql');