// current running season
            $date_range = "DATE(p.post_date) > '" . $prev->end_date('Y-m-d') . "'";
        } else {
            // anything inbetween
            $date_range = "DATE(p.post_date) >= '" . $this->start_date('Y-m-d') . "' AND DATE(p.post_date) <= '" . $this->end_date('Y-m-d') . "'";
        }
        $sql = "SELECT\n\t\t\t\te.*\n\t\t\tFROM\n\t\t\t\t`" . Episode::table_name() . "` e\n\t\t\t\tJOIN `" . $wpdb->posts . "` p ON e.post_id = p.ID\n\t\t\tWHERE\n\t\t\t\tp.post_type = 'podcast' AND\n\t\t\t\tp.post_status = 'publish' AND\n\t\t\t\t{$date_range}\n\t\t\tORDER BY\n\t\t\t\tp.post_date ASC\n\t\t";
        return Episode::find_all_by_sql($sql);
    }
    /**
     * Season number.
     * 
     * Automatically determined season number.
     * 
     * One season may have no start date and is assumed to be the first season.
     * 
     * @return int
     */
    public function number()
    {
        $seasons = Season::find_all_by_where("start_date < '" . $this->start_date . "' OR start_date IS NULL AND id != " . $this->id);
        return count($seasons) + 1;
    }
}
Season::property('id', 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY');
Season::property('title', 'VARCHAR(255)');
Season::property('subtitle', 'TEXT');
Season::property('summary', 'TEXT');
Season::property('image', 'TEXT');
Season::property('start_date', 'DATE');