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