private function tryToUseIdsFromDatabase() { $vpidTableExists = (bool) $this->database->get_row("SHOW TABLES LIKE '{$this->database->vp_id}'"); if (!$vpidTableExists) { return; } $vpidRows = $this->database->get_results("SELECT `table`, id, HEX(vp_id) vp_id FROM {$this->database->vp_id}"); foreach ($vpidRows as $row) { $this->idCache[$this->dbSchema->getEntityInfoByTableName($row->table)->entityName][$row->id] = $row->vp_id; } }
/** * @param $table * @param $data */ private function createEntity($table, $data) { $entityInfo = $this->dbSchemaInfo->getEntityInfoByPrefixedTableName($table); $id = $this->database->insert_id; $data = $this->database->get_row("SELECT * FROM `{$table}` WHERE `{$entityInfo->idColumnName}` = '{$id}'", ARRAY_A); $entityName = $entityInfo->entityName; $data = $this->vpidRepository->replaceForeignKeysWithReferences($entityName, $data); array_walk($data, function (&$value, $key) { if ($value === false) { $value = ''; } }); $shouldBeSaved = $this->mirror->shouldBeSaved($entityName, $data); if (!$shouldBeSaved) { return; } $data = $this->vpidRepository->identifyEntity($entityName, $data, $id); $data = $this->shortcodesReplacer->replaceShortcodesInEntity($entityName, $data); $this->mirror->save($entityName, $data); }