From 7e18d2b861826f399805656143fbdb940f302221 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 14 Oct 2011 17:18:25 +0200 Subject: [PATCH 1/2] [ticket/10327] Also change CREATE UNIQUE INDEX to use ALTER TABLE. PHPBB3-10327 --- phpBB/includes/db/db_tools.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index 0d8cf7fdab..392a827cb7 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -2092,7 +2092,7 @@ class phpbb_db_tools case 'mysql_40': case 'mysql_41': - $statements[] = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; + $statements[] = 'ALTER TABLE ' . $table_name . ' ADD UNIQUE INDEX (' . implode(', ', $column) . ')'; break; case 'mssql': From 607761e8303f456929e4755d8fabb69d9d16561a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 14 Oct 2011 17:20:51 +0200 Subject: [PATCH 2/2] [ticket/10327] Use $this->tools instead of creating a new instance of db_tools. PHPBB3-10327 --- tests/dbal/db_tools_test.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index 927bce4597..daf464d600 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -336,19 +336,12 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case public function test_index_exists() { - $db_tools = new phpbb_db_tools($this->db); - - $this->assertTrue($db_tools->sql_index_exists('prefix_table_name', 'i_simple')); + $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_simple')); } public function test_create_index_against_index_exists() { - $db_tools = new phpbb_db_tools($this->db); - - $table_name = 'prefix_table_name'; - $index_name = 'fookey'; - - $db_tools->sql_create_index($table_name, $index_name, array('c_timestamp', 'c_decimal')); - $this->assertTrue($db_tools->sql_index_exists($table_name, $index_name)); + $this->tools->sql_create_index('prefix_table_name', 'fookey', array('c_timestamp', 'c_decimal')); + $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'fookey')); } }