PHP code example of bakame / csv-doctrine-collection-bridge
1. Go to this page and download the library: Download bakame/csv-doctrine-collection-bridge 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/ */
bakame / csv-doctrine-collection-bridge example snippets
use Bakame\Csv\Extension as CsvExtension;
use Doctrine\Common\Collections\Criteria;
use League\Csv\Reader;
$csv = Reader::createFromPath('/path/to/my/file.csv');
$csv->setHeaderOffset(0);
$csv->setDelimiter(';');
$criteria = Criteria::create()
->andWhere(Criteria::expr()->eq('prenom', 'Adam'))
->orderBy( [ 'annee' => 'ASC', 'foo' => 'desc', ] )
->setFirstResult(0)
->setMaxResults(10)
;
//you can do
$resultset = CsvExtension\CriteriaConverter::convert($criteria)->process($csv);
$result = new CsvExtension\RecordCollection($resultset);
//or
$collection = new CsvExtension\RecordCollection($csv);
$result = $collection->matching($criteria);
use Bakame\Csv\Extension\RecordCollection;
use League\Csv\Reader;
$csv = Reader::createFromPath('/path/to/my/file.csv');
$csv->setHeaderOffset(0);
$csv->setDelimiter(';');
$collection = new RecordCollection($csv);