本文整理汇总了PHP中DatabaseBase::indexExists方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseBase::indexExists方法的具体用法?PHP DatabaseBase::indexExists怎么用?PHP DatabaseBase::indexExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseBase
的用法示例。
在下文中一共展示了DatabaseBase::indexExists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renameIndex
/**
* Rename an index from an existing table
*
* @param string $table Name of the table to modify
* @param string $oldIndex Old name of the index
* @param string $newIndex New name of the index
* @param bool $skipBothIndexExistWarning Whether to warn if both the
* old and the new indexes exist.
* @param string $patch Path to the patch file
* @param bool $fullpath Whether to treat $patch path as a relative or not
* @return bool False if this was skipped because schema changes are skipped
*/
protected function renameIndex($table, $oldIndex, $newIndex, $skipBothIndexExistWarning, $patch, $fullpath = false)
{
if (!$this->doTable($table)) {
return true;
}
// First requirement: the table must exist
if (!$this->db->tableExists($table, __METHOD__)) {
$this->output("...skipping: '{$table}' table doesn't exist yet.\n");
return true;
}
// Second requirement: the new index must be missing
if ($this->db->indexExists($table, $newIndex, __METHOD__)) {
$this->output("...index {$newIndex} already set on {$table} table.\n");
if (!$skipBothIndexExistWarning && $this->db->indexExists($table, $oldIndex, __METHOD__)) {
$this->output("...WARNING: {$oldIndex} still exists, despite it has " . "been renamed into {$newIndex} (which also exists).\n" . " {$oldIndex} should be manually removed if not needed anymore.\n");
}
return true;
}
// Third requirement: the old index must exist
if (!$this->db->indexExists($table, $oldIndex, __METHOD__)) {
$this->output("...skipping: index {$oldIndex} doesn't exist.\n");
return true;
}
// Requirements have been satisfied, patch can be applied
return $this->applyPatch($patch, $fullpath, "Renaming index {$oldIndex} into {$newIndex} to table {$table}");
}
示例2: dropIndex
/**
* Drop an index from an existing table
*
* @param $table String: Name of the table to modify
* @param $index String: Name of the old index
* @param $patch String: Path to the patch file
* @param $fullpath Boolean: Whether to treat $patch path as a relative or not
*/
protected function dropIndex($table, $index, $patch, $fullpath = false)
{
if ($this->db->indexExists($table, $index, __METHOD__)) {
$this->applyPatch($patch, $fullpath, "Dropping {$index} index from table {$table}");
} else {
$this->output("...{$index} key doesn't exist.\n");
}
}
示例3: dropMysqlTextIndex
/**
* (MySQL only) Drops fulltext index before populating the table.
*/
private function dropMysqlTextIndex()
{
$searchindex = $this->db->tableName('searchindex');
if ($this->db->indexExists('searchindex', 'si_title', __METHOD__)) {
$this->output("Dropping index...\n");
$sql = "ALTER TABLE {$searchindex} DROP INDEX si_title, DROP INDEX si_text";
$this->db->query($sql, __METHOD__);
}
}