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

class Setting_model extends CI_Model
{
	// menampilkan semua
	public function getAllData()
	{
		$this->db->select('*');
		$this->db->from('set_account');
		$this->db->join('akun', 'set_account.id_akun = akun.id_akun', 'left');
		$this->db->order_by("id_sa", "asc");
		$query = $this->db->get()->result_array();
		return $query;
	}

	public function getDataById($id)
	{
		$this->db->select('*');
		$this->db->from('set_account');
		$this->db->join('akun', 'set_account.id_akun = akun.id_akun', 'left');
		$this->db->where('id_sa', $id);
		return $this->db->get()->row_array();
	}

	// mengubah data
	public function update($id)
	{
		$data = [
			'nm' => $this->input->post('nm', true),
			'id_akun' => $this->input->post('id_akun', true),
			'date_created' => time(),
		];

		$this->db->where('id_sa', $id);
		$this->db->update('set_account', $data);
	}

}	