<?php
defined('BASEPATH') or exit('No direct script access allowed');

class ModelDataStunting extends CI_Model
{

    public function __construct()
    {
        parent::__construct();
        //Codeigniter : Write Less Do More
    }

    public function get_data()
    {
        $this->db->join("desa", "desa.id_desa = stunting.id_desa");
        return $this->db->get("stunting")->result();
    }

    public function get_data_edit($id)
    {
        return $this->db->get_where("stunting", array("id_stunting" => $id))->row_array();
    }

    function getbyDesaTahun($iddesa, $tahun)
    {
        $this->db->where('id_desa', $iddesa);
        $this->db->where('tahun', $tahun);
        $this->db->order_by("id_desa", "DESC");
        return $this->db->get('stunting')->row_array();
    }

    // public function get_data_by_year($year)
    // {
    //     $this->db->join("data_desa", "data_desa.id_datadesa = data_stunting.id_datadesa");
    //     $this->db->where("tahun", $year);
    //     return $this->db->get("data_stunting")->result();
    // }

}
