Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: Display people in priority order when displaying program details #87

Open
garybuhrmaster opened this issue Apr 10, 2023 · 0 comments

Comments

@garybuhrmaster
Copy link
Contributor

In a follow up to #40 and #71, here is a code fragment that is mysql/mariadb complaint (test on all known/current supported mysql/mariadb versions without requiring sql_mode overrides).

Given that mythweb has a very short future lifetime, it is not clear if this a worthwhile patch, but it is now available if needed....

As I am about to delete my mythweb fork, and that means a PR would get auto deleted, this is inline.

diff --git a/modules/tv/classes/Program.php b/modules/tv/classes/Program.php
index d84a3d9f..a5d4ca77 100644
--- a/modules/tv/classes/Program.php
+++ b/modules/tv/classes/Program.php
@@ -556,9 +556,10 @@ class Program extends MythBase {
     public function has_credits() {
         global $db;
         return $db->query_col('SELECT COUNT(people.name)
-                                 FROM credits, people
-                                WHERE credits.person    = people.person
-                                  AND credits.chanid    = ?
+                                 FROM credits
+                            LEFT JOIN people
+                                   ON credits.person    = people.person
+                                WHERE credits.chanid    = ?
                                   AND credits.starttime = FROM_UNIXTIME(?)',
                               $this->chanid,
                               $this->starttime
@@ -573,13 +574,17 @@ class Program extends MythBase {
     // No cached value -- load it
         if (!isset($this->credits[$role][$add_search_links])) {
         // Get the credits for the requested role
-            $result = $db->query('SELECT DISTINCT people.name
-                                     FROM credits, people
-                                    WHERE credits.person    = people.person
-                                      AND credits.role      = ?
-                                      AND credits.chanid    = ?
-                                      AND credits.starttime = FROM_UNIXTIME(?)
-                                      ORDER BY credits.priority',
+            $result = $db->query('SELECT p.name
+                                    FROM (
+                                              SELECT DISTINCT people.name, credits.priority
+                                                FROM credits
+                                           LEFT JOIN people
+                                                  ON credits.person    = people.person
+                                               WHERE credits.role      = ?
+                                                 AND credits.chanid    = ?
+                                                 AND credits.starttime = FROM_UNIXTIME(?)
+                                            ORDER BY credits.priority
+                                         ) p',
                                    $role,
                                    $this->chanid,
                                    $this->starttime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant