Optimize maybe_create_table(). Props jamescollins. fixes #8977

git-svn-id: https://develop.svn.wordpress.org/trunk@10447 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2009-01-27 22:35:21 +00:00
parent 5c33a003d8
commit 2683a27a8b
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;
}