当前位置: 首页>>代码示例>>PHP>>正文


PHP PMA_Index::getIndexTypes方法代码示例

本文整理汇总了PHP中PMA_Index::getIndexTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Index::getIndexTypes方法的具体用法?PHP PMA_Index::getIndexTypes怎么用?PHP PMA_Index::getIndexTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PMA_Index的用法示例。


在下文中一共展示了PMA_Index::getIndexTypes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PMA_buildIndexStatements

/**
 * Create relevant index statements
 *
 * @param array   $index         an array of index columns
 * @param string  $index_choice  index choice that which represents
 *                               the index type of $indexed_fields
 * @param boolean $is_create_tbl true if requirement is to get the statement
 *                               for table creation
 *
 * @return array an array of sql statements for indexes
 */
function PMA_buildIndexStatements($index, $index_choice, $is_create_tbl = true)
{
    $statement = array();
    if (!count($index)) {
        return $statement;
    }
    $sql_query = PMA_getStatementPrefix($is_create_tbl) . ' ' . $index_choice;
    if (!empty($index['Key_name']) && $index['Key_name'] != 'PRIMARY') {
        $sql_query .= ' ' . PMA_Util::backquote($index['Key_name']);
    }
    $index_fields = array();
    foreach ($index['columns'] as $key => $column) {
        $index_fields[$key] = PMA_Util::backquote($_REQUEST['field_name'][$column['col_index']]);
        if ($column['size']) {
            $index_fields[$key] .= '(' . $column['size'] . ')';
        }
    }
    // end while
    $sql_query .= ' (' . implode(', ', $index_fields) . ')';
    $keyBlockSizes = $index['Key_block_size'];
    if (!empty($keyBlockSizes)) {
        $sql_query .= " KEY_BLOCK_SIZE = " . PMA_Util::sqlAddSlashes($keyBlockSizes);
    }
    // specifying index type is allowed only for primary, unique and index only
    $type = $index['Index_type'];
    if ($index['Index_choice'] != 'SPATIAL' && $index['Index_choice'] != 'FULLTEXT' && in_array($type, PMA_Index::getIndexTypes())) {
        $sql_query .= ' USING ' . $type;
    }
    $parser = $index['Parser'];
    if ($index['Index_choice'] == 'FULLTEXT' && !empty($parser)) {
        $sql_query .= " WITH PARSER " . PMA_Util::sqlAddSlashes($parser);
    }
    $comment = $index['Index_comment'];
    if (!empty($comment)) {
        $sql_query .= " COMMENT '" . PMA_Util::sqlAddSlashes($comment) . "'";
    }
    $statement[] = $sql_query;
    return $statement;
}
开发者ID:nervo,项目名称:phpmyadmin,代码行数:50,代码来源:create_addfield.lib.php

示例2: getSqlQueryForIndexCreateOrEdit

 /**
  * Function to get the sql query for index creation or edit
  *
  * @param PMA_Index $index  current index
  * @param bool      &$error whether error occurred or not
  *
  * @return string
  */
 public function getSqlQueryForIndexCreateOrEdit($index, &$error)
 {
     // $sql_query is the one displayed in the query box
     $sql_query = sprintf('ALTER TABLE %s.%s', PMA_Util::backquote($this->_db_name), PMA_Util::backquote($this->_name));
     // Drops the old index
     if (!empty($_REQUEST['old_index'])) {
         if ($_REQUEST['old_index'] == 'PRIMARY') {
             $sql_query .= ' DROP PRIMARY KEY,';
         } else {
             $sql_query .= sprintf(' DROP INDEX %s,', PMA_Util::backquote($_REQUEST['old_index']));
         }
     }
     // end if
     // Builds the new one
     switch ($index->getChoice()) {
         case 'PRIMARY':
             if ($index->getName() == '') {
                 $index->setName('PRIMARY');
             } elseif ($index->getName() != 'PRIMARY') {
                 $error = PMA_Message::error(__('The name of the primary key must be "PRIMARY"!'));
             }
             $sql_query .= ' ADD PRIMARY KEY';
             break;
         case 'FULLTEXT':
         case 'UNIQUE':
         case 'INDEX':
         case 'SPATIAL':
             if ($index->getName() == 'PRIMARY') {
                 $error = PMA_Message::error(__('Can\'t rename index to PRIMARY!'));
             }
             $sql_query .= sprintf(' ADD %s ', $index->getChoice());
             if ($index->getName()) {
                 $sql_query .= PMA_Util::backquote($index->getName());
             }
             break;
     }
     // end switch
     $index_fields = array();
     foreach ($index->getColumns() as $key => $column) {
         $index_fields[$key] = PMA_Util::backquote($column->getName());
         if ($column->getSubPart()) {
             $index_fields[$key] .= '(' . $column->getSubPart() . ')';
         }
     }
     // end while
     if (empty($index_fields)) {
         $error = PMA_Message::error(__('No index parts defined!'));
     } else {
         $sql_query .= ' (' . implode(', ', $index_fields) . ')';
     }
     $keyBlockSizes = $index->getKeyBlockSize();
     if (!empty($keyBlockSizes)) {
         $sql_query .= sprintf(' KEY_BLOCK_SIZE = ', PMA_Util::sqlAddSlashes($keyBlockSizes));
     }
     // specifying index type is allowed only for primary, unique and index only
     $type = $index->getType();
     if ($index->getChoice() != 'SPATIAL' && $index->getChoice() != 'FULLTEXT' && in_array($type, PMA_Index::getIndexTypes())) {
         $sql_query .= ' USING ' . $type;
     }
     $parser = $index->getParser();
     if ($index->getChoice() == 'FULLTEXT' && !empty($parser)) {
         $sql_query .= ' WITH PARSER ' . PMA_Util::sqlAddSlashes($parser);
     }
     $comment = $index->getComment();
     if (!empty($comment)) {
         $sql_query .= sprintf(" COMMENT '%s'", PMA_Util::sqlAddSlashes($comment));
     }
     $sql_query .= ';';
     return $sql_query;
 }
开发者ID:TheBlackBloodyUnicorn,项目名称:pico_wanderblog,代码行数:78,代码来源:Table.class.php

示例3: generateIndexTypeSelector

 /**
  * Returns HTML for the index type selector
  *
  * @return string HTML for the index type selector
  */
 public function generateIndexTypeSelector()
 {
     $types = array("" => "--");
     foreach (PMA_Index::getIndexTypes() as $type) {
         $types[$type] = $type;
     }
     return PMA_Util::getDropdown("index[Index_type]", $types, $this->_type, "select_index_type");
 }
开发者ID:TheBlackBloodyUnicorn,项目名称:pico_wanderblog,代码行数:13,代码来源:Index.class.php


注:本文中的PMA_Index::getIndexTypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。