From 35c7673caeff18080433191e461ccb7874baadc2 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 31 Oct 2008 11:13:31 +0000 Subject: - Patch #327480 by chx: remove DB specific code from simpletest. --- includes/database/database.inc | 12 ++++++++++++ includes/database/schema.inc | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'includes') diff --git a/includes/database/database.inc b/includes/database/database.inc index b44846aa2..91c5ea4cb 100644 --- a/includes/database/database.inc +++ b/includes/database/database.inc @@ -1674,6 +1674,18 @@ function db_column_exists($table, $column) { return Database::getActiveConnection()->schema()->columnExists($table, $column); } + /** + * Find all tables that are like the specified base table name. + * + * @param table_expression + * An SQL expression, for example simpletest% . BEWARE: this is not + * prefixed, the caller should take care of that. + * @return + * Array, both the keys and the values are the matching tables. + */ +function db_find_tables($table_expression) { + return Database::getActiveConnection()->schema()->findTables($table_expression); +} /** * Given a Schema API field type, return the correct %-placeholder. diff --git a/includes/database/schema.inc b/includes/database/schema.inc index 03114d2cd..391db547c 100644 --- a/includes/database/schema.inc +++ b/includes/database/schema.inc @@ -405,6 +405,24 @@ abstract class DatabaseSchema { return $ret; } + /** + * Find all tables that are like the specified base table name. + * + * @param table_expression + * An SQL expression, for example "simpletest%" (without the quotes). + * BEWARE: this is not prefixed, the caller should take care of that. + * @return + * Array, both the keys and the values are the matching tables. + */ + public function findTables($table_expression) { + global $db_prefix; + $info = Database::getConnectionInfo(); + $result = db_query("SELECT table_name FROM information_schema.tables WHERE table_schema = :database AND table_name LIKE :table_name", array( + ':database' => $info['default']['database'], + ':table_name' => $table_expression, + )); + return $result->fetchAllKeyed(0, 0); + } } /** -- cgit v1.2.3