User.class.php 1.04 KB
Newer Older
quentin.vrel's avatar
quentin.vrel committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?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();
   }

quentin.vrel's avatar
quentin.vrel committed
20 21
   public static function updateUser($array) {
      $stm = parent::exec('USER_UPDATE', $array);
quentin.vrel's avatar
quentin.vrel committed
22 23
   }

quentin.vrel's avatar
quentin.vrel committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
   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);
   }
   
quentin.vrel's avatar
quentin.vrel committed
45 46

}