PHP code example of mixpo / form-data-exporter

1. Go to this page and download the library: Download mixpo/form-data-exporter 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/ */

    

mixpo / form-data-exporter example snippets




$exporter = new FormExporter(
    'dsn', // <- PDO DSN string including credentials
    'tableName', // <- the table the you wish to export data from
    'data', // <- the name of the 'data' column (column that hold the JSON form data)
    ["client_id" => "12345", "campaign" => "widget-2015"], // <- criteria used to build an AND'ed WHERE clause
    $logger // <- Psr\Log\LoggerInterface
);



$exporter->setExporterEngine(
    new FileSystemExporterEngine(
       'file:///var/data/csv/leadgen99.csv',  // <- full path to the output CSV in <protocol>://<path> format
                                                    s3://<bucket>/<object-path> is also supported
        $logger, // <- Psr\Log\LoggerInterface
        $randomizeFileName = true
    )
);
                                              
$outputCsvFilePath = $exporter->run();




$exporter->run();
$issues = $exporter->getIssues();

/**
 * $issues will be an empty array if there were no issues, but if there were it will look something like this.
 *      [
 *       [
 *         "message" => "Expected data field of name: 'form_data', not found for this row",
 *         "row" => ["id" => 2, 
 *                   "identifier" => "client-xyz",
 *                   "tag" => "widget-1-campaign",
 *                   "version" => 1,
 *                   "created" => "2015-04-16 21:50:39"]
 *       ],
 *       ...
 *      ]
 **/