<?php
namespace Modules\Index\Repository;

use Helpers\QueryBuilder\AbsRepository;

class Index extends AbsRepository
{

    
    /**
     * pdo
     *
     * @var \PDO
     */
    protected $pdo;
    
    /**
     * __construct
     *
     * @param  \PDO $pdo
     * @return void
     */
    public function __construct(\PDO $pdo)
    {
        $this->pdo = $pdo;
    }
    
    /**
     * getFavoris
     * @return array<mixed>
     */
    public function getFavoris() : ?array
    {
        $req = "select SIEX_THE, SIEX_NOM, SIEX_URL, SIEX_ICO, CAST(MEMOS.CONTMEMO AS TEXT)
                AS CONTMEMO from SIEXLIST with(nolock) left outer join MEMOS with(nolock)
                on NM_COMM=NODEMEMO where COD_LNG = '" .$_SESSION['Session_Langue']. "' order by SIEX_THE, SIEX_NOM";
        
        return $this->fetchAssocAll($req, []);
    }
    
    /**
     * getActu
     * @return array<string>
     */
    public function getActu() : ?array
    {
        $req = "select URL_PAGE from PAGEINFO with (nolock) where COD_LNG = '" .$_SESSION['Session_Langue']. "'";
        
        $requete = $this->pdo->prepare($req);
        
        $requete->execute();
        return $requete->fetch($this->pdo::FETCH_ASSOC);
    }
}
