<?php

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

require_once 'Da_user.php';

class M_user extends Da_user
{

	public function __construct()
	{
		parent::__construct();
	}

	public function check_login($email, $pass)
	{
		$sql = "SELECT * FROM {$this->db_name}.user
        WHERE email = ? AND password = ? and is_delete = 0"; 

        $query = $this->db->query($sql,[$email,$pass]);
        return $query;
	}

	public function get_all()
	{
		$sql = "SELECT * FROM {$this->db_name}.user
		Where is_delete = 0 order by user_id DESC";
        $query = $this->db->query($sql);
        return $query;
	}

	public function get_user_by_id($id)
	{
		$sql = "SELECT * FROM {$this->db_name}.user
		Where user_id = $id";
        $query = $this->db->query($sql);
        return $query;
	}

	public function get_user_by_email($email){
		$sql = "SELECT * FROM {$this->db_name}.user
		Where email = ? and is_delete = 0";
        $query = $this->db->query($sql,[$email]);
        return $query;
	}

	public function get_user_project($email){
		$sql = "SELECT user_id, student_id, prefix, first_name, last_name, email FROM {$this->db_name}.user
		Where email like '".substr($email,0,2)."%'";
        $query = $this->db->query($sql);
        return $query;
	}

	public function get_user_project_admin(){
		$sql = "SELECT user_id, student_id, prefix, first_name, last_name, email FROM {$this->db_name}.user";
        $query = $this->db->query($sql);
        return $query;
	}



}
