User.class.php 1.41 KB
Newer Older
Zohten's avatar
Zohten committed
1 2
<?php

Zohten's avatar
Zohten committed
3 4
class User extends Model
{
Zohten's avatar
Zohten committed
5 6

   // ===========
Zohten's avatar
Zohten committed
7 8 9
    // = Statics =
    // ===========
    protected static $table_name = 'USER';
Zohten's avatar
Zohten committed
10

Zohten's avatar
Zohten committed
11 12 13 14 15 16 17 18 19 20 21
    // load all users from Db
    public static function getList()
    {
        $stm = parent::exec('USER_LIST');
        return $stm->fetchAll();
    }
    public static function getRow($id)
    {
        $stm = parent::exec('USER_GET_WITH_ID', ['id' => $id]);
        return $stm->fetchAll();
    }
Zohten's avatar
Zohten committed
22

Zohten's avatar
Zohten committed
23 24 25 26
    public static function updateUser($array)
    {
        $stm = parent::exec('USER_UPDATE', $array);
    }
Zohten's avatar
Zohten committed
27

Zohten's avatar
Zohten committed
28 29 30 31 32
    public static function tryLogin($login)
    {
        $stm = parent::exec('USER_GET_WITH_LOGIN', ['login' => $login]);
        return $stm->fetchAll(PDO::FETCH_CLASS, 'User')[0];
    }
Zohten's avatar
Zohten committed
33
    public function id()
Zohten's avatar
Zohten committed
34
    {
Zohten's avatar
Zohten committed
35
        return trim($this->ID_USER);
Zohten's avatar
Zohten committed
36
    }
Zohten's avatar
Zohten committed
37
    public function role()
Zohten's avatar
Zohten committed
38
    {
Zohten's avatar
Zohten committed
39
        return trim($this->ID_ROLE);
Zohten's avatar
Zohten committed
40
    }
Zohten's avatar
Zohten committed
41 42 43 44 45
    public function password()
    {
        return trim($this->PASWORD);
    }
    public function avatar()
Zohten's avatar
Zohten committed
46
    {
Zohten's avatar
Zohten committed
47
        return trim($this->AVATAR);
Zohten's avatar
Zohten committed
48 49 50
    }
    public function lastname()
    {
Zohten's avatar
Zohten committed
51 52 53 54 55
        return trim($this->LASTNAME);
    }
    public function firstname()
    {
        return trim($this->FIRSTNAME);
Zohten's avatar
Zohten committed
56 57 58
    }
    public function email()
    {
Zohten's avatar
Zohten committed
59 60 61 62 63 64 65 66 67
        return trim($this->MAIL);
    }
    public function isBanned()
    {
        return trim($this->BAN_ACCOUNT);
    }
    public function lastIP()
    {
        return trim($this->LAST_IP);
Zohten's avatar
Zohten committed
68 69
    }
}