Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
denise 2012-09-06 11:11:15 -04:00
commit b25ce921ee
2 changed files with 18 additions and 14 deletions

View File

@ -1,7 +1,8 @@
<?php <?php
class Application_Common_Database class Application_Common_Database
{ {
public static function prepareAndExecute($sql, array $paramValueMap, $type='all', $fetchType=PDO::FETCH_ASSOC) public static function prepareAndExecute($sql, array $paramValueMap,
$type='all', $fetchType=PDO::FETCH_ASSOC)
{ {
$con = Propel::getConnection(); $con = Propel::getConnection();
$stmt = $con->prepare($sql); $stmt = $con->prepare($sql);

View File

@ -1063,23 +1063,25 @@ SQL;
* In both cases (new and edit) we only grab shows that * In both cases (new and edit) we only grab shows that
* are scheduled 2 days prior * are scheduled 2 days prior
*/ */
$se = $show_end->format('Y-m-d H:i:s'); //$se = $show_end->format('Y-m-d H:i:s');
if ($update) { if ($update) {
$sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]." $sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]."
where (ends <= '{$show_end->format('Y-m-d H:i:s')}' where (ends <= '{$show_end->format('Y-m-d H:i:s')}'
or starts <= '{$show_end->format('Y-m-d H:i:s')}') or starts <= '{$show_end->format('Y-m-d H:i:s')}')
and date(starts) >= (date('{$show_end->format('Y-m-d H:i:s')}') - INTERVAL '2 days') and date(starts) >= (date('{$show_end->format('Y-m-d H:i:s')}') - INTERVAL '2 days')
and modified_instance = false and id != ".$instanceId. " order by ends"; and modified_instance = false and id != ".$instanceId. " order by ends";
$stmt = $con->prepare("SELECT id, starts, ends FROM :showInstances
$stmt = $con->prepare("SELECT id, starts, ends FROM {$CC_CONFIG['showInstances']}
where (ends <= :show_end1 where (ends <= :show_end1
or starts <= :show_end2) or starts <= :show_end2)
and date(starts) >= (date(:show_end3) - INTERVAL '2 days') and date(starts) >= (date(:show_end3) - INTERVAL '2 days')
and modified_instance = false and id != :instanceId order by ends"); and modified_instance = false and id != :instanceId order by ends");
$stmt->execute(array( $stmt->execute(array(
':showInstances' => $CC_CONFIG['showInstances'], ':showInstances' => $CC_CONFIG['showInstances'],
':show_end1' => $se, ':show_end1' => $show_end->format('Y-m-d H:i:s'),
':show_end2' => $se, ':show_end2' => $show_end->format('Y-m-d H:i:s'),
':show_end3' => $se, ':show_end3' => $show_end->format('Y-m-d H:i:s'),
':instanceId' => $instanceId ':instanceId' => $instanceId
)); ));
} else { } else {
@ -1089,16 +1091,17 @@ SQL;
or starts <= '{$show_end->format('Y-m-d H:i:s')}') or starts <= '{$show_end->format('Y-m-d H:i:s')}')
and date(starts) >= (date('{$show_end->format('Y-m-d H:i:s')}') - INTERVAL '2 days') and date(starts) >= (date('{$show_end->format('Y-m-d H:i:s')}') - INTERVAL '2 days')
and modified_instance = false order by ends"; and modified_instance = false order by ends";
$stmt = $con->prepare("SELECT id, starts, ends FROM :showInstances
where (ends <= :show_end1 $stmt = $con->prepare("SELECT id, starts, ends FROM
or starts <= :show_end2) {$CC_CONFIG['showInstances']}
where (ends <= :show_end1 or starts <= :show_end2)
and date(starts) >= (date(:show_end3) - INTERVAL '2 days') and date(starts) >= (date(:show_end3) - INTERVAL '2 days')
and modified_instance = false order by ends"); and modified_instance = false order by ends");
$stmt->execute(array( $stmt->execute(array(
':showInstances' => $CC_CONFIG['showInstances'], ':show_end1' => $show_end->format('Y-m-d H:i:s'),
':show_end1' => $se, ':show_end2' => $show_end->format('Y-m-d H:i:s'),
':show_end2' => $se, ':show_end3' => $show_end->format('Y-m-d H:i:s')
':show_end3' => $se,
)); ));
} }
//$rows = $con->query($sql); //$rows = $con->query($sql);
@ -1106,7 +1109,7 @@ SQL;
foreach ($rows as $row) { foreach ($rows as $row) {
$start = new DateTime($row["starts"], new DateTimeZone('UTC')); $start = new DateTime($row["starts"], new DateTimeZone('UTC'));
$end = new DateTime($row["ends"], new DateTimeZone('UTC')); $end = new DateTime($row["ends"], new DateTimeZone('UTC'));
if ($show_start->getTimestamp() < $end->getTimestamp() && if ($show_start->getTimestamp() < $end->getTimestamp() &&
$show_end->getTimestamp() > $start->getTimestamp()) { $show_end->getTimestamp() > $start->getTimestamp()) {