本文整理汇总了PHP中Nette\Database\Context::getStructure方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::getStructure方法的具体用法?PHP Context::getStructure怎么用?PHP Context::getStructure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Database\Context
的用法示例。
在下文中一共展示了Context::getStructure方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPrimarySequence
/**
* @return string
*/
public function getPrimarySequence()
{
if ($this->primarySequence === FALSE) {
$this->primarySequence = $this->context->getStructure()->getPrimaryKeySequence($this->name);
}
return $this->primarySequence;
}
示例2: __construct
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)));
}
示例3: initializeDataStructure
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);
}
}
}
示例4: __construct
public function __construct(Context $databaseContext)
{
$this->databaseContext = $databaseContext;
$this->databaseStructure = $databaseContext->getStructure();
$this->databaseConventions = $databaseContext->getConventions();
}