PHP code example of iamapen / commentable-data-set

1. Go to this page and download the library: Download iamapen/commentable-data-set 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/ */

    

iamapen / commentable-data-set example snippets


$ds = new \Iamapen\CommentableDataSet\DbUnit\DataSet\CommentableCsvDataSet();
$ds->addTable('users', '/PATH/TO/users.csv');
$ds->setIgnoreColumnCount(1);    // 1列目をコメント列とする

class XxxTest extends \PHPUnit\DbUnit\TestCase {
  function testXXX() {
      $this->assertDataSetsEqual($ds1, $ds2);
  }
}

> $ds = new Iamapen\ExcelFriendlyDataSet\Database\DataSet\ExcelCsvDataSet();
> 

use Iamapen\CommentableDataSet\DbUnit\DataSet\CommentableCsvDataSet;
use Iamapen\CommentableDataSet\DbUnit\Operation\MySqlBulkInsert;

// DataSet
$ds = new CommentableCsvDataSet();
$ds->addTable('/PATH/TO/CSV');

// 実行 (TRUNCATE -> BULK INSERT)
$con = new \PHPUnit\DbUnit\Database\DefaultConnection($pdo);
\PHPUnit\DbUnit\Operation\Factory::TRUNCATE()->execute($con, $ds);
(new MySqlBulkInsert())->execute($con, $ds);