<?php 


class M_profile extends CI_Model{	


    


    function __construct() {


        parent::__construct();


    }


    


    function user_nik(){


        return $this->session->userdata('sess_nik');


    }


    function data_log($data){


        $sql = "SELECT * FROM tb_user WHERE kode_user = '$data[kode_user]'";


        return $this->db->query($sql);


    }


    function ambil_image($data){


        $sql = "SELECT foto FROM tb_user WHERE kode_user = '$data[kode_user]'";


        return $this->db->query($sql);


    }


    function update_data_log($data){


        $sql = "UPDATE `tb_user` SET `username`='$data[username]',`email`='$data[email]',`tlp`='$data[tlp]' WHERE kode_user = '$data[kode_user]'";


        return $this->db->query($sql);


    }


    function ganti_pw($data){


        $pw = md5($data['pw']);


        $sql = "UPDATE `tb_user` SET `password`='$pw' WHERE kode_user = '$data[kode_user]'";


        return $this->db->query($sql);


    }


    function upload_image($data){


        $sql = "UPDATE `tb_user` SET `foto`='$data[file_name]' WHERE kode_user = '$data[kode_user]'";


        return $this->db->query($sql);


    }


}