Ticket #14273: maybe_create_table.2.diff
| File maybe_create_table.2.diff, 1.2 KB (added by , 14 years ago) |
|---|
-
wp-admin/install-helper.php
51 51 * @param string $create_ddl Create database table SQL. 52 52 * @return bool False on error, true if already exists or success. 53 53 */ 54 function maybe_create_table( $table_name, $create_ddl) {54 function maybe_create_table( $table_name, $create_ddl ) { 55 55 global $wpdb; 56 foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {57 if ($table == $table_name) {58 return true;59 } 60 }61 //didn't find it try to create it.62 $wpdb->query($create_ddl); 56 $query = $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ); 57 if ( strtolower( $wpdb->get_var( $query ) ) == strtolower( $table_name ) ) 58 return true; 59 60 // Didn't find it, so we need to try to create it. 61 $wpdb->query( $create_ddl ); 62 63 63 // we cannot directly tell that whether this succeeded! 64 foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) { 65 if ($table == $table_name) { 66 return true; 67 } 68 } 69 return false; 64 return ( strtolower( $wpdb->get_var( $query ) ) == strtolower( $table_name ) ); 70 65 } 71 66 endif; 72 67