/** * Loads the fixture data. * Data will be batch inserted into the given collection. */ public function load() { parent::load(); $data = $this->getData(); $this->getCollection()->batchInsert($data); foreach ($data as $alias => $row) { $this->data[$alias] = $row; } }
/** * Loads the fixture. * * It will then populate the table with the data returned by [[getData()]]. * * If you override this method, you should consider calling the parent implementation * so that the data returned by [[getData()]] can be populated into the table. */ public function load() { parent::load(); $table = $this->getTableSchema(); foreach ($this->getData() as $alias => $row) { $this->db->createCommand()->insert($table->fullName, $row)->execute(); if ($table->sequenceName !== null) { foreach ($table->primaryKey as $pk) { if (!isset($row[$pk])) { $row[$pk] = $this->db->getLastInsertID($table->sequenceName); break; } } } $this->data[$alias] = $row; } }