Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

Rev 32 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

<?php

class macroElement implements iMacroElement{
    
    protected $identifiantblockdedonnees;
    protected $connexion;
    protected $contexteRef;
    protected $blockdedonneesParent;
    protected $collectionblockdedonnees;
    protected $idRes;
    
    function __construct($une_connexion, $un_block_données_parent, $identifiant)
    {
        $this->connexion = $une_connexion;
        $this->blockdedonneesParent = $un_block_donn;
        $this->identifiantblockdedonnees = $identifiant;
        $this->contexteRef = $this->blockdedonneesParent->recupererDonnees();
    }
    
    function construire() 
    {
        $sql = $this->getSQL();
        if(!is_null($sql)) {
            $this->openCursor($sql);
            while ($this->fetch());
            $this->closeCursor();
        }
    }
    
    function contruireParRecursivitePlate()
    {
        construire();
        
        $this->$contexteRef = $this->blockdedonnees;
        
        construire();
    }
    
    function contruireParRecursivite()
    {
        
    }
    
    function openCursor($sql)
    {
        $res = mysql_query($sql, $this->connexion);
        if (!$res) echo mysql_errno().': '.mysql_error()."\n";
        $this->idRes = $res;
        $this->collectionblockdedonnees = new collectionblockdedonnees($this->identifiantblockdedonnees);
        $this->blockdedonneesParent->ajouterCollectionBlockFils($this->collectionblockdedonnees);
    }
    
    function fetch()
    {
        $res = mysql_fetch_assoc($this->idRes);
        if (!$res) {
            
        } else {
            //$this->blockdedonnees = new blockdedonnees($this->identifiantblockdedonnees);
            //$this->blockdedonnees->affecterDonnees($res);
            $this->collectionblockdedonnees->ajouterDonnees($res);
        }
        return $res;
    }
    
    function closeCursor()
    {
        mysql_free_result($this->idRes);
    }
}
?>