예제 #1
0
 /**
  * Delete this student or related object.
  * If no parameters are set, this method deletes current student and all participant record related with this student.
  * @param DataMapper|string $object related object to delete from relation.
  * @param string $related_field relation internal name.
  */
 public function delete($object = '', $related_field = '')
 {
     if (empty($object) && !is_array($object) && !empty($this->id)) {
         $participant = new Participant();
         $participant->where_related($this);
         $participant->get();
         $participant->delete_all();
     }
     parent::delete($object, $related_field);
 }
예제 #2
0
function channel_server_start()
{
    $db = sr_pdo();
    $result = array();
    try {
        $room_list = Room::fetchAll();
        foreach ($room_list as $room) {
            channel_destroyed_log($room);
        }
        $participant_list = Participant::fetchAll();
        foreach ($participant_list as $p) {
            channel_client_disconnected_log($p);
        }
        Room::delete_all($db);
        Participant::delete_all($db);
        $result['result'] = 0;
        echo json_encode($result);
    } catch (PDOException $e) {
        $result['result'] = 1;
        $result['msg'] = 'Server error. ' . $e->getMessage();
        echo json_encode($result);
    }
}