本文整理汇总了PHP中xmldb_index::setNext方法的典型用法代码示例。如果您正苦于以下问题:PHP xmldb_index::setNext方法的具体用法?PHP xmldb_index::setNext怎么用?PHP xmldb_index::setNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmldb_index
的用法示例。
在下文中一共展示了xmldb_index::setNext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addIndex
/**
* Add one index to the table, allowing to specify the desired order
* If it's not specified, then the index is added at the end
* @param xmldb_index $index
* @param xmldb_object $after
*/
public function addIndex($index, $after = null)
{
// Detect duplicates first
if ($this->getIndex($index->getName())) {
throw new coding_exception('Duplicate index ' . $index->getName() . ' specified in table ' . $this->getName());
}
// Make sure there are no keys with the index column specs because they would collide.
$newfields = $index->getFields();
$allkeys = $this->getKeys();
foreach ($allkeys as $key) {
$fields = $key->getFields();
if ($fields === $newfields) {
throw new coding_exception('Key ' . $key->getName() . ' collides with index' . $index->getName() . ' specified in table ' . $this->getName());
}
}
// Calculate the previous and next indexes
$previndex = null;
$nextindex = null;
if (!$after) {
$allindexes = $this->getIndexes();
if (!empty($allindexes)) {
end($allindexes);
$previndex = $allindexes[key($allindexes)];
}
} else {
$previndex = $this->getIndex($after);
}
if ($previndex && $previndex->getNext()) {
$nextindex = $this->getIndex($previndex->getNext());
}
// Set current index previous and next attributes
if ($previndex) {
$index->setPrevious($previndex->getName());
$previndex->setNext($index->getName());
}
if ($nextindex) {
$index->setNext($nextindex->getName());
$nextindex->setPrevious($index->getName());
}
// Some more attributes
$index->setLoaded(true);
$index->setChanged(true);
// Add the new index
$this->indexes[] = $index;
// Reorder the indexes
$this->orderIndexes($this->indexes);
// Recalculate the hash
$this->calculateHash(true);
// We have one new index, so the table has changed
$this->setChanged(true);
}
示例2: addIndex
/**
* Add one index to the table, allowing to specify the desired order
* If it's not specified, then the index is added at the end
* @param xmldb_index $index
* @param xmldb_object $after
*/
public function addIndex($index, $after=null) {
// Detect duplicates first
if ($this->getIndex($index->getName())) {
throw new coding_exception('Duplicate index '.$index->getName().' specified in table '.$this->getName());
}
// Calculate the previous and next indexes
$previndex = null;
$nextindex = null;
if (!$after) {
$allindexes = $this->getIndexes();
if (!empty($allindexes)) {
end($allindexes);
$previndex = $allindexes[key($allindexes)];
}
} else {
$previndex = $this->getIndex($after);
}
if ($previndex && $previndex->getNext()) {
$nextindex = $this->getIndex($previndex->getNext());
}
// Set current index previous and next attributes
if ($previndex) {
$index->setPrevious($previndex->getName());
$previndex->setNext($index->getName());
}
if ($nextindex) {
$index->setNext($nextindex->getName());
$nextindex->setPrevious($index->getName());
}
// Some more attributes
$index->setLoaded(true);
$index->setChanged(true);
// Add the new index
$this->indexes[] = $index;
// Reorder the indexes
$this->orderIndexes($this->indexes);
// Recalculate the hash
$this->calculateHash(true);
// We have one new index, so the table has changed
$this->setChanged(true);
}