本文整理汇总了PHP中Room::where_related方法的典型用法代码示例。如果您正苦于以下问题:PHP Room::where_related方法的具体用法?PHP Room::where_related怎么用?PHP Room::where_related使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Room
的用法示例。
在下文中一共展示了Room::where_related方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: select_group
public function select_group()
{
$group_id = $this->input->post('group_id');
$this->_transaction_isolation();
$this->db->trans_begin();
$group = new Group();
$group->get_by_id($group_id);
if ($group->exists()) {
$course = $group->course->get();
if (is_null($course->groups_change_deadline) || date('U', strtotime($course->groups_change_deadline)) >= time()) {
$student = new Student();
$student->get_by_id($this->usermanager->get_student_id());
if ($student->is_related_to('active_course', $course->id)) {
$participant = new Participant();
$participant->where_related($student);
$participant->where_related($course);
$participant->where('allowed', 1);
$participant->get();
if ($participant->exists()) {
if (!$participant->is_related_to($group)) {
$participant->save($group);
$participant->where_related($course);
$participant->where_related($group);
$participant->where('allowed', 1);
$participants_count = $participant->count();
$room = new Room();
$room->where_related($group)->order_by('capacity', 'asc')->limit(1)->get();
if ($participants_count > intval($room->capacity)) {
$this->db->trans_rollback();
$this->messages->add_message('lang:groups_message_group_is_full', Messages::MESSAGE_TYPE_ERROR);
} else {
$this->db->trans_commit();
$this->messages->add_message(sprintf($this->lang->line('groups_message_group_changed'), $this->lang->text($group->name)), Messages::MESSAGE_TYPE_SUCCESS);
$this->_action_success();
$this->output->set_internal_value('course_id', $participant->course_id);
}
} else {
$this->db->trans_rollback();
$this->messages->add_message('lang:groups_message_you_are_in_group', Messages::MESSAGE_TYPE_ERROR);
}
} else {
$this->db->trans_rollback();
$this->messages->add_message('lang:groups_message_cant_found_participant_record', Messages::MESSAGE_TYPE_ERROR);
}
} else {
$this->db->trans_rollback();
$this->messages->add_message('lang:groups_message_cant_change_group_of_inactive_course', Messages::MESSAGE_TYPE_ERROR);
}
} else {
$this->db->trans_rollback();
$this->messages->add_message('lang:groups_message_groups_switching_disabled', Messages::MESSAGE_TYPE_ERROR);
}
} else {
$this->db->trans_rollback();
$this->messages->add_message('lang:groups_message_group_not_found', Messages::MESSAGE_TYPE_ERROR);
}
redirect(create_internal_url('groups'));
}
示例2: inject_course_group_rooms
private function inject_course_group_rooms($course_id)
{
$rooms = new Room();
$rooms->where_related('group/course', 'id', (int) $course_id);
$rooms->include_related('group', '*', TRUE, TRUE);
$rooms->order_by_related('group', 'id', 'asc');
$rooms->order_by('time_day', 'asc')->order_by('time_begin', 'asc');
$rooms->order_by_with_constant('name', 'asc');
$rooms->get_iterated();
$days = get_days();
$data = array();
foreach ($rooms as $room) {
if ($room->group->exists()) {
$data[$room->group->id][] = array('value' => $room->id, 'text' => $this->lang->text($room->name) . ' (' . $days[$room->time_day] . ': ' . is_time($room->time_begin) . ' - ' . is_time($room->time_end) . ')');
}
}
$this->parser->assign('all_rooms', $data);
}