diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index d3ee829ac..238b08f27 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -793,22 +793,17 @@ SQL; public static function GetNextShowInstance($p_timeNow) { - global $CC_CONFIG; - $con = Propel::getConnection(); - - $sql = "SELECT si.id" - ." FROM $CC_CONFIG[showInstances] si" - ." WHERE si.starts > TIMESTAMP '$p_timeNow'" - ." AND si.modified_instance = 'f'" - ." ORDER BY si.starts" - ." LIMIT 1"; - - $id = $con->query($sql)->fetchColumn(0); - if ($id) { - return new Application_Model_ShowInstance($id); - } else { - return null; - } + $sql = << :timeNow::TIMESTAMP +AND si.modified_instance = 'f' +ORDER BY si.starts +LIMIT 1 +SQL; + $id = Application_Common_Database::prepareAndExecute( $sql, + array( 'timeNow' => $p_timeNow ), 'column' ); + return ( $id ? new Application_Model_ShowInstance($id) : null ); } // returns number of show instances that ends later than $day