[mythtv] patch: movies, years/stars/ratings

Andy Davidoff dert at pobox.com
Fri Mar 7 19:03:47 EST 2003


Apparently, I was forgetting those poor users without recordings scheduled.
This patch generously allows them to see listings as well.


#if Andy Davidoff /* Mar 07, 05:53 */
> I'm probably forgetting something.
#endif /* dert at pobox.com */
-------------- next part --------------
Index: mythweb/functions.php
===================================================================
RCS file: /var/lib/cvs/mythweb/functions.php,v
retrieving revision 1.13
diff -d -u -w -r1.13 functions.php
--- mythweb/functions.php	7 Mar 2003 19:35:49 -0000	1.13
+++ mythweb/functions.php	8 Mar 2003 00:00:41 -0000
@@ -352,6 +352,14 @@
 	return $channelarray;
 }
 
+function singleSelect($query)
+{
+	$result = mysql_query($query) or die("Error in simpleSelect('$query').");
+	$data = mysql_fetch_array($result, MYSQL_ASSOC);
+	mysql_free_result($result);
+	return $data;
+}
+
 //
 //	So, anything good on TV?
 //
@@ -360,20 +368,31 @@
 	$maxStars = $GLOBALS['maximumStarRating'];
 	$star = $GLOBALS['starRatingCharacter'];
 
-	for ($i = 0; $i < $numbSlots; $i += 1)
+	$rec = singleSelect("select count(*) as 'recordings' from record;");
+	if ((int) $rec['recordings'] > 0)
 	{
-		$channelindex = 0;
-		$mytime = $timearray[$i];
-
-		$query = "SELECT ".
-			"sum(record.type = 4 and program.title = record.title)>0 as 'type4', ".
+		$recordFrom = ", record ";
+		$recordSelect =	"sum(record.type = 4 and program.title = record.title)>0 as 'type4', ".
 			"sum(record.type = 3 and program.title = record.title and record.chanid = program.chanid)>0 as 'type3', ".
 			"sum(record.type = 2 and program.title = record.title and record.chanid = program.chanid and ".
 			"     record.starttime = sec_to_time(time_to_sec(program.starttime)) and ".
 			"     record.endtime = sec_to_time(time_to_sec(program.endtime)))>0 as 'type2', " .
 			"sum(record.type = 1 and program.title = record.title and record.chanid = program.chanid and ".
 			"     record.starttime = sec_to_time(time_to_sec(program.starttime)) and ".
-			"     record.startdate = from_days(to_days(program.starttime)))>0 as 'type1', ".
+						"     record.startdate = from_days(to_days(program.starttime)))>0 as 'type1', ";
+	}
+	else
+	{
+		$recordFrom = "";
+		$recordSelect = "";
+	}
+
+	for ($i = 0; $i < $numbSlots; $i += 1)
+	{
+		$channelindex = 0;
+		$mytime = $timearray[$i];
+
+		$query = "SELECT ".$recordSelect.
 			"channel.chanid, ".
 			"channel.channum, ".
 			"program.starttime, ".
@@ -388,7 +407,7 @@
 			"ifnull(programrating.system, '') as rater, ".
 			"ifnull(programrating.rating, '') as rating, ".
 			"((UNIX_TIMESTAMP(program.endtime) - UNIX_TIMESTAMP(program.starttime)) / 60 ) as duration ".
-			"FROM channel left join program using (chanid) left join programrating using (chanid, starttime), record ".
+			"FROM channel left join program using (chanid) left join programrating using (chanid, starttime) ".$recordFrom.
 			"WHERE program.starttime < " . $mytime->sqltime . " AND program.endtime > " . $mytime->sqltime." ".
 			"GROUP BY program.chanid ORDER BY channel.channum + 0, programrating.system;";
 


More information about the mythtv-dev mailing list