replaces mysql_* function calls with $wpdb api calls