<commit_before><?php

class Reservation extends CI_Model {

  function __construct()
  {
    parent::__construct();
    $this->load->database();
  }

  function get_reservations()
  {
    $query = $this->db->get('reservations');
    return $query->result();
  }

  function get_reservations_by_room_id($room_id){
    $query = $this->db->get_where('reservations', array('room_id' => $room_id));
    return $query->result();
  }

  function get_reservation($id)
  {
    $query = $this->db->get_where('reservation', array('id' => $id) );
    return $query->row();
  }

  function save_reservation($id = null)
  {

    $data = array();

    if( isset($id) ){
      $data['id'] = $id;
    }
    
    if ($id == null) {
      return $this->db->insert('reservations', $data);
    }
    else {
      $this->db->where('id', $id);
      return $this->db->update('reservations', $data);
    }

  }

  function delete_reservation($id)
  {
    return $this->db->delete('reservations', array('id' => $id) );
  }

}

?><commit_msg>tweaks save reservation function<commit_after><?php

class Reservation extends CI_Model {

  function __construct()
  {
    parent::__construct();
    $this->load->database();
  }

  function get_reservations()
  {
    $query = $this->db->get('reservations');
    return $query->result();
  }

  function get_reservations_by_room_id($room_id){
    $query = $this->db->get_where('reservations', array('room_id' => $room_id));
    return $query->result();
  }

  function get_reservation($id)
  {
    $query = $this->db->get_where('reservation', array('id' => $id) );
    return $query->row();
  }

  function save_reservation($data = array())
  {

    $id = null;

    if( isset($data['id']) ){
      $id = $data['id'];
      unset( $data['id'] );
    }
    
    if ($id == null) {
      return $this->db->insert('reservations', $data);
    }
    else {
      $this->db->where('id', $id);
      return $this->db->update('reservations', $data);
    }

  }

  function delete_reservation($id)
  {
    return $this->db->delete('reservations', array('id' => $id) );
  }

}

?>
{'fraction_non_alphanumeric': 0.20124580737901293, 'fraction_numerical': 0.0, 'mean_word_length': 3.1183431952662723, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6181687', 'n_tokens_mistral': 754, 'n_tokens_neox': 737, 'n_words': 121}