本文整理匯總了PHP中SimpleORMap::findByMetadate_id方法的典型用法代碼示例。如果您正苦於以下問題:PHP SimpleORMap::findByMetadate_id方法的具體用法?PHP SimpleORMap::findByMetadate_id怎麽用?PHP SimpleORMap::findByMetadate_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SimpleORMap
的用法示例。
在下文中一共展示了SimpleORMap::findByMetadate_id方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: store
/**
* Stores this cycle.
* @return int number of changed rows
*/
public function store()
{
$cycle = parent::findByMetadate_id($this->metadate_id);
//create new entry in seminare_cycle_date
if (!$cycle) {
$result = parent::store();
if ($result) {
$new_dates = $this->createTerminSlots();
foreach ($new_dates as $semester_dates) {
foreach ($semester_dates['dates'] as $date) {
$result += $date->store();
}
}
StudipLog::log('SEM_ADD_CYCLE', $this->seminar_id, NULL, $this->toString());
return $result;
}
return 0;
}
//change existing cycledate, changes also corresponding single dates
$old_cycle = SeminarCycleDate::find($this->metadate_id);
if (!parent::store()) {
return false;
}
if (mktime($this->start_time) >= mktime($old_cycle->start_time) && mktime($this->end_time) <= mktime($old_cycle->end_time) && $this->weekday == $old_cycle->weekday && $this->end_offset == $old_cycle->end_offset) {
$update_count = 0;
foreach ($this->getAllDates() as $date) {
$tos = $date->date;
$toe = $date->end_time;
//Update future dates
if ($toe > time()) {
$date->date = mktime(date('G', strtotime($this->start_time)), date('i', strtotime($this->start_time)), 0, date('m', $tos), date('d', $tos), date('Y', $tos));
$date->end_time = mktime(date('G', strtotime($this->end_time)), date('i', strtotime($this->end_time)), 0, date('m', $toe), date('d', $toe), date('Y', $toe));
}
if ($date->isDirty()) {
$date->store();
$update_count++;
}
}
StudipLog::log('SEM_CHANGE_CYCLE', $this->seminar_id, NULL, $old_cycle->toString() . ' -> ' . $this->toString());
return $update_count;
}
//collect topics for existing future dates (CourseDate)
$topics = array();
foreach ($this->getAllDates() as $date) {
if ($date->end_time >= time()) {
$topics_tmp = CourseTopic::findByTermin_id($date->termin_id);
if (!empty($topics_tmp)) {
$topics[] = $topics_tmp;
}
//uncomment below
$date->delete();
}
}
$new_dates = $this->createTerminSlots(time());
$topic_count = 0;
$update_count = 0;
foreach ($new_dates as $semester_dates) {
foreach ($semester_dates['dates'] as $date) {
if ($date instanceof CourseDate) {
if (isset($topics[$topic_count])) {
$date->topics = $topics[$topic_count];
$topic_count++;
}
}
$date->store();
$update_count++;
}
}
StudipLog::log('SEM_CHANGE_CYCLE', $this->seminar_id, NULL, $old_cycle->toString() . ' -> ' . $this->toString());
return $update_count;
}