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

class User_m extends CI_Model
{

    public function login($post)
    {
        $this->db->select('*');
        $this->db->from('tb_user'); // nama database
        $this->db->where('username', $post['username']); // fild dari database
        $this->db->where('password', sha1($post['password']));     // fild dari database
        $this->db->like('is_active', 1); // fild dari database
        $query = $this->db->get();
        return $query;
    }

    //public function getuser($id = null)
    //{
    //   $pass = $pass = $this->fungsi->user_login()->user_id;
    //   $this->db->from('idpass');
    //   $this->db->order_by('user_id', 'desc');
    //  $this->db->like('level', $pass);
    //  if ($id != null) {
    //      $this->db->where('user_id',  $id,);
    //   }
    //   $query = $this->db->get();
    //   return $query;
    //}

    public function get($id = null)
    {
        $this->db->from('tb_user');
        if ($id != null) {
            $this->db->where('id_user', $id);
        }
        $query = $this->db->get();
        return $query;
    }
}
