cc-4347: PDO'd getInstanceOnDate()

This commit is contained in:
Rudi Grinberg 2012-09-07 15:29:30 -04:00
parent 26a3e35de0
commit 8f3c7e8eba

View file

@ -949,20 +949,24 @@ SQL;
* row in the cc_show_instances table. */
public function getInstanceOnDate($p_dateTime)
{
$con = Propel::getConnection();
$timestamp = $p_dateTime->format("Y-m-d H:i:s");
$showId = $this->getId();
$sql = "SELECT id FROM cc_show_instances"
." WHERE date(starts) = date(TIMESTAMP '$timestamp') "
." AND show_id = $showId AND rebroadcast = 0";
$query = $con->query($sql);
$row = ($query !== false) ? $query->fetchColumn(0) : null;
$sql = <<<SQL
SELECT id
FROM cc_show_instances
WHERE date(starts) = date(TIMESTAMP :timestamp)
AND show_id = :showId
AND rebroadcast = 0;
SQL;
try {
$row = Application_Common_Database::prepareAndExecute( $sql,
array( 'showId' => $this->getId(),
':timestamp' => $timestamp ), 'column');
return CcShowInstancesQuery::create()
->findPk($row);
} catch (Exception $e) {
return null;
}
}
public function deletePossiblyInvalidInstances($p_data, $p_endDate, $isRecorded, $repeatType)
@ -2107,7 +2111,6 @@ WHERE table_name = 'cc_show' AND character_maximum_length > 0
SQL;
$result = $con->query($sql)->fetchAll();
$assocArray = array();
foreach ($result as $row) {
$assocArray[$row['column_name']] = $row['character_maximum_length'];
}