Skip to content

Commit

Permalink
README
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauro Cassani committed Feb 6, 2018
1 parent 91a87ad commit d177d23
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ You can decide how to build insert query:
* 'multiple' (default) - insert data in a unique multiple insert query
* 'single' - insert data in a loop of insert queries

### Maximum limit or records in multiple insert queries

Please note that there is a limit to the maximum number of records that can be inserted in a single query. In case this limit is exceeded, a loop of multiple insertion queries will be executed.

This limit is:

* 4000 records for mysql driver
* 200 records for sqlite driver

## Built With

* [DBAL](http://www.doctrine-project.org/projects/dbal.html) - Database Abstraction Layer
Expand Down
12 changes: 6 additions & 6 deletions src/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ public function getQueries()
{
$queryBuilder = $this->getQueryBuilder();

/** @var $class QueryBuilderInterface */
return (new $queryBuilder(
$this->table,
$this->mapping,
Expand Down Expand Up @@ -194,6 +193,7 @@ public function execute()
return $this->executeMultipleInsertQuery();
}
}

/**
* @return bool
*/
Expand All @@ -214,6 +214,7 @@ private function executeSingleInsertQueries()

return true;
}

/**
* @return bool
*/
Expand All @@ -229,24 +230,23 @@ private function executeMultipleInsertQuery()
foreach ($queries as $query){
$stmt = $this->dbal->prepare($query);
$c = 1;
$d = array_slice($this->data->toArray(), ($start*$limit), $limit);
$dataSliced = array_slice($this->data->toArray(), ($start*$limit), $limit);

foreach ($d as $item) {
foreach ($dataSliced as $item) {
$this->bindValuesToItem($item, $stmt, $c);
$c++;
}

$start++;

if(false === $stmt->execute()){
return false;
}

$start++;
}

return true;
}


/**
* @param $item
* @param $index
Expand Down

0 comments on commit d177d23

Please sign in to comment.