<?php
class User_model extends CI_model
{
    public function get_user($id_user)
    {
        $this->db->select('*');
        $this->db->from('m_user');
        $this->db->where('id_user',$id_user);
        return $this->db->get()->row_array();
    }

    public function get_user_all()
    {
        $this->db->select('*');
        $this->db->from('m_user');
        return $this->db->get()->result_array();
    }

    public function add($email,$username, $password) {
        $data = [
            'email' => htmlspecialchars($email),
            'username' => htmlspecialchars($username),
            'password' => password_hash($password, PASSWORD_DEFAULT)
          
        ];
       
        return $this->db->insert('m_user', $data);
    }

    public function edit($id, $password) {
        $this->db->set('password',password_hash($password, PASSWORD_DEFAULT));
        $this->db->where('id_user',$id);
        return $this->db->update('m_user');
    }

    public function hapus($id)
    {
        $this->db->where('id_user', $id);
        return  $this->db->delete('m_user');
    }   
}