/** * @inheritdoc */ public function load() { $this->resetTable(); $this->data = []; $table = $this->getTableSchema(); $users = User::find()->select(['id'])->column(); if (count($users) > 0) { $index = 0; foreach ($this->getData() as $alias => $row) { $row['id'] = $users[$index++]; $this->db->schema->insert($table->fullName, $row); $this->data[$alias] = $row; } } }
/** * @inheritdoc */ public function load() { $this->resetTable(); $this->data = []; $table = $this->getTableSchema(); $users = User::find()->select(['id'])->column(); if (count($users) > 0) { $index = 0; foreach ($this->getData() as $alias => $row) { if (!isset($users[$index])) { break; } $row['id'] = $users[$index]; $primaryKeys = $this->db->schema->insert($table->fullName, $row); $this->data[$alias] = array_merge($row, $primaryKeys); $index++; } } }
/** * @inheritdoc */ public function load() { $this->resetTable(); $this->data = []; $table = $this->getTableSchema(); $data = $this->getData(); $users = User::find()->select(['id'])->column(); if (count($users) >= 2) { ArrayHelper::multisort($data, 'timestamp', SORT_ASC, SORT_NUMERIC); foreach ($data as $alias => $row) { shuffle($users); $row['sender_id'] = $users[0]; $row['receiver_id'] = $users[1]; $row['created_at'] = date('Y-m-d H:i:s', $row['timestamp']); unset($row['timestamp']); $primaryKeys = $this->db->schema->insert($table->fullName, $row); $this->data[$alias] = array_merge($row, $primaryKeys); } } }