From 3df4c8d65ad78abd2b956aef79d033c8674eee87 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 11:39:22 -0400 Subject: [PATCH] cc-4347: deleteRebroadcasts and GetEndTimeOfNextShowWithLiveDJ pdo'd --- .../application/models/ShowInstance.php | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index c19d8c3b7..03a4d60a2 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -36,17 +36,17 @@ class Application_Model_ShowInstance public function deleteRebroadcasts() { - $con = Propel::getConnection(); - $timestamp = gmdate("Y-m-d H:i:s"); $instance_id = $this->getShowInstanceId(); - - $sql = "DELETE FROM cc_show_instances" - ." WHERE starts > TIMESTAMP '$timestamp'" - ." AND instance_id = $instance_id" - ." AND rebroadcast = 1"; - - $con->exec($sql); + $sql = << :timestamp::TIMESTAMP +AND instance_id = :instanceId +AND rebroadcast = 1; +SQL; + Application_Common_Database::prepareAndExecute( $sql, array( + ':instanceId' => $instance_id, + ':timestamp' => $timestamp), 'execute'); } /* This function is weird. It should return a boolean, but instead returns @@ -821,16 +821,19 @@ SQL; // this returns end timestamp of all shows that are in the range and has live DJ set up public static function GetEndTimeOfNextShowWithLiveDJ($p_startTime, $p_endTime) { - global $CC_CONFIG; - $con = Propel::getConnection(); - - $sql = "SELECT ends - FROM cc_show_instances as si - JOIN cc_show as sh ON si.show_id = sh.id - WHERE si.ends > '$p_startTime' and si.ends < '$p_endTime' and (sh.live_stream_using_airtime_auth or live_stream_using_custom_auth) - ORDER BY si.ends"; - - return $con->query($sql)->fetchAll(); + $sql = << :startTime::TIMESTAMP + AND si.ends < :endTime::TIMESTAMP + AND (sh.live_stream_using_airtime_auth + OR live_stream_using_custom_auth) +ORDER BY si.ends"; +SQL; + return Application_Common_Database::prepareAndExecute( $sql, array( + ':startTime' => $p_startTime, + ':endTime' => $p_endTime), 'all'); } public function isRepeating()