End of part 3 of patch #458014: fulltext indexes support

This commit is contained in:
Loïc Chapeaux
2001-09-06 23:48:51 +00:00
parent e393a2f2d7
commit 709eec1b9b
4 changed files with 60 additions and 6 deletions

View File

@@ -124,6 +124,21 @@ if (isset($submit)) {
}
} // end if
// Builds the fulltext statements and updates the table
$fulltext = '';
if (MYSQL_INT_VERSION >= 32323 && isset($field_fulltext)) {
for ($i = 0; $i < count($field_fulltext); $i++) {
$j = $field_fulltext[$i];
$fulltext .= backquote($field_name[$j]) . ', ';
} // end for
$fulltext = ereg_replace(', $', '', $fulltext);
if (!empty($fulltext)) {
$sql_query .= "\n" . 'ALTER TABLE ' . backquote($db) . '.' . backquote($table) . ' ADD FULLTEXT (' . $fulltext . ')';
$result = mysql_query('ALTER TABLE ' . backquote($db) . '.' . backquote($table) . ' ADD UNIQUE (' . $fulltext . ')') or mysql_die();
}
} // end if
// Go back to table properties
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
include('./tbl_properties.php3');

View File

@@ -77,6 +77,7 @@ if (isset($submit)) {
$sql_query = 'ALTER TABLE ' . backquote($db) . '.' . backquote($table) . ' CHANGE ' . $query;
$result = mysql_query($sql_query) or mysql_die();
$message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
$btnDrop = 'Fake';
include('./tbl_properties.php3');
exit();
}

View File

@@ -130,7 +130,29 @@ if (isset($submit)) {
if (!empty($unique)) {
$unique = ', UNIQUE (' . $unique . ')';
}
$query_keys = $primary . $index . $unique;
// Builds the fulltextes statements
if (!isset($fulltext)) {
$fulltext = '';
}
if (!isset($field_fulltext) || MYSQL_INT_VERSION < 32323) {
$field_fulltext = array();
}
for ($i = 0; $i < count($field_fulltext); $i++) {
$j = $field_fulltext[$i];
if (!empty($field_name[$j])) {
if (get_magic_quotes_gpc()) {
$field_name[$j] = stripslashes($field_name[$j]);
}
$fulltext .= backquote($field_name[$j]) . ', ';
}
} // end for
$fulltext = ereg_replace(', $', '', $fulltext);
if (!empty($fulltext)) {
$fulltext = ', FULLTEXT (' . $fulltext . ')';
}
$query_keys = $primary . $index . $unique . $fulltext;
$query_keys = ereg_replace(', $', '', $query_keys);
// Builds the 'create table' statement

View File

@@ -39,6 +39,7 @@ if (!$is_backup) {
echo " <th>$strPrimary</th>\n";
echo " <th>$strIndex</th>\n";
echo " <th>$strUnique</th>\n";
echo " <th>$strIdxFulltext</th>\n";
} else {
for ($i = 0; $i < $num_indexes; $i++) {
echo " <th>$strSequence</th>\n";
@@ -214,14 +215,20 @@ for ($i = 0 ; $i < $num_fields; $i++) {
$checked_primary = '';
}
if (isset($row) && isset($row['Key']) && $row['Key'] == 'MUL') {
$checked_index = ' checked="checked"';
$checked_index = ' checked="checked"';
} else {
$checked_index = '';
$checked_index = '';
}
if (isset($row) && isset($row['Key']) && $row['Key'] == 'UNI') {
$checked_unique = ' checked="checked"';
$checked_unique = ' checked="checked"';
} else {
$checked_unique = '';
$checked_unique = '';
}
if (MYSQL_INT_VERSION >= 32323
&&(isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
$checked_fulltext = ' checked="checked"';
} else {
$checked_fulltext = '';
}
echo "\n";
?>
@@ -235,6 +242,15 @@ for ($i = 0 ; $i < $num_fields; $i++) {
<input type="checkbox" name="field_unique[]" value="<?php echo $i; ?>"<?php echo $checked_unique; ?> />
</td>
<?php
if (MYSQL_INT_VERSION >= 32323) {
echo "\n";
?>
<td nowrap="nowrap">
<input type="checkbox" name="field_fulltext[]" value="<?php echo $i; ?>"<?php echo $checked_fulltext; ?> />
</td>
<?php
} // end if (MYSQL_INT_VERSION >= 32323)
echo "\n";
} // end if (empty($num_indexes))
} // end if ($action ==...)
echo "\n";
@@ -304,7 +320,7 @@ if ($action == 'tbl_create.php3' && MYSQL_INT_VERSION >= 32300) {
} // end if
} // end while
} // end if
mysql_free_result($tables);
mysql_free_result($result);
echo "\n";
?>