Données recursive d'une table
Bonjour,
Je développe un projet sous Symphony (surement la raison de ma presence ici) et j'aurais une question !
J'expose mon application, ca fonctionne comme un dossier et des fichiers sous linux en gros.
J'ai un projet (ma racine) qui contient des dossiers qui contient lui meme des dossiers et /ou des fichiers.
Je souhaiterais afficher l'ensemble sur le coté en forme d'arborescence. et la se pose mon soucis : Comment faire appel à un dossier d'un dossier ?
Dans un premier temps j'ai fait cela :
<-- lib/model/TDossierPeer.php -->
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#Recupere une liste de dossier d'un dossier
static public function getWithDossiers(Criteria $criteria = null)
{
if (is_null($criteria))
{
$criteria = new Criteria();
}
$criteria = new Criteria();
$criteria->addJoin(self::C_FK_DSS_DSS_ID, TDossierPeer::C_PK_DSS_ID);
$criteria->setDistinct();
return self::doSelect($criteria);
} |
<-- lib/model/TDossier.php -->
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| class TDossier extends BaseTDossier
#Recupere la liste des dossiers d'un dossier particulier
{
public function getWithDossiersN2()
{
$criteria = new Criteria();
$criteria->add(TDossierPeer::C_FK_DSS_DSS_ID, $this->getCPkDssId());
return TDossierPeer::getWithDossiers($criteria);
}
} |
Et je l'appel dans un component :
<-- apps/frontend/modules/projet/templates/_monMenu.php -->
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
<?php foreach ($t_dossiers1 as $i => $t_dossierN1): ?>
<?php echo "<li class=\"toggleSubMenu\"><span>".$t_dossierN1->getDssRef()."</span>"; ?>
<?php #if ($t_dossiers2) :?>
<?php echo "<ul class='navigation'>"; ?>
<?php foreach ($t_dossierN1->getWithDossiersN2() as $j => $t_dossierN2): ?>
<?php echo "<li> Hello <\li>" ?>
<?php echo "<li class=\"toggleSubMenu\"><span>".$t_dossierN2->getDssRef()."</span>"; ?>
<?php endforeach; ?>
<?php echo "</ul>"; ?>
<?php #endif; ?>
<?php endforeach; ?> |
Et juste pour info (histoire de bien comprendre) mon component :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
<-- Projet -->
<?php
class projetComponents extends sfComponents
{
public function executeMonMenu(sfWebRequest $request)
{
#$this->t_projet_list = TProjetPeer::doSelect(new Criteria());
if ($request->getParameter('c_pk_prj_id'))
{
$this->t_projet = TProjetPeer::retrieveByPk($request->getParameter('c_pk_prj_id'));
$this->t_dossiers1 = TDossierPeer::getWithProjets();
#$this->forward404Unless($this->t_projet);
}
else
{
$this->t_dossiers1 = Null;
}
}
}
?> |
Aucune erreur ne se produit mais rien n'est recupérer, et SQL Query donne ca :
Code:
1 2 3 4 5
|
SELECT DISTINCT t_dossier.ID, t_dossier.DSS_REF, t_dossier.DSS_DESIG, t_dossier.DSS_DATE_MODIFICATION,
t_dossier.DSS_DATE_CREATION, t_dossier.DSS_DESC_EVOLUTION,
FROM `t_dossier`
WHERE t_dossier.C_FK_DSS_DSS_ID=t_dossier.ID |
Et dans mon cas il me faudrait :
Code:
1 2 3 4
|
SELECT DISTINCT T_D2.ID, T_D2.DSS_REF, T_D2.DSS_DESIG
FROM `t_dossier` as T_D1, `t_dossier` as T_D2
WHERE T_D2.C_FK_DSS_DSS_ID=T_D1.ID |
Il suffirait certainement d'un Alias ??
J'espere avoir ete explicite :)
Merci pour votre futur aide !