Skip to content
Snippets Groups Projects
User.class.php 598 B
Newer Older
root's avatar
root committed
<?php 

include_once ($_SERVER['DOCUMENT_ROOT'].'/api/lib/database.class.php');

class User
{
    private $db;
root's avatar
root committed
    private $data;
    private $collection;
root's avatar
root committed
    
    public function __construct($username)
    {
root's avatar
root committed
        $this->db = Database::getConnection();
        $this->collection = $this->db->auth;
        $this->data = $this->collection->findOne([
            '$or' => [
            ['username' => $username],
            ['email' => $username]
            ]
        ]);

        if($this->data == null)
root's avatar
root committed
        {
root's avatar
root committed
            throw new Exception ("User not found");
root's avatar
root committed
        }
root's avatar
root committed
    }


}