public getStructure ( ) : Nette\Database\IStructure | ||
리턴 | Nette\Database\IStructure |
/** * @return string */ public function getPrimarySequence() { if ($this->primarySequence === FALSE) { $this->primarySequence = $this->context->getStructure()->getPrimaryKeySequence($this->name); } return $this->primarySequence; }
public function __construct($tableName, Context $context) { $this->tableName = $tableName; $this->driver = $context->getConnection()->getSupplementalDriver(); $this->conventions = $context->getConventions(); $this->structure = $context->getStructure(); $this->delimitedTable = implode('.', array_map([$this->driver, 'delimite'], explode('.', $tableName))); }
protected function initializeDataStructure($tableName, $primaryKey) { $dataStructure = new Structures\DataStructure($tableName, $primaryKey); $this->setDataStructure($dataStructure); $structure = $this->context->getStructure(); $columns = $structure->getColumns($this->getTableName()); Helpers::setStructureFromColumns($dataStructure, $this->determineFromColumns($columns)); foreach ($structure->getBelongsToReference($tableName) as $key => $table) { $dataStructure->getOrCreateTableStructure($table, $structure->getPrimaryKey($table)); $targetReference = $structure->getBelongsToReference($table); $hasOneToOne = array_search($tableName, $targetReference); if ($hasOneToOne) { $field = $dataStructure->addOneToOne($table, $table, $key); } else { $field = $dataStructure->addManyToOne($table, $table, $key); } $column = $this->findColumn($columns, $key); $field->setNullable($column['nullable']); } foreach ($structure->getHasManyReference($tableName) as $table => $keys) { $dataStructure->getOrCreateTableStructure($table, $structure->getPrimaryKey($table)); $sourceReference = $structure->getBelongsToReference($tableName); if (in_array($table, $sourceReference)) { continue; } $targetReference = $structure->getBelongsToReference($table); if (count($targetReference) > 1) { $match = null; foreach ($keys as $key => $targetTable) { $match = array_search($tableName, $targetReference); if ($match) { unset($targetReference[$match]); break; } } if ($match) { $arrayKeys = array_keys($targetReference); $selfColumn = reset($arrayKeys); $currentValue = reset($targetReference); $dataStructure->getOrCreateTableStructure($currentValue, $structure->getPrimaryKey($currentValue)); $dataStructure->addManyToMany($currentValue, $currentValue, $selfColumn, $table, $match); continue; } } $match = null; foreach ($keys as $key => $targetTable) { $match = array_search($tableName, $targetReference); if ($match) { unset($targetReference[$match]); break; } } if ($match) { $dataStructure->addOneToMany($table, $table, $match); } } }
public function __construct(Context $databaseContext) { $this->databaseContext = $databaseContext; $this->databaseStructure = $databaseContext->getStructure(); $this->databaseConventions = $databaseContext->getConventions(); }