public function fill()
{
$totalColumn = $this->db->getTotalColumns();
$rows = array();
for ($n = 0; $n < $this->num; $n++) {
$fakeRow = new DbRowEntity();
for ($i = 0; $i < $totalColumn; $i++) {
if ($this->db->isColumnAutoincrement($i)) {
continue;
}
$fieldName = $this->db->getColumnName($i);
$fakeType = $this->db->getColumnType($i);
$dataLength = $this->db->getColumnLength($i);
$fakeData = $this->fakeColumn($fieldName, $fakeType, $dataLength);
$fakeRow->setFields(new DbFieldEntity($fieldName, $fakeData[0], $fakeType, $dataLength));
}
$this->db->insert($fakeRow);
$rows[] = $fakeRow->toArray();
}
return $rows;
}
/** * Fills the given table with fake data. * * @param string|null $tableName * * @return array $rows * @throws \Fakerino\FakeData\Exception\MissingRequiredOptionException */ public function fakeTable($tableName = null) { if ($tableName === null) { throw new MissingRequiredOptionException('table name'); } $connectionParams = FakerinoConf::get('database'); $dbFiller = new DbFiller($connectionParams, $this->db, $tableName, $this, $this->num); $rows = $dbFiller->fill(); return $rows; }