Fix dateRange for one day search.
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 7 Nov 2016 19:11:40 +0000 (14:11 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 7 Nov 2016 19:11:40 +0000 (14:11 -0500)
Fix the sql for times as sub select.

models/front/events/baseAction.php
models/front/events/list.php

index 4e48495..b1853de 100644 (file)
@@ -298,7 +298,6 @@ abstract class GlmMembersFront_events_baseAction extends GlmDataEvents
         if ( isset( $whereParts ) && !empty( $whereParts ) ) {
             $where = implode( ' AND ', $whereParts);
         }
-        //echo '<pre>$where: ' . print_r( $where, true ) . '</pre>';
 
         $events = $this->getList( $where, $order );
 
index 63ddb6d..5c3c779 100644 (file)
@@ -210,11 +210,13 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
                 if ( $eventDay ) {
                     $fromDate = $toDate = $eventDay;
                     $from = $to = date( 'Y-m-d', strtotime( $eventDay ) );
+                    $this->dateRange = "id IN (
+                        SELECT id
+                          FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
+                         WHERE DATE(start_time) = '{$from}')";
                 }
             }
-            $this->dateRange = "start_time <= CAST('{$from}' AS DATE) AND start_time >= CAST('{$to}' as DATE)";
         }
-        //echo '<pre>dateRange: ' . print_r( $this->dateRange, true ) . '</pre>';
 
         if ( isset( $_REQUEST['event_name'] )
             && $eventNameSearch = filter_var( $_REQUEST['event_name'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES ) ) {