<?php
/**
 *  Class qui gère les user 
 **/
class Class_user
{
    private $pdo = null;

    public function __construct(PdoGsb $pDO)
    {
        $this->pdo = $pDO->getPdoGsb();
    }

    /**
     * FONCTION QUI CONNECTE UN UTILISATEUR
     */
    public function connectUser(string $login, string $password): array|bool
    {
        $req = 'SELECT "uId", "uNom", "uPrenom", "uAdresse", "uCp", "uVille", "uSecteur", "uLabo", "parametre"."pLibelle"
        FROM utilisateur
        INNER JOIN parametre ON "parametre"."pType" = \'statUti\' 
        AND "utilisateur"."uStatut" = "parametre"."pIndice"
        WHERE "uLogin" = :login AND "uMdp" = :pwd ;';

        $result = $this->pdo->prepare($req);
        $result->bindParam('login', $login);
        $result->bindParam('pwd', $password);
        $result->execute();

        return $result->fetch();
    }
}
