Précédent   Forum des professionnels en informatique > PHP > Outils > Zend > Zend Framework
Zend Framework Forum d'entraide sur la programmation PHP avec Zend Framework. Avant de poster -> FAQ ZF, Cours ZF
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 05/05/2011, 13h11   #1
Membre du Club
 
Inscription : août 2008
Messages : 165
Détails du profil
Informations forums :
Inscription : août 2008
Messages : 165
Points : 50
Points : 50
Par défaut résultat d'une select zend_db

bonjour à toutes et à tous,
mon prob est que je n'arrive pas à réaliser une requête qui retourne un tableau imbriqué selon des jointures :

données :

1er table :
Code :
array(2) { [0]=> array(4) { ["IdOrg"]=> string(1) "1" ... } }
2eme table :
Code :
 array(3) { [0]=> array(4) { ["IdSO"]=> string(1) "1" ["Idorg"]=> string(1) "1" ... } }
3eme table :
Code :
array(4) { [0]=> array(12) { ["IdDocs"]=> string(1) "1" ["IdOrg"]=> string(1) "1" ["IdSO"]=> string(1) "1" ... } }
je veux sélectionner les champs de tout les tables et le résultat soit comme suite :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
array(2) { [0]=> array(4) { ["IdOrg"]=> string(1) "1" ["taleau 2"]=> array(){ 
 
	[0]=> array(4) { ["IdSO"]=> string(1) "1" ["Idorg"]=> string(1) "1" ["taleau 3"]=> array(){
 
		[0]=> {["IdDocs"]=> string(1) "1" ["IdOrg"]=> string(1) "1" ["IdSO"]=> string(1) "1"}
		[1]=> {["IdDocs"]=> string(1) "1" ["IdOrg"]=> string(1) "1" ["IdSO"]=> string(1) "1"}
...
}
	[1]=> array(4) { ["IdSO"]=> string(1) "1" ["Idorg"]=> string(1) "1" ["taleau 3"]=> array(){
 
		[0]=> {["IdDocs"]=> string(1) "1" ["IdOrg"]=> string(1) "1" ["IdSO"]=> string(1) "1"}
		[1]=> {["IdDocs"]=> string(1) "1" ["IdOrg"]=> string(1) "1" ["IdSO"]=> string(1) "1"}
...
}
 
} ... } }
mon code est le suivant:

Code :
1
2
3
4
5
6
7
8
9
 
$select = $db->select();
           $select->from(array("p" => "tableau1"), array("p.IdOrg"))
		     ->join(array("u" => "tablea2"),'p.IdOrg = u.Idorg' , array("u.IdSO"))
		    ->join(array("d" => "tableau3"),'d.IdSO = u.IdSO')
		    ->group(array('d.IdOrg'))
							   ;
 
	    $res = $db->fetchAll($select);
or ce code donne un autre résultat (résultat aplatis ):



Code :
1
2
3
array(2) { [0]=> array(14) { ["IdOrg"]=> string(1) "1" ["IdSO"]=> string(1) "1" ["IdDocs"]=> string(1) "2" } [1]=> array(14) { ["IdOrg"]=> string(1) "1" ["IdSO"]=> string(1) "1" ["IdDocs"]=> string(1) "3" } 
...
}
merci d'avance
kamclasse est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/05/2011, 13h27   #2
Modérateur
 
Inscription : septembre 2010
Messages : 7 103
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 103
Points : 8 466
Points : 8 466
formate tes var_dump en pre on verra mieux
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/05/2011, 15h23   #3
Membre du Club
 
Inscription : août 2008
Messages : 165
Détails du profil
Informations forums :
Inscription : août 2008
Messages : 165
Points : 50
Points : 50
bonjour est merciiii bcp pour votre réponse
en faite mon problème est simple je veux un affichage imbriqué :

======
====
===
===
===
======
====
===
===
===

au lieu d'un affichage aplatis :

===== ==== ===
===== ==== ===
===== ==== ===
...

mon code donne ceci:
Code :
1
2
3
4
 
array(2) { [0]=> array(14) { ["IdOrg"]=> string(1) "1" ["IdSO"]=> string(1) "1" ["IdDocs"]=> string(1) "2" } [1]=> array(14) { ["IdOrg"]=> string(1) "1" ["IdSO"]=> string(1) "1" ["IdDocs"]=> string(1) "3" } 
...
}

merciiiii
kamclasse est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/05/2011, 21h27   #4
Invité de passage
 
Femme
Ingénieur commercial
Inscription : mai 2011
Messages : 1
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : Maroc

Informations professionnelles :
Activité : Ingénieur commercial
Secteur : Industrie

Informations forums :
Inscription : mai 2011
Messages : 1
Points : 1
Points : 1
Bonsoir à toutes et à tous
en fait moi aussi, j'ai le même problème et jusqu'aujourd'hui je n'ai pas trouver une solution
si quelqu'un peut m'aider je serais très reconnaissante
khdoj est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/05/2011, 22h11   #5
Modérateur
 
Inscription : septembre 2010
Messages : 7 103
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 103
Points : 8 466
Points : 8 466
Il faut faire un fetch group.
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/05/2011, 18h31   #6
Membre du Club
 
Inscription : août 2008
Messages : 165
Détails du profil
Informations forums :
Inscription : août 2008
Messages : 165
Points : 50
Points : 50
merciii beaucoup stealth35 pour votre aide,

la fonction Zend_Db::FETCH_GROUP a réglé le problème d'affichage de résultat imbriqué en 1er niveau, mais pour mois j'ai un affichage en plusieurs niveau 3,4,5 niveau

est ce qu'il y a une solution, je me suis bloqué

et merciiii
kamclasse est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/05/2011, 18h48   #7
Membre du Club
 
Inscription : août 2008
Messages : 165
Détails du profil
Informations forums :
Inscription : août 2008
Messages : 165
Points : 50
Points : 50
bonjour j'ai oublié d'ajouter le code:

Code :
1
2
3
4
5
6
7
8
9
10
 
 
$select = $db->select()
             ->from(array("p" => "organisation"), array("p.Intitule","u.IntituleSO"))
	     ->join(array("u" => "sousorg"),'p.IdOrg = u.Idorg')
	     ->join(array("d" => "docs"),'d.IdSO = u.IdSO')
	     ->where('d.Etat = ?', "A")
	     ->order('d.DateCreatDoc desc');
 
	$res = $db->fetchAll($select,null,Zend_Db::FETCH_GROUP);
je veux un groupement à 2 niveau

1- p.Intitule
2- u.IntituleSO

malheureusement le résultat est groupé au premier niveau seulement p.Intitule

merciiiii bien
kamclasse est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 10h03.


 
 
 
 
Partenaires

Hébergement Web