Skip to content

Commit

Permalink
add new method mCreate and bug fix in src/Inserter.php
Browse files Browse the repository at this point in the history
  • Loading branch information
amirfaramarzi committed Aug 24, 2021
1 parent 252c69d commit 91a357e
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/Inserter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,41 @@ public function connection(string $connection = 'mysql'): static
return $this;
}

public function create(int $count): string
public function create(int $count): void
{
if ($count > 10000)
$count = 10000;

for ($i=0;$i<$count;$i++){
for ($i=0;$i<$count;$i++)
$this->insertData[] = $this->data;

$this->insert();
}

public function mCreate(int $count): void
{
if ($count > 10000)
$count = 10000;

for ($i=0;$i<$count;$i++){
$data = [];
foreach ($this->data as $index => $item) {
if (is_array($item)){
$class = $item['class'];
if (is_string($class))
$class = new $class();

$method = $item['method'];
$args = $item['args'] ?? [];
$data[$index] = call_user_func_array([$class , $method] , $args);
} else{
$data[$index] = $item;
}
}
$this->insertData[] = $data;
}

$this->insert();
return "success";
}

protected function insert(): void
Expand Down

0 comments on commit 91a357e

Please sign in to comment.