cc-4347: deleteRebroadcasts and GetEndTimeOfNextShowWithLiveDJ pdo'd

This commit is contained in:
Rudi Grinberg 2012-09-10 11:39:22 -04:00
parent e2c2f67fbb
commit 3df4c8d65a
1 changed files with 22 additions and 19 deletions

View File

@ -36,17 +36,17 @@ class Application_Model_ShowInstance
public function deleteRebroadcasts() public function deleteRebroadcasts()
{ {
$con = Propel::getConnection();
$timestamp = gmdate("Y-m-d H:i:s"); $timestamp = gmdate("Y-m-d H:i:s");
$instance_id = $this->getShowInstanceId(); $instance_id = $this->getShowInstanceId();
$sql = <<<SQL
$sql = "DELETE FROM cc_show_instances" DELETE FROM cc_show_instances
." WHERE starts > TIMESTAMP '$timestamp'" WHERE starts > :timestamp::TIMESTAMP
." AND instance_id = $instance_id" AND instance_id = :instanceId
." AND rebroadcast = 1"; AND rebroadcast = 1;
SQL;
$con->exec($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 /* 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 // 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) public static function GetEndTimeOfNextShowWithLiveDJ($p_startTime, $p_endTime)
{ {
global $CC_CONFIG; $sql = <<<SQL
$con = Propel::getConnection(); SELECT ends
FROM cc_show_instances AS si
$sql = "SELECT ends JOIN cc_show AS sh ON si.show_id = sh.id
FROM cc_show_instances as si WHERE si.ends > :startTime::TIMESTAMP
JOIN cc_show as sh ON si.show_id = sh.id AND si.ends < :endTime::TIMESTAMP
WHERE si.ends > '$p_startTime' and si.ends < '$p_endTime' and (sh.live_stream_using_airtime_auth or live_stream_using_custom_auth) AND (sh.live_stream_using_airtime_auth
ORDER BY si.ends"; OR live_stream_using_custom_auth)
ORDER BY si.ends";
return $con->query($sql)->fetchAll(); SQL;
return Application_Common_Database::prepareAndExecute( $sql, array(
':startTime' => $p_startTime,
':endTime' => $p_endTime), 'all');
} }
public function isRepeating() public function isRepeating()