<?php
/**
 * AJOUT COMPTABLE
 *      INSERT INTO utilisateur 
 *      VALUES('cpt1', 'Renaudot', 'Pierre', 'pr07', 'pr', 'rue saint éloi', 21110, 'Marliens', NOW(), 3, 3, 4, 27, NOW(), NOW(), '120cv', 'essence')
 */
class Class_user
{
    private $pdo = null;

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

    public function connectUser(string $login, string $password): array
    {
        $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();
    }
}
