Created
May 23, 2012 20:44
-
-
Save tonykwon/2777679 to your computer and use it in GitHub Desktop.
Media Categories Plugin - Slow Query Fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/// | |
// Functions Called From Init | |
/// | |
public function CheckForTermOrderColumn() | |
{ | |
global $wpdb; | |
//-- CHECK FOR term_order column --- | |
$query = " | |
SELECT COUNT(*) FROM information_schema.COLUMNS | |
WHERE | |
TABLE_SCHEMA = '" . DB_NAME . "' | |
AND TABLE_NAME = '$wpdb->terms' | |
AND COLUMN_NAME = 'term_order'; | |
"; | |
$row_count = $wpdb->get_var( $wpdb->prepare( $query ) ); | |
//-- END CHECK FOR term_order column --- | |
//-- IF term_order column doesnt exist re-add it --- | |
$query = " | |
ALTER TABLE $wpdb->terms ADD term_order int(4) NOT NULL default 0;; | |
"; | |
if($row_count==0) | |
{ | |
$wpdb->query($query); | |
} | |
//-- END IF term_order column doesnt exist re-add it --- | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment