mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-28 14:52:24 +09:00
Support more index types in DB table parser
UNIQUE, SPATIAL, FULLTEXT
This commit is contained in:
parent
5f8ceafdf6
commit
9b776942e5
5 changed files with 25 additions and 8 deletions
|
|
@ -9,5 +9,5 @@ class Index
|
|||
{
|
||||
public $name;
|
||||
public $columns = array();
|
||||
public $is_unique = false;
|
||||
public $type = null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class Table
|
|||
}
|
||||
$idxcolumns[] = '`' . $column_name . '`' . ($prefix_size > 0 ? "($prefix_size)" : '');
|
||||
}
|
||||
$idxtype = ($index->is_unique ? 'UNIQUE' : 'INDEX');
|
||||
$idxtype = $index->type ? ($index->type . ' INDEX') : 'INDEX';
|
||||
$idxdef = ' ' . $idxtype . ' `' . $index->name . '` (' . implode(', ', $idxcolumns) . ')';
|
||||
$columns[] = $idxdef;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,11 +154,19 @@ class DBTableParser extends BaseParser
|
|||
$index->columns[$idxcolumn] = 0;
|
||||
}
|
||||
}
|
||||
$index->is_unique = toBool($index_info['unique'] ?? '');
|
||||
|
||||
if (isset($index_info['type']) && $index_info['type'])
|
||||
{
|
||||
$index->type = strtoupper($index_info['type']);
|
||||
}
|
||||
elseif (toBool($index_info['unique']))
|
||||
{
|
||||
$index->type = 'UNIQUE';
|
||||
}
|
||||
if (isset($table->columns[$idxcolumn]) && is_object($table->columns[$idxcolumn]))
|
||||
{
|
||||
$table->columns[$idxcolumn]->is_indexed = true;
|
||||
$table->columns[$idxcolumn]->is_unique = $index->is_unique;
|
||||
$table->columns[$idxcolumn]->is_unique = $index->type === 'UNIQUE';
|
||||
}
|
||||
$table->indexes[$index->name] = $index;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue