WordPress.org

Make WordPress Core

Changeset 10447


Ignore:
Timestamp:
01/27/2009 10:35:21 PM (9 years ago)
Author:
ryan
Message:

Optimize maybe_create_table(). Props jamescollins. fixes #8977

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/upgrade.php

    r10150 r10447  
    927927function maybe_create_table($table_name, $create_ddl) {
    928928    global $wpdb;
    929     foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
    930         if ($table == $table_name) {
    931             return true;
    932         }
    933     }
     929    if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name )
     930        return true;
    934931    //didn't find it try to create it.
    935932    $q = $wpdb->query($create_ddl);
    936933    // we cannot directly tell that whether this succeeded!
    937     foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
    938         if ($table == $table_name) {
    939             return true;
    940         }
    941     }
     934    if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name )
     935        return true;
    942936    return false;
    943937}
Note: See TracChangeset for help on using the changeset viewer.