<?php

namespace Modules\Contrat\Repository;

// TYPE MARCHE
class TypeMarche
{
    
    private $pdo;
    
    public function __construct(\PDO $pdo)
    {
        $this->pdo = $pdo;
    }

    /**
     * listExport
     * @param string $select
     * @param array <string> $post
     * @return array<mixed>
    */
    public function listExport(string $select, array $post) : ?array
    {
        $arrayReq = [];
        $alias="SELECT $select FROM TYPMARCH with (nolock) where 1=1";
        
        $whereArray = \Helpers\Filter\FilterTable::splitFilter($post, 0, 0, 1);
        if (count($whereArray)>  0) {
            $alias .= $whereArray[0].$whereArray['tri'];
            
            if (count($whereArray[1]) != 0) {
                $arrayReq = array_merge($arrayReq, $whereArray[1]);
            }
        }

        $bdd = $this->pdo->prepare($alias);
        $bdd->execute($arrayReq);

        return $bdd->fetchAll($this->pdo::FETCH_ASSOC);
    }
}
