<?php

class Account
{
    private $id;
    public $username;
    public $password;

    protected function Account($data)
    {
        $this->id = $data["id"];
        $this->username = $data["name"];
        $this->password = $data["password"];
    }

    public function getId()
    {
        return $this->id;
    }

    public static function LoadId($accountId)
    {
        $data = rawQuery("select * from users where id=?", array($accountId));
        return count($data) ? new Account($data[0]) : null;
    }

    public static function LoadWithCredentials($username, $password)
    {
        $data = rawQuery("select * from users where name=? and password=?", array($username, sha1($password)));
        return count($data) ? new Account($data[0]) : null;
    }
}

