<?php

namespace Entity\Model;

use Helpers\QueryBuilder\QueryBuilder;

class LotGest extends QueryBuilder
{
    protected string $table = 'LOTGEST with (nolock)';
    protected string $primaryKey = '';

    /**
     * @return array<mixed>
     */
    public function getNumLot()
    {
        $date = date('Ymd');

        $req = "select top 1 * from LOTGEST with (nolock) where DAT_EFF <= :date order by DAT_EFF DESC";
        $arrayReq = [
            ':date' => $date,
        ];

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

        $return = $stmt->fetch(\PDO::FETCH_ASSOC);

        if ($return) {
            return $return;
        } else {
            return [];
        }
    }
}
