Optimize maybe_create_table(). Props jamescollins. fixes #8977

git-svn-id: http://svn.automattic.com/wordpress/trunk@10447 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-01-27 22:35:21 +00:00
parent 2724b924d6
commit e027822f45
1 changed files with 4 additions and 10 deletions

View File

@ -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;
}