Update sql for NOT IN in the correct place.
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 14 May 2018 18:08:56 +0000 (14:08 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 14 May 2018 18:08:56 +0000 (14:08 -0400)
Placing NOT IN outside sub select.

models/front/events/baseAction.php

index db8ead9..6e2412c 100644 (file)
@@ -278,18 +278,17 @@ abstract class GlmMembersFront_events_baseAction extends GlmDataEvents
             }
         } else if ( $this->notInCat && !empty( $this->notInCat ) ) {
             $whereParts[] = "
-                T.id IN (
+                T.id NOT IN (
                     SELECT event
                       FROM " .GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "event_categories
-                     WHERE category NOT IN (" . implode( ',', $this->notInCat ) . ")
-                    AND event IN (
+                     WHERE category IN (" . implode( ',', $this->notInCat ) . ")
+                    )";
+            $whereParts[] = "T.id IN (
                             SELECT event
                               FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times AS ET
                              WHERE status = " . $this->config['status_numb']['Active'] . "
                                AND " . $this->dateRange . "
-                        )
-                    )
-                ";
+                        ) ";
             $order = "T.id";
             if ( $limit = filter_var( $limit, FILTER_VALIDATE_INT ) ) {
                 $order .= " LIMIT {$limit} OFFSET 0";