From e027822f45cab9cb27fd9029009006bfb0202b48 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 27 Jan 2009 22:35:21 +0000 Subject: [PATCH] Optimize maybe_create_table(). Props jamescollins. fixes #8977 git-svn-id: http://svn.automattic.com/wordpress/trunk@10447 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/upgrade.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 4919fd4317..f41422b576 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -926,19 +926,13 @@ function upgrade_270() { */ function maybe_create_table($table_name, $create_ddl) { global $wpdb; - foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) { - if ($table == $table_name) { - return true; - } - } + if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name ) + return true; //didn't find it try to create it. $q = $wpdb->query($create_ddl); // we cannot directly tell that whether this succeeded! - foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) { - if ($table == $table_name) { - return true; - } - } + if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name ) + return true; return false; }