Completely changed to fit $wpdb