<commit_before><?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class detail_desa_model extends CI_Model
{
  public $table = 'detail_desa';
  public $id    = 'id_detail_desa';
  public $order = 'DESC';

  function get_all()
  {
    $this->db->order_by($this->id, $this->order);
    return $this->db->get($this->table)->result();
  }

  function get_combo_detail_desa()
  {
    $this->db->order_by('nama_desa', 'ASC');
    $query = $this->db->get($this->table);

    if($query->num_rows() > 0){
      $data = array();
      foreach ($query->result_array() as $row) 
      {
        $data[$row['id_detail_desa']] = $row['nama_desa'];
      }
      return $data;
    }
  }

  // get data by id
  function get_by_id($id)
  {
    $this->db->where($this->id, $id);
    $this->db->or_where('nama_desa_seo', $id);
    return $this->db->get($this->table)->row();    
  }
  
  // get total rows
  function total_rows() {
    return $this->db->get($this->table)->num_rows();
  }

  // insert data
  function insert($data)
  {
    $this->db->insert($this->table, $data);
  }

  // update data
  function update($id, $data)
  {
    $this->db->where($this->id,$id);
    $this->db->update($this->table, $data);
  }

  // delete data
  function delete($id)
  {
    $this->db->where($this->id, $id);
    $this->db->delete($this->table);
  }

  // get all
  function get_cari_detail_desa()
  {
    $cari_berita = $this->input->post('cari_detail_desa');

    $this->db->like('nama_desa', $cari_detail_desa);
    return $this->db->get($this->table)->result();
  }

 /**
   * Activate
   *
   * @return void
   * @author Mathew
   **/
  public function activate($id, $code = false){
    $this->trigger_events('pre_activate');

    if ($code !== FALSE)
    {
      $query = $this->db->select($this->identity_column)
                        ->where('id_pejabat', $id)
                        ->limit(1)
                  ->order_by('id_pejabat', 'desc')
                        ->get($this->tables['data_pejabat']);

      $result = $query->row();

      if ($query->num_rows() !== 1)
      {
        $this->trigger_events(array('post_activate', 'post_activate_unsuccessful'));
        $this->set_error('activate_unsuccessful');
        return FALSE;
      }

      $data = array(
          'active'          => 1
      );

      $this->trigger_events('extra_where');
      $this->db->update($this->tables['data_pejabat'], $data, array('id_pejabat' => $id));
    }
    else
    {
      $data = array(
          'active'          => 1
      );


      $this->trigger_events('extra_where');
      $this->db->update($this->tables['data_pejabat'], $data, array('id_pejabat' => $id));
    }


    $return = $this->db->affected_rows() == 1;
    if ($return)
    {
      $this->trigger_events(array('post_activate', 'post_activate_successful'));
      $this->set_message('activate_successful');
    }
    else
    {
      $this->trigger_events(array('post_activate', 'post_activate_unsuccessful'));
      $this->set_error('activate_unsuccessful');
    }


    return $return;
  }

  /**
   * Deactivate
   *
   * @return void
   * @author Mathew
   **/
  public function deactivate($id = NULL){
    $this->trigger_events('deactivate');

    if (!isset($id))
    {
      $this->set_error('deactivate_unsuccessful');
      return FALSE;
    }

    $data = array(
        'active'          => 0
    );

    $this->trigger_events('extra_where');
    $this->db->update($this->tables['data_pejabat'], $data, array('id_pejabat' => $id));

    $return = $this->db->affected_rows() == 1;
    if ($return)
      $this->set_message('deactivate_successful');
    else
      $this->set_error('deactivate_unsuccessful');

    return $return;
  }

}

/* End of file data_pejabat_model.php */
/* Location: ./application/models/data_pejabat_model.php */
/* Please DO NOT modify this information : */
/* Generated by Harviacode Codeigniter CRUD Generator 2016-10-17 02:19:21 */
/* http://harviacode.com */<commit_msg>ganti comment detail_desa_model<commit_after><?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class detail_desa_model extends CI_Model
{
  public $table = 'detail_desa';
  public $id    = 'id_detail_desa';
  public $order = 'DESC';

  function get_all()
  {
    $this->db->order_by($this->id, $this->order);
    return $this->db->get($this->table)->result();
  }

  function get_combo_detail_desa()
  {
    $this->db->order_by('nama_desa', 'ASC');
    $query = $this->db->get($this->table);

    if($query->num_rows() > 0){
      $data = array();
      foreach ($query->result_array() as $row)
      {
        $data[$row['id_detail_desa']] = $row['nama_desa'];
      }
      return $data;
    }
  }

  // get data by id
  function get_by_id($id)
  {
    $this->db->where($this->id, $id);
    $this->db->or_where('nama_desa_seo', $id);
    return $this->db->get($this->table)->row();
  }

  // get total rows
  function total_rows() {
    return $this->db->get($this->table)->num_rows();
  }

  // insert data
  function insert($data)
  {
    $this->db->insert($this->table, $data);
  }

  // update data
  function update($id, $data)
  {
    $this->db->where($this->id,$id);
    $this->db->update($this->table, $data);
  }

  // delete data
  function delete($id)
  {
    $this->db->where($this->id, $id);
    $this->db->delete($this->table);
  }

  // get all
  function get_cari_detail_desa()
  {
    $cari_berita = $this->input->post('cari_detail_desa');

    $this->db->like('nama_desa', $cari_detail_desa);
    return $this->db->get($this->table)->result();
  }

 /**
   * Activate
   *
   * @return void
   * @author Mathew
   **/
  public function activate($id, $code = false){
    $this->trigger_events('pre_activate');

    if ($code !== FALSE)
    {
      $query = $this->db->select($this->identity_column)
                        ->where('id_pejabat', $id)
                        ->limit(1)
                  ->order_by('id_pejabat', 'desc')
                        ->get($this->tables['data_pejabat']);

      $result = $query->row();

      if ($query->num_rows() !== 1)
      {
        $this->trigger_events(array('post_activate', 'post_activate_unsuccessful'));
        $this->set_error('activate_unsuccessful');
        return FALSE;
      }

      $data = array(
          'active'          => 1
      );

      $this->trigger_events('extra_where');
      $this->db->update($this->tables['data_pejabat'], $data, array('id_pejabat' => $id));
    }
    else
    {
      $data = array(
          'active'          => 1
      );


      $this->trigger_events('extra_where');
      $this->db->update($this->tables['data_pejabat'], $data, array('id_pejabat' => $id));
    }


    $return = $this->db->affected_rows() == 1;
    if ($return)
    {
      $this->trigger_events(array('post_activate', 'post_activate_successful'));
      $this->set_message('activate_successful');
    }
    else
    {
      $this->trigger_events(array('post_activate', 'post_activate_unsuccessful'));
      $this->set_error('activate_unsuccessful');
    }


    return $return;
  }

  /**
   * Deactivate
   *
   * @return void
   * @author Mathew
   **/
  public function deactivate($id = NULL){
    $this->trigger_events('deactivate');

    if (!isset($id))
    {
      $this->set_error('deactivate_unsuccessful');
      return FALSE;
    }

    $data = array(
        'active'          => 0
    );

    $this->trigger_events('extra_where');
    $this->db->update($this->tables['data_pejabat'], $data, array('id_pejabat' => $id));

    $return = $this->db->affected_rows() == 1;
    if ($return)
      $this->set_message('deactivate_successful');
    else
      $this->set_error('deactivate_unsuccessful');

    return $return;
  }

}

/* End of file detail_desa_model.php */
/* Location: ./application/models/detail_desa_model.php */
/* Please DO NOT modify this information : */
/* Generated by Harviacode Codeigniter CRUD Generator 2016-10-17 02:19:21 */
/* http://harviacode.com */
{'fraction_non_alphanumeric': 0.19117830813444958, 'fraction_numerical': 0.00549793827314757, 'mean_word_length': 2.6614821591948763, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 193, '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': '2352690', 'n_tokens_mistral': 2850, 'n_tokens_neox': 2739, 'n_words': 432}