<?php

namespace Modules\DemandeAchat\Repository;

class Clause
{
    
    private $pdo;
    
    public function __construct(\PDO $pdo)
    {
        $this->pdo = $pdo;
    }
    
    /**
     * listeClause
     * @param string $numDA
     * @return array<mixed>
     */
    public function listeClause(String $numDA) : ?array
    {
        $req =
        "SELECT NO_DA, NO_ORDRE, CONTMEMO 
        FROM DA_CLAUS with (nolock)
        LEFT JOIN MEMOS with (nolock) on MEMOS.NODEMEMO = DA_CLAUS.NM_PARAG
        WHERE NO_DA = :numDA ORDER BY NO_ORDRE";
        
        $arrayReq = [':numDA' => $numDA];
        
        $requete = $this->pdo->prepare($req);
        $requete->execute($arrayReq);
        
        return $requete->fetchAll($this->pdo::FETCH_ASSOC);
    }
}
