diff options
author | Igor Wiedler <igor@wiedler.ch> | 2010-09-05 03:14:27 +0200 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2010-09-05 03:14:27 +0200 |
commit | e7b86871f077bb0d9ad819a6405607232fdd078f (patch) | |
tree | 6fab7b3a1cc4818a03a5fd9c878a5cb22ddae7ae /phpBB/includes/db | |
parent | bb191a1d696994c1d27bbd0457457cf538dff7ee (diff) | |
download | forums-e7b86871f077bb0d9ad819a6405607232fdd078f.tar forums-e7b86871f077bb0d9ad819a6405607232fdd078f.tar.gz forums-e7b86871f077bb0d9ad819a6405607232fdd078f.tar.bz2 forums-e7b86871f077bb0d9ad819a6405607232fdd078f.tar.xz forums-e7b86871f077bb0d9ad819a6405607232fdd078f.zip |
[ticket/8944] Patch db_tools to support index length for MySQL4
Diffstat (limited to 'phpBB/includes/db')
-rw-r--r-- | phpBB/includes/db/db_tools.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index 819ef69c96..f4b181c6ad 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -611,7 +611,7 @@ class phpbb_db_tools * drop_columns: Removing/Dropping columns * add_primary_keys: adding primary keys * add_unique_index: adding an unique index - * add_index: adding an index + * add_index: adding an index (can be column:index_size if you need to provide size) * * The values are in this format: * {TABLE NAME} => array( @@ -1804,6 +1804,12 @@ class phpbb_db_tools { $statements = array(); + // remove index length unless MySQL4 + if ('mysql_40' != $this->sql_layer) + { + $column = preg_replace('#:.*$#', '', $column); + } + switch ($this->sql_layer) { case 'firebird': @@ -1814,6 +1820,16 @@ class phpbb_db_tools break; case 'mysql_40': + // add index size to definition as required by MySQL4 + foreach ($column as $i => $col) + { + if (false !== strpos($col, ':')) + { + list($col, $index_size) = explode(':', $col); + $column[$i] = "$col($index_size)"; + } + } + // no break case 'mysql_41': $statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; break; |