CC-2997: Daylight savings time affects repeating shows.

-should work now
This commit is contained in:
Martin Konecny 2011-10-25 16:49:44 -04:00
parent 43721e138d
commit d26e410799

View file

@ -434,7 +434,7 @@ class Application_Model_Show {
} }
} }
/** /**
* Get the end date of the current show. * Get the end date of the current show.
* Note that this is not the end date of repeated show * Note that this is not the end date of repeated show
* *
@ -577,10 +577,10 @@ class Application_Model_Show {
public function getDuration($format=false){ public function getDuration($format=false){
$showDay = CcShowDaysQuery::create()->filterByDbShowId($this->getId())->findOne(); $showDay = CcShowDaysQuery::create()->filterByDbShowId($this->getId())->findOne();
if(!$format){ if(!$format){
return $showDay->getDbDuration(); return $showDay->getDbDuration();
}else{ }else{
$info = explode(':',$showDay->getDbDuration()); $info = explode(':',$showDay->getDbDuration());
return ($info[0] != 0 ? intval($info[0]).'h'.' ' : '').($info[1] != 0 ? intval($info[1]).'m' : ''); return ($info[0] != 0 ? intval($info[0]).'h'.' ' : '').($info[1] != 0 ? intval($info[1]).'m' : '');
} }
} }
@ -604,16 +604,18 @@ class Application_Model_Show {
return $showInstances; return $showInstances;
} }
public function hasInstanceOnDate($p_timestamp){ public function hasInstanceOnDate($p_dateTime){
return (!is_null($this->getInstanceOnDate($p_timestamp))); return (!is_null($this->getInstanceOnDate($p_dateTeim)));
} }
public function getInstanceOnDate($p_timestamp){ public function getInstanceOnDate($p_dateTime){
global $CC_DBC; global $CC_DBC;
$timestamp = $p_dateTime->getTimestamp();
$showId = $this->getId(); $showId = $this->getId();
$sql = "SELECT id FROM cc_show_instances" $sql = "SELECT id FROM cc_show_instances"
." WHERE date(starts) = date(TIMESTAMP '$p_timestamp') " ." WHERE date(starts) = date(TIMESTAMP '$timestamp') "
." AND show_id = $showId"; ." AND show_id = $showId";
$row = $CC_DBC->GetOne($sql); $row = $CC_DBC->GetOne($sql);
@ -726,7 +728,7 @@ class Application_Model_Show {
{ {
$startDateTime = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time']); $startDateTime = new DateTime($data['add_show_start_date']." ".$data['add_show_start_time']);
$utcStartDateTime = clone $startDateTime; $utcStartDateTime = clone $startDateTime;
$utcStartDateTime->setTimezone(new DateTimeZone('UTC')); $utcStartDateTime->setTimezone(new DateTimeZone('UTC'));
if ($data['add_show_no_end']) { if ($data['add_show_no_end']) {
@ -746,8 +748,8 @@ class Application_Model_Show {
} }
//What we are doing here is checking if the show repeats or if //What we are doing here is checking if the show repeats or if
//any repeating days have been checked. If not, then by default //any repeating days have been checked. If not, then by default
//the "selected" DOW is the initial day. //the "selected" DOW is the initial day.
$startDow = date("w", $utcStartDateTime->getTimestamp()); $startDow = date("w", $utcStartDateTime->getTimestamp());
if (!$data['add_show_repeats']) { if (!$data['add_show_repeats']) {
$data['add_show_day_check'] = array($startDow); $data['add_show_day_check'] = array($startDow);
@ -792,7 +794,7 @@ class Application_Model_Show {
$showDay->setDbFirstShow($startDateTime->format("Y-m-d")); $showDay->setDbFirstShow($startDateTime->format("Y-m-d"));
$showDay->setDbLastShow($endDate); $showDay->setDbLastShow($endDate);
$showDay->setDbStartTime($startDateTime->format("H:i:s")); $showDay->setDbStartTime($startDateTime->format("H:i:s"));
$showDay->setDbTimezone(date_default_timezone_get()); $showDay->setDbTimezone(date_default_timezone_get());
$showDay->setDbDuration($data['add_show_duration']); $showDay->setDbDuration($data['add_show_duration']);
$showDay->setDbRepeatType($repeatType); $showDay->setDbRepeatType($repeatType);
$showDay->setDbShowId($showId); $showDay->setDbShowId($showId);
@ -800,8 +802,8 @@ class Application_Model_Show {
$showDay->save(); $showDay->save();
} else { } else {
foreach ($data['add_show_day_check'] as $day) { foreach ($data['add_show_day_check'] as $day) {
$daysAdd=0; $daysAdd=0;
$startDateTimeClone = clone $startDateTime; $startDateTimeClone = clone $startDateTime;
if ($startDow !== $day){ if ($startDow !== $day){
if ($startDow > $day) if ($startDow > $day)
$daysAdd = 6 - $startDow + 1 + $day; $daysAdd = 6 - $startDow + 1 + $day;
@ -815,7 +817,7 @@ class Application_Model_Show {
$showDay->setDbFirstShow($startDateTimeClone->format("Y-m-d")); $showDay->setDbFirstShow($startDateTimeClone->format("Y-m-d"));
$showDay->setDbLastShow($endDate); $showDay->setDbLastShow($endDate);
$showDay->setDbStartTime($startDateTimeClone->format("H:i")); $showDay->setDbStartTime($startDateTimeClone->format("H:i"));
$showDay->setDbTimezone(date_default_timezone_get()); $showDay->setDbTimezone(date_default_timezone_get());
$showDay->setDbDuration($data['add_show_duration']); $showDay->setDbDuration($data['add_show_duration']);
$showDay->setDbDay($day); $showDay->setDbDay($day);
$showDay->setDbRepeatType($repeatType); $showDay->setDbRepeatType($repeatType);
@ -881,7 +883,7 @@ class Application_Model_Show {
Application_Model_RabbitMq::PushSchedule(); Application_Model_RabbitMq::PushSchedule();
return $showId; return $showId;
} }
/** /**
* Generate repeating show instances for a single show up to the given date. * Generate repeating show instances for a single show up to the given date.
* If no date is given, use the one in the user's preferences, which is stored * If no date is given, use the one in the user's preferences, which is stored
@ -889,18 +891,20 @@ class Application_Model_Show {
* has looked at. * has looked at.
* *
* @param int $p_showId * @param int $p_showId
* @param string $p_endTimestamp * @param DateTime $p_dateTime
* In the format "YYYY-MM-DD HH:mm:ss, non-UTC" * DateTime object in UTC time.
*/ */
public static function populateShowUntil($p_showId, $p_endTimestamp = NULL) public static function populateShowUntil($p_showId, $p_dateTime = NULL)
{ {
global $CC_DBC; global $CC_DBC;
if (is_null($p_endTimestamp)) { if (is_null($p_endTimestamp)) {
$p_endTimestamp = Application_Model_Preference::GetShowsPopulatedUntil(); $date = Application_Model_Preference::GetShowsPopulatedUntil();
if ($p_endTimestamp == "") { if ($date == "") {
$today_timestamp = date("Y-m-d"); $p_dateTime = new DateTime("now", new DateTimeZone('UTC'));
Application_Model_Preference::SetShowsPopulatedUntil($today_timestamp); Application_Model_Preference::SetShowsPopulatedUntil($p_dateTime->format("Y-m-d"));
} else {
$p_dateTime = new DateTime($date, new DateTimeZone('UTC'));
} }
} }
@ -908,49 +912,67 @@ class Application_Model_Show {
$res = $CC_DBC->GetAll($sql); $res = $CC_DBC->GetAll($sql);
foreach ($res as $showRow) { foreach ($res as $showRow) {
Application_Model_Show::populateShow($showRow, $p_endTimestamp); Application_Model_Show::populateShow($showRow, $p_dateTime);
} }
} }
private static function populateShow($p_showRow, $p_endTimestamp) { /**
* We are going to use cc_show_days as a template, to generate Show Instances. This function
* is basically a dispatcher that looks at the show template, and sends it to the correct function
* so that Show Instance generation can begin. After the all show instances have been created, pushes
* the schedule to Pypo.
*
* @param array $p_showRow
* A row from cc_show_days table
* @param DateTime $p_dateTime
* DateTime object in UTC time.
*/
private static function populateShow($p_showRow, $p_dateTime) {
if($p_showRow["repeat_type"] == -1) { if($p_showRow["repeat_type"] == -1) {
Application_Model_Show::populateNonRepeatingShow($p_showRow, $p_endTimestamp); Application_Model_Show::populateNonRepeatingShow($p_showRow, $p_dateTime);
} }
else if($p_showRow["repeat_type"] == 0) { else if($p_showRow["repeat_type"] == 0) {
Application_Model_Show::populateRepeatingShow($p_showRow, $p_endTimestamp, '7 days'); Application_Model_Show::populateRepeatingShow($p_showRow, $p_dateTime, 'P7D');
} }
else if($p_showRow["repeat_type"] == 1) { else if($p_showRow["repeat_type"] == 1) {
Application_Model_Show::populateRepeatingShow($p_showRow, $p_endTimestamp, '14 days'); Application_Model_Show::populateRepeatingShow($p_showRow, $p_dateTime, 'P14D');
} }
else if($p_showRow["repeat_type"] == 2) { else if($p_showRow["repeat_type"] == 2) {
Application_Model_Show::populateRepeatingShow($p_showRow, $p_endTimestamp, '1 month'); Application_Model_Show::populateRepeatingShow($p_showRow, $p_dateTime, 'P1M');
} }
Application_Model_RabbitMq::PushSchedule(); Application_Model_RabbitMq::PushSchedule();
} }
//for a show with repeat_type == -1 /**
private static function populateNonRepeatingShow($p_showRow, $end_timestamp) * Creates a single show instance. If the show is recorded, it may have multiple
* rebroadcast dates, and so this function will create those as well.
*
* @param array $p_showRow
* A row from cc_show_days table
* @param DateTime $p_dateTime
* DateTime object in UTC time.
*/
private static function populateNonRepeatingShow($p_showRow, $p_dateTime)
{ {
global $CC_DBC; global $CC_DBC;
$show_id = $p_showRow["show_id"]; $show_id = $p_showRow["show_id"];
$first_show = $p_showRow["first_show"]; //non-UTC $first_show = $p_showRow["first_show"]; //non-UTC
$start_time = $p_showRow["start_time"]; //non-UTC $start_time = $p_showRow["start_time"]; //non-UTC
$duration = $p_showRow["duration"]; $duration = $p_showRow["duration"];
$day = $p_showRow["day"]; $day = $p_showRow["day"];
$record = $p_showRow["record"]; $record = $p_showRow["record"];
$timezone = $p_showRow["timezone"]; $timezone = $p_showRow["timezone"];
$start = $first_show." ".$start_time; $start = $first_show." ".$start_time;
$utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone);
$utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone);
$utcStart = $utcStartDateTime->format("Y-m-d H:i:s");
if (strtotime($utcStart) < strtotime($end_timestamp)) { if ($utcStartDateTime->getTimestamp() < $p_dateTime->getTimestamp()) {
$utcStart = $utcStartDateTime->format("Y-m-d H:i:s");
$sql = "SELECT timestamp '{$utcStart}' + interval '{$duration}'"; $sql = "SELECT timestamp '{$utcStart}' + interval '{$duration}'";
$utcEnd = $CC_DBC->GetOne($sql); $utcEndDateTime = new DateTime($CC_DBC->GetOne($sql), new DateTimeZone("UTC"));
$date = new Application_Model_DateHelper(); $date = new Application_Model_DateHelper();
$currentUtcTimestamp = $date->getUtcTimestamp(); $currentUtcTimestamp = $date->getUtcTimestamp();
@ -959,16 +981,15 @@ class Application_Model_Show {
if ($show->hasInstance()){ if ($show->hasInstance()){
$ccShowInstance = $show->getInstance(); $ccShowInstance = $show->getInstance();
$newInstance = false; $newInstance = false;
} } else {
else {
$ccShowInstance = new CcShowInstances(); $ccShowInstance = new CcShowInstances();
$newInstance = true; $newInstance = true;
} }
if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp){ if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp){
$ccShowInstance->setDbShowId($show_id); $ccShowInstance->setDbShowId($show_id);
$ccShowInstance->setDbStarts($utcStart); $ccShowInstance->setDbStarts($utcStartDateTime);
$ccShowInstance->setDbEnds($utcEnd); $ccShowInstance->setDbEnds($utcEndDateTime);
$ccShowInstance->setDbRecord($record); $ccShowInstance->setDbRecord($record);
$ccShowInstance->save(); $ccShowInstance->save();
} }
@ -981,46 +1002,38 @@ class Application_Model_Show {
} }
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}"; $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
Logging::log($sql);
$rebroadcasts = $CC_DBC->GetAll($sql); $rebroadcasts = $CC_DBC->GetAll($sql);
foreach($rebroadcasts as $rebroadcast) { self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $utcStartDateTime, $duration);
$timeinfo = explode(" ", $utcStart);
$sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
$rebroadcast_start_time = $CC_DBC->GetOne($sql);
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
if ($rebroadcast_start_time > $currentUtcTimestamp){
$newRebroadcastInstance = new CcShowInstances();
$newRebroadcastInstance->setDbShowId($show_id);
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
$newRebroadcastInstance->setDbEnds($rebroadcast_end_time);
$newRebroadcastInstance->setDbRecord(0);
$newRebroadcastInstance->setDbRebroadcast(1);
$newRebroadcastInstance->setDbOriginalShow($show_instance_id);
$newRebroadcastInstance->save();
}
}
} }
} }
//for a show with repeat_type == 0,1,2 /**
private static function populateRepeatingShow($p_showRow, $end_timestamp, $interval) * Creates a 1 or more than 1 show instances (user has stated this show repeats). If the show
* is recorded, it may have multiple rebroadcast dates, and so this function will create
* those as well.
*
* @param array $p_showRow
* A row from cc_show_days table
* @param DateTime $p_dateTime
* DateTime object in UTC time.
* @param string $p_interval
* Period of time between repeating shows
*/
private static function populateRepeatingShow($p_showRow, $p_dateTime, $p_interval)
{ {
global $CC_DBC; global $CC_DBC;
$show_id = $p_showRow["show_id"]; $show_id = $p_showRow["show_id"];
$next_pop_date = $p_showRow["next_pop_date"]; $next_pop_date = $p_showRow["next_pop_date"];
$first_show = $p_showRow["first_show"]; //non-UTC $first_show = $p_showRow["first_show"]; //non-UTC
$last_show = $p_showRow["last_show"]; //non-UTC $last_show = $p_showRow["last_show"]; //non-UTC
$start_time = $p_showRow["start_time"]; //non-UTC $start_time = $p_showRow["start_time"]; //non-UTC
$duration = $p_showRow["duration"]; $duration = $p_showRow["duration"];
$day = $p_showRow["day"]; $day = $p_showRow["day"];
$record = $p_showRow["record"]; $record = $p_showRow["record"];
$timezone = $p_showRow["timezone"]; $timezone = $p_showRow["timezone"];
if(isset($next_pop_date)) { if(isset($next_pop_date)) {
@ -1030,22 +1043,23 @@ class Application_Model_Show {
} }
$utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone); $utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone);
$utcStart = $utcStartDateTime->format("Y-m-d H:i:s");
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}"; $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
$rebroadcasts = $CC_DBC->GetAll($sql); $rebroadcasts = $CC_DBC->GetAll($sql);
$show = new Application_Model_Show($show_id); $show = new Application_Model_Show($show_id);
$date = new Application_Model_DateHelper(); $date = new Application_Model_DateHelper();
$currentUtcTimestamp = $date->getUtcTimestamp(); $currentUtcTimestamp = $date->getUtcTimestamp();
while(strtotime($utcStart) <= strtotime($end_timestamp) && (strtotime($utcStart) < strtotime($last_show) || is_null($last_show))) { while($utcStartDateTime->getTimestamp() <= $p_dateTime->getTimestamp() &&
($utcStartDateTime->getTimestamp() < strtotime($last_show) || is_null($last_show))) {
$utcStart = $utcStartDateTime->format("Y-m-d H:i:s");
$sql = "SELECT timestamp '{$utcStart}' + interval '{$duration}'"; $sql = "SELECT timestamp '{$utcStart}' + interval '{$duration}'";
$utcEnd = $CC_DBC->GetOne($sql); $utcEndDateTime = new DateTime($CC_DBC->GetOne($sql), new DateTimeZone("UTC"));
if ($show->hasInstanceOnDate($utcStart)){ if ($show->hasInstanceOnDate($utcStartDateTime)){
$ccShowInstance = $show->getInstanceOnDate($utcStart); $ccShowInstance = $show->getInstanceOnDate($utcStartDateTime);
$newInstance = false; $newInstance = false;
} else { } else {
$ccShowInstance = new CcShowInstances(); $ccShowInstance = new CcShowInstances();
@ -1055,10 +1069,10 @@ class Application_Model_Show {
/* When editing the start/end time of a repeating show, we don't want to /* When editing the start/end time of a repeating show, we don't want to
* change shows that started in the past. So check the start time. * change shows that started in the past. So check the start time.
*/ */
if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp){ if ($newInstance || $ccShowInstance->getDbStarts() > $currentUtcTimestamp){
$ccShowInstance->setDbShowId($show_id); $ccShowInstance->setDbShowId($show_id);
$ccShowInstance->setDbStarts($utcStart); $ccShowInstance->setDbStarts($utcStartDateTime);
$ccShowInstance->setDbEnds($utcEnd); $ccShowInstance->setDbEnds($utcEndDateTime);
$ccShowInstance->setDbRecord($record); $ccShowInstance->setDbRecord($record);
$ccShowInstance->save(); $ccShowInstance->save();
} }
@ -1066,40 +1080,49 @@ class Application_Model_Show {
$show_instance_id = $ccShowInstance->getDbId(); $show_instance_id = $ccShowInstance->getDbId();
$showInstance = new Application_Model_ShowInstance($show_instance_id); $showInstance = new Application_Model_ShowInstance($show_instance_id);
/* If we are updating a show then make sure that the scheduled content within
* the show is updated to the correct time. */
if (!$newInstance){ if (!$newInstance){
$showInstance->correctScheduleStartTimes(); $showInstance->correctScheduleStartTimes();
} }
foreach($rebroadcasts as $rebroadcast) { self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $utcStartDateTime, $duration);
$timeinfo = explode(" ", $utcStart); $dt = new DateTime($start, new DateTimeZone($timezone));
$dt->add(new DateInterval($p_interval));
$sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'"; $start = $dt->format("Y-m-d H:i:s");
$rebroadcast_start_time = $CC_DBC->GetOne($sql);
$dt->setTimezone(new DateTimeZone('UTC'));
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'"; $utcStartDateTime = $dt;
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
if ($rebroadcast_start_time > $currentUtcTimestamp){
$newRebroadcastInstance = new CcShowInstances();
$newRebroadcastInstance->setDbShowId($show_id);
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
$newRebroadcastInstance->setDbEnds($rebroadcast_end_time);
$newRebroadcastInstance->setDbRecord(0);
$newRebroadcastInstance->setDbRebroadcast(1);
$newRebroadcastInstance->setDbOriginalShow($show_instance_id);
$newRebroadcastInstance->save();
}
}
$sql = "SELECT timestamp '{$start}' + interval '{$interval}'";
$start = $CC_DBC->GetOne($sql);
$utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone);
$utcStart = $utcStartDateTime->format("Y-m-d H:i:s");
} }
Application_Model_Show::setNextPop($start, $show_id, $day); Application_Model_Show::setNextPop($start, $show_id, $day);
} }
private static function createRebroadcastInstances($p_rebroadcasts, $p_currentUtcTimestamp, $p_showId, $p_showInstanceId, $p_utcStartDateTime, $p_duration){
global $CC_DBC;
foreach($p_rebroadcasts as $rebroadcast) {
$timeinfo = $p_utcStartDateTime->format("Y-m-d H:i:s");
$sql = "SELECT timestamp '{$timeinfo}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
$rebroadcast_start_time = $CC_DBC->GetOne($sql);
$sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$p_duration}'";
$rebroadcast_end_time = $CC_DBC->GetOne($sql);
if ($rebroadcast_start_time > $p_currentUtcTimestamp){
$newRebroadcastInstance = new CcShowInstances();
$newRebroadcastInstance->setDbShowId($p_showId);
$newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
$newRebroadcastInstance->setDbEnds($rebroadcast_end_time);
$newRebroadcastInstance->setDbRecord(0);
$newRebroadcastInstance->setDbRebroadcast(1);
$newRebroadcastInstance->setDbOriginalShow($p_showInstanceId);
$newRebroadcastInstance->save();
}
}
}
/** /**
* Get all the show instances in the given time range. * Get all the show instances in the given time range.
@ -1218,7 +1241,7 @@ class Application_Model_Show {
$days = $interval->format('%a'); $days = $interval->format('%a');
$shows = Application_Model_Show::getShows($start, $end); $shows = Application_Model_Show::getShows($start, $end);
$today_timestamp = date("Y-m-d H:i:s"); $today_timestamp = date("Y-m-d H:i:s");
foreach ($shows as $show) { foreach ($shows as $show) {
$options = array(); $options = array();
@ -1248,10 +1271,10 @@ class Application_Model_Show {
if($show["rebroadcast"]) { if($show["rebroadcast"]) {
$event["disableResizing"] = true; $event["disableResizing"] = true;
} }
$startDateTime = new DateTime($show["starts"], new DateTimeZone("UTC")); $startDateTime = new DateTime($show["starts"], new DateTimeZone("UTC"));
$startDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); $startDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$endDateTime = new DateTime($show["ends"], new DateTimeZone("UTC")); $endDateTime = new DateTime($show["ends"], new DateTimeZone("UTC"));
$endDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); $endDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
@ -1362,17 +1385,17 @@ class Application_Model_Show {
} }
public static function GetMaxLengths() { public static function GetMaxLengths() {
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
$sql = "SELECT column_name, character_maximum_length FROM information_schema.columns" $sql = "SELECT column_name, character_maximum_length FROM information_schema.columns"
." WHERE table_name = 'cc_show' AND character_maximum_length > 0"; ." WHERE table_name = 'cc_show' AND character_maximum_length > 0";
$result = $CC_DBC->GetAll($sql); $result = $CC_DBC->GetAll($sql);
// store result into assoc array // store result into assoc array
$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'];
} }
return $assocArray; return $assocArray;
} }
} }