<?php

class User extends Model {

   // ===========
   // = Statics =
   // ===========
   protected static $table_name = 'USER';

   // 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();
   }

   public static function updateUser($array) {
      $stm = parent::exec('USER_UPDATE', $array);
   }

   public static function tryLogin($login){
      $stm = parent::exec('USER_GET_WITH_LOGIN', ['login' => $login]);
      return $stm->fetchAll(PDO::FETCH_CLASS, 'User')[0];
   }

   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);
   }
   

}