User.class.php 1.12 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

Zohten's avatar
Zohten committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
    public function password()
    {
        return trim($this->USER_PWD);
    }
    public function id()
    {
        return trim($this->USER_ID);
    }
    public function firstname()
    {
        return trim($this->USER_NAME);
    }
    public function lastname()
    {
        return trim($this->USER_SURNAME);
    }
    public function email()
    {
        return trim($this->USER_EMAIL);
    }
}