Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Episodes table
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `show_id` int(11) DEFAULT NULL,
- `title` varchar(255) DEFAULT NULL,
- `season` int(11) DEFAULT NULL,
- `epnum` int(11) DEFAULT NULL,
- `seasonnum` int(11) DEFAULT NULL,
- `airdate` varchar(255) DEFAULT NULL,
- `link` varchar(255) DEFAULT NULL,
- `created_at` datetime DEFAULT NULL,
- `updated_at` datetime DEFAULT NULL,
- PRIMARY KEY (`id`)
- ## Shows table
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `show_id` int(11) DEFAULT NULL,
- `title` varchar(255) DEFAULT NULL,
- `season` int(11) DEFAULT NULL,
- `epnum` int(11) DEFAULT NULL,
- `seasonnum` int(11) DEFAULT NULL,
- `airdate` varchar(255) DEFAULT NULL,
- `link` varchar(255) DEFAULT NULL,
- `created_at` datetime DEFAULT NULL,
- `updated_at` datetime DEFAULT NULL,
- ## Finder
- @shows = Show.find(:all, :include => :episodes, :conditions => ["episodes.airdate >= ?", Date.today], :order => "episodes.airdate, shows.airtime desc")
- ## SQL
- SELECT `shows`.`id` AS t0_r0, `shows`.`showid` AS t0_r1, `shows`.`name` AS t0_r2, `shows`.`started` AS t0_r3, `shows`.`ended` AS t0_r4, `shows`.`airday` AS t0_r5, `shows`.`airtime` AS t0_r6, `shows`.`network` AS t0_r7, `shows`.`showlink` AS t0_r8, `shows`.`created_at` AS t0_r9, `shows`.`updated_at` AS t0_r10, `episodes`.`id` AS t1_r0, `episodes`.`show_id` AS t1_r1, `episodes`.`title` AS t1_r2, `episodes`.`season` AS t1_r3, `episodes`.`epnum` AS t1_r4, `episodes`.`seasonnum` AS t1_r5, `episodes`.`airdate` AS t1_r6, `episodes`.`link` AS t1_r7, `episodes`.`created_at` AS t1_r8, `episodes`.`updated_at` AS t1_r9 FROM `shows` LEFT OUTER JOIN `episodes` ON episodes.show_id = shows.id WHERE (episodes.airdate >= '2009-08-30' OR episodes.id IS NULL) ORDER BY episodes.airdate, shows.airtime desc
- ## Problem
- It only returns episodes in the future, so if a TV program doesn't have any scheduled episodes, it isn't in the list. How can I get around that?
Add Comment
Please, Sign In to add comment