<?php

namespace Modules\API\APIExterne\Repository;

use Helpers\QueryBuilder\AbsRepository;

class Index extends AbsRepository
{

    /**
     * updateParamDico
     * @param String $commentaire
     * @param String $typedico
     * @param String $id1
     * @return void
     */
    public function updateParamDico(String $commentaire, String $typedico, String $id1) : void
    {
        $req="UPDATE PARAMDICO SET COMMENTAIRE =:COMMENTAIRE WHERE TYPEDICO = :TYPEDICO AND ID1 = :ID1";
        

        $arrayReq = [':COMMENTAIRE' => $commentaire, ':TYPEDICO' => $typedico, ':ID1' => $id1];
        
        $delais = $this->pdo->prepare($req);
        $delais->execute($arrayReq);
    }
    
    /**
     * insertTokenTmp
     * @param String $idUser
     * @param String $token
     * @return void
     */
    public function insertTokenTmp(String $idUser, String $token) : void
    {
        $tmp = date('Ymd').'|'.date('His');
        
        $req = 'Insert into DNMP_DEMNEWMDP (DNMP_ID, DNMP_USER, DNMP_DATETIME) VALUES(:token, :user, :date)';
        $arrayReq = [
            ':user' => $idUser,
            ':token' => $token,
            ':date' => $tmp
        ];

        $delais = $this->pdo->prepare($req);
        $delais->execute($arrayReq);
    }

    /**
     * execSQL
     * TOTO : BBA attention faille de securité
     * @param String $req
     * @return array<mixed>
     */
    public function execSQL(String $req) : ?array
    {
       // $req ="select TOP 1 * from CONTFOUR with (nolock) where CODE_FOU =:codeFrs and EMAIL != '' ";
         
        $arrayReq = [];

        return $this->fetchAssocAll($req, $arrayReq);
    }
}
