diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index ef2521ad5..d3ee829ac 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -769,29 +769,26 @@ SQL; public static function GetCurrentShowInstance($p_timeNow) { - global $CC_CONFIG; - $con = Propel::getConnection(); - /* Orderby si.starts descending, because in some cases * we can have multiple shows overlapping each other. In * this case, the show that started later is the one that * is actually playing, and so this is the one we want. */ - $sql = "SELECT si.id" - ." FROM $CC_CONFIG[showInstances] si" - ." WHERE si.starts <= TIMESTAMP '$p_timeNow'" - ." AND si.ends > TIMESTAMP '$p_timeNow'" - ." AND si.modified_instance = 'f'" - ." ORDER BY si.starts DESC" - ." LIMIT 1"; + $sql = << :timeNow2::TIMESTAMP + AND si.modified_instance = 'f' +ORDER BY si.starts DESC LIMIT 1 +SQL; - $id = $con->query($sql)->fetchColumn(0); - if ($id) { - return new Application_Model_ShowInstance($id); - } else { - return null; - } + $id = Application_Common_Database( $sql, array( + ':timeNow1' => $p_timeNow, + ':timeNow2' => $p_timeNow ), 'column'); + + return ( $id ? new Application_Model_ShowInstance($id) : null ); } public static function GetNextShowInstance($p_timeNow)