<?php
class Login_model {
    private $db;
    public function __construct() {
        $this->db = new Database;
    }

    public function findByEmail($email) {
        $e = $this->db->escape($email);
        $res = $this->db->query("SELECT * FROM tbl_login WHERE email='$e' LIMIT 1");
        return $res ? $res->fetch_assoc() : false;
    }

    public function createUser($username, $email, $password) {
        $u = $this->db->escape($username);
        $e = $this->db->escape($email);
        $p = $this->db->escape($password);
        $this->db->query("INSERT INTO tbl_login (username,email,password) VALUES ('$u','$e','$p')");
        return $this->db->insert_id();
    }
}
?>
