<?php

namespace Entity\Model;

use Helpers\QueryBuilder\QueryBuilder;

class OxaUserPanierImputation extends QueryBuilder
{
    protected string $table = 'oxa_users_panier_imputation with (nolock)';
    public string $titre;
    protected string $primaryKey = '';

    /**
     * @return array<mixed>
     */
    public function getArchitecture(\Helpers\Trad\ITrad $trad)
    {
        return  [];
    }

    public function getMaxId(string $idPanier, string $idUser) : int
    {
        $req = "select max(id_imputation) maxId from ".$this->table." where id_panier = :idPanier and id_user = :idUser";

        $arrayReq = [
            ':idPanier' => $idPanier,
            ':idUser'   => $idUser,
        ];

        $data = $this->pdo->prepare($req);
        $data->execute($arrayReq);
        
        $return = $data->fetch($this->pdo::FETCH_ASSOC);

        if ($return) {
            return (int)$return['maxId'];
        } else {
            return 0;
        }
    }
}
