cc-4347: GetCurrentShowInstance got PDO nuked.

This commit is contained in:
Rudi Grinberg 2012-09-10 11:17:45 -04:00
parent 57aae73074
commit 8c3be7393a
1 changed files with 13 additions and 16 deletions

View File

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