68 lines
1.4 KiB
PHP
68 lines
1.4 KiB
PHP
<?php
|
|
|
|
class Login_m extends MY_Model{
|
|
public function __construct(){
|
|
parent::__construct();
|
|
}
|
|
|
|
public function cek_login($email,$password){
|
|
$user_data = $this->get_row(['email'=>$email]);
|
|
if(isset($user_data)){
|
|
if ($user_data->password == md5($password)) {
|
|
$user_session = [
|
|
'email' => $user_data->email,
|
|
'id_role' => $user_data->role
|
|
];
|
|
$this->session->set_userdata($user_session);
|
|
return 2;
|
|
}else {
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public function get_row($cond)
|
|
{
|
|
$this->db->where($cond);
|
|
$query = $this->db->get('akun');
|
|
return $query->row();
|
|
}
|
|
|
|
public function update($email, $data) {
|
|
$this->db->where('email', $email);
|
|
return $this->db->update('akun', $data);
|
|
}
|
|
|
|
public function get_num_row($cond)
|
|
{
|
|
$this->db->where($cond);
|
|
$query = $this->db->get('akun');
|
|
return $query->num_rows();
|
|
}
|
|
|
|
public function totalbalita()
|
|
{
|
|
$this->db->select('COUNT(id_balita) As balita');
|
|
return $this->db->get('balita')->row();
|
|
}
|
|
|
|
public function totalkriteria()
|
|
{
|
|
$this->db->select('COUNT(id_kriteria) AS kriteria');
|
|
return $this->db->get('kriteria')->row();
|
|
}
|
|
|
|
public function totalalternatif()
|
|
{
|
|
$this->db->select('COUNT(id_alternatif) AS alternatif');
|
|
return $this->db->get('alternatif')->row();
|
|
}
|
|
|
|
public function totalperhitungan()
|
|
{
|
|
$this->db->select('COUNT(id_perhitungan) AS perhitungan');
|
|
return $this->db->get('perhitungan_saw')->row();
|
|
}
|
|
|
|
} |