Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > Flash/Flex > Flex
Flex Forum d'entraide sur la programmation Adobe Flex : applications Internet riches (RIA)
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 04/09/2011, 14h49   #1
Invité régulier
 
Inscription : juin 2004
Messages : 29
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 29
Points : 8
Points : 8
Par défaut Flex Zend AMF et JOIN

Bonjour à tous,

j'essai avec beaucoup de mal de faire fonctionner Flex et les data service PHP (qui utilise zend amf)
J'ai 2 tables :
1 table t_adherents (adhId, adhNom...) et 1 table t_adresses (adrId, adhId, adrLigne1...)

La classe PHP automatiquement généré par Flex me permet de lister, d'ajouter correctement des données dans ma table t_adhérents (sans s'occuper des adresses).

J'ai donc modifier la requete de cette façon
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
25
26
27
public function getAllT_adherents() {
 
		$this->throwExceptionOnError();
		$stmt = mysqli_prepare($this->connection, 
		"SELECT adh.adhId, adh.adhNom, adh.adhPrenom, adh.adhDateN, adh.adhSecu, adr.adrLigne1 
		FROM t_adherents AS adh 
		LEFT OUTER JOIN t_adresses AS adr ON adh.adhId = adr.adr_adhId");		
 
		mysqli_stmt_execute($stmt);
		$this->throwExceptionOnError();
 
		$rows = array();
 
		mysqli_stmt_bind_result($stmt, $row->adhId, $row->adhNom, $row->adhPrenom, $row->adhDateN, $row->adhSecu, $row->adrLigne1);
 
	    while (mysqli_stmt_fetch($stmt)) {
	      $rows[] = $row;
	      $row = new stdClass();
	      mysqli_stmt_bind_result($stmt, $row->adhId, $row->adhNom, $row->adhPrenom, $row->adhDateN, $row->adhSecu, $row->adrLigne1);
 
	    }
 
		mysqli_stmt_free_result($stmt);
	    mysqli_close($this->connection);
 
	    return $rows;
	}
Toutefois dans la partie Flex je ne parviens pas a afficher dans mon datagrid les données correspondants à la table t_adresses :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
<s:DataGrid id="dataGrid" x="141" y="45" width="628" height="122"
				creationComplete="dataGrid_creationCompleteHandler(event)" requestedRowCount="4">
		<s:columns>
			<s:ArrayList>
				<s:GridColumn dataField="adhId" headerText="adhId"></s:GridColumn>
				<s:GridColumn dataField="adhNom" headerText="adhNom"></s:GridColumn>
				<s:GridColumn dataField="adhPrenom" headerText="adhPrenom"></s:GridColumn>
				<s:GridColumn dataField="adhDateN" headerText="adhDateN"></s:GridColumn>
				<s:GridColumn dataField="adhSecu" headerText="adhSecu"></s:GridColumn>
				<s:GridColumn dataField="adrLigne1" headerText="adre"></s:GridColumn>
			</s:ArrayList>
		</s:columns>
Les données adhNom, adhPrenom... s'affichent correctement.

Une idée. Merci par avance..
tininou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/09/2011, 15h10   #2
Membre Expert
 
Avatar de Madfrix
 
Inscription : juin 2007
Messages : 2 279
Détails du profil
Informations personnelles :
Localisation : France, Gironde (Aquitaine)

Informations forums :
Inscription : juin 2007
Messages : 2 279
Points : 2 325
Points : 2 325
Bonjour,

tu peux tester via PHP de faire un var_export dans un fichier de ta variable $row pour voir si le résultat est celui attendu. C'est peut être pour cela que Flex te montre pas toutes les données, il t'en manque peut être
__________________
Je ne réponds pas aux questions envoyées par mp
Madfrix est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/09/2011, 19h36   #3
Invité régulier
 
Inscription : juin 2004
Messages : 29
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 29
Points : 8
Points : 8
Merci pour ton aide.
J'ai fait une petite fonction qui fait un var_dump
Code :
1
2
3
4
5
6
7
8
9
10
11
12
function logMe($var) {
    $filename = dirname(__FILE__) . '/__lognico.txt';          
    if (!$handle = fopen($filename, 'a')) {
        echo "Cannot open file ($filename)";         
        return;
     }          
    $toSave = var_export($var, true);    
    fwrite($handle, "[" . date("y-m-d H:i:s") . "]");     
    fwrite($handle, "\n");    
    fwrite($handle, $toSave);     fwrite($handle, "\n");     
    fclose($handle); 
}
J'ai testé dans comme ceci :
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
25
26
27
public function getAllT_adherents() {
 
		$this->throwExceptionOnError();
		$stmt = mysqli_prepare($this->connection, 
		"SELECT adh.adhId, adh.adhNom, adh.adhPrenom, adh.adhDateN, adh.adhSecu, adr.adrLigne1 
		FROM t_adherents AS adh 
		LEFT OUTER JOIN t_adresses AS adr ON adh.adhId = adr.adr_adhId");		
 
		mysqli_stmt_execute($stmt);
		$this->throwExceptionOnError();
 
		$rows = array();
 
		mysqli_stmt_bind_result($stmt, $row->adhId, $row->adhNom, $row->adhPrenom, $row->adhDateN, $row->adhSecu, $row->adrLigne1);
 
	    while (mysqli_stmt_fetch($stmt)) {
	      $rows[] = $row;
	      $row = new stdClass();
	      mysqli_stmt_bind_result($stmt, $row->adhId, $row->adhNom, $row->adhPrenom, $row->adhDateN, $row->adhSecu, $row->adrLigne1);
	    logMe($row);
	    }
 
		mysqli_stmt_free_result($stmt);
	    mysqli_close($this->connection);
 
	    return $rows;
	}
et voilà ce que cela me retourne :

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
25
26
27
[11-09-04 19:29:50]
stdClass::__set_state(array(
   'adhId' => NULL,
   'adhNom' => NULL,
   'adhPrenom' => NULL,
   'adhDateN' => NULL,
   'adhSecu' => NULL,
   'adrLigne1' => NULL,
))
[11-09-04 19:29:50]
stdClass::__set_state(array(
   'adhId' => NULL,
   'adhNom' => NULL,
   'adhPrenom' => NULL,
   'adhDateN' => NULL,
   'adhSecu' => NULL,
   'adrLigne1' => NULL,
))
[11-09-04 19:29:50]
stdClass::__set_state(array(
   'adhId' => NULL,
   'adhNom' => NULL,
   'adhPrenom' => NULL,
   'adhDateN' => NULL,
   'adhSecu' => NULL,
   'adrLigne1' => NULL,
))
Là où je ne comprend rien c'est que cela "log" bien le nombre d'enregistrement dans la base et que mon datagrid se complete bien pour adhID, adhNom mais rien pour adrLigne1. (j'ai également essayé les autres champs de ma table adresse et idem)

Je ne comprends plus rien.
tininou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/09/2011, 00h18   #4
Membre Expert
 
Avatar de Madfrix
 
Inscription : juin 2007
Messages : 2 279
Détails du profil
Informations personnelles :
Localisation : France, Gironde (Aquitaine)

Informations forums :
Inscription : juin 2007
Messages : 2 279
Points : 2 325
Points : 2 325
C'est normal, tu insères ton $row dans ton tableau puis tu affectes tes valeurs. Remplaces par ceci

Code php :
1
2
3
4
5
6
7
 
while (mysqli_stmt_fetch($stmt)) {
    $row = new stdClass();
    mysqli_stmt_bind_result($stmt, $row->adhId, $row->adhNom, $row->adhPrenom, $row->adhDateN, $row->adhSecu, $row->adrLigne1);
    $rows[] = $row;
    logMe($row);
}
__________________
Je ne réponds pas aux questions envoyées par mp
Madfrix est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/09/2011, 21h07   #5
Invité régulier
 
Inscription : juin 2004
Messages : 29
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 29
Points : 8
Points : 8
Merci pour ton aide...Toutefois j'ai toujours le même résultat même en essayant cela :
Code :
1
2
3
4
5
6
 
while (mysqli_stmt_fetch($stmt)) {
    $row = new stdClass();
    mysqli_stmt_bind_result($stmt, $row->adhId, $row->adhNom, $row->adhPrenom, $row->adhDateN, $row->adhSecu, $row->adrLigne1);
    $rows[] = $row;
    logMe($row);
Je nage...
tininou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/09/2011, 21h30   #6
Invité régulier
 
Inscription : juin 2004
Messages : 29
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 29
Points : 8
Points : 8
Bon j'avance un peu... (un peu mais juste un peu... )

en fait avec logMe($rows) (et non pas row j'ai bien mes données y compris adrLigne1
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
[11-09-05 21:25:29]
array (
  0 => 
  stdClass::__set_state(array(
     'adhId' => 1,
     'adhNom' => 'Toto',
     'adhPrenom' => 'bill',
     'adrLigne1' => '25 rue loulou',
  )),
  1 => 
  stdClass::__set_state(array(
     'adhId' => 2,
     'adhNom' => 'LILI',
     'adhPrenom' => 'Coco',
     'adrLigne1' => '12 rue de l\'orage',
Bon je reviens donc à mon problème d'origine... pourquoi dans flex je n'arrive pas a afficher dans mon datagrid mon adrLigne1.... ?

Je crois avoir une piste. J'ai également fait un formulaire lié à mon datagrid pour effectuer des modifications sur les enregistrements. Tout est ok pour mes champs de ma table T_Adherents mais pas pour ceux de la jointure issues de la tables T_Adresses.
Voilà l'erreur :
Citation:
1119: Accès à la propriété adrLigne1 peut-être non définie, via la référence de type static valueObjects:T_adherents
Donc je suis en train de me demander si j'utilise la bonne méthode pour faire la jointure.

Des idées ?
tininou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/09/2011, 21h49   #7
Membre Expert
 
Avatar de Madfrix
 
Inscription : juin 2007
Messages : 2 279
Détails du profil
Informations personnelles :
Localisation : France, Gironde (Aquitaine)

Informations forums :
Inscription : juin 2007
Messages : 2 279
Points : 2 325
Points : 2 325
EDIT suite à ton EDIT ^^

tu parles de la jointure SQL faite sous PHP ?

PS: fais voir le code AS3 stp
__________________
Je ne réponds pas aux questions envoyées par mp
Madfrix est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/09/2011, 21h52   #8
Invité régulier
 
Inscription : juin 2004
Messages : 29
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 29
Points : 8
Points : 8
Citation:
EDIT suite à ton EDIT ^^

tu parles de la jointure SQL faite sous PHP ?
Oui...


PS/ désolé pour le multi Edit..... je ne voulais pas créer des milliers de posts...


Le code AS3
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
			   xmlns:s="library://ns.adobe.com/flex/spark"
			   xmlns:mx="library://ns.adobe.com/flex/mx"
			   xmlns:valueObjects="valueObjects.*"
			   xmlns:tadherentsservice="services.tadherentsservice.*"
			   minWidth="955" minHeight="600">
 
	<fx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.events.FlexEvent;
 
 
			protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
			{
	getAllT_adherentsResult.token = tadherentsService.getAllT_adherents();
			}
 
		]]>
	</fx:Script>
 
	<fx:Declarations>
		<valueObjects:T_adherents id="t_adherents"/>
		<s:CallResponder id="createT_adherentsResult"/>
		<tadherentsservice:TadherentsService id="tadherentsService"
			fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
			showBusyCursor="true"/>
		<s:CallResponder id="getAllT_adherentsResult"/>
		<valueObjects:T_adherents id="t_adherents2"/>
 
		<!-- Placer ici les éléments non visuels (services et objets de valeur, par exemple). -->
	</fx:Declarations>
 
	<s:DataGrid id="dataGrid" x="141" y="45" width="628" height="122"
				creationComplete="dataGrid_creationCompleteHandler(event)" requestedRowCount="4">
		<s:columns>
			<s:ArrayList>
				<s:GridColumn dataField="adhId" headerText="adhId"></s:GridColumn>
				<s:GridColumn dataField="adhNom" headerText="adhNom"></s:GridColumn>
				<s:GridColumn dataField="adhPrenom" headerText="adhPrenom"></s:GridColumn>
				<s:GridColumn dataField="adhDateN" headerText="adhDateN"></s:GridColumn>
				<s:GridColumn dataField="adhSecu" headerText="adhSecu"></s:GridColumn>
				<s:GridColumn dataField="adrLigne1" headerText="adre"></s:GridColumn>
			</s:ArrayList>
		</s:columns>
 
		<s:AsyncListView list="{getAllT_adherentsResult.lastResult}"/>
	</s:DataGrid>
 
</s:Application>
tininou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/09/2011, 22h03   #9
Membre Expert
 
Avatar de Madfrix
 
Inscription : juin 2007
Messages : 2 279
Détails du profil
Informations personnelles :
Localisation : France, Gironde (Aquitaine)

Informations forums :
Inscription : juin 2007
Messages : 2 279
Points : 2 325
Points : 2 325
Citation:
Envoyé par tininou Voir le message
Tout est ok pour mes champs de ma table T_Adherents mais pas pour ceux de la jointure issues de la tables T_Adresses.
Peut on voir comment tu construis ton formulaire et comment tu récupères les valeurs associées ?
__________________
Je ne réponds pas aux questions envoyées par mp
Madfrix est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/09/2011, 22h10   #10
Invité régulier
 
Inscription : juin 2004
Messages : 29
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 29
Points : 8
Points : 8
Pour le form :
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
25
<fx:Binding destination="t_adherents" source="dataGrid.selectedItem as T_adherents"/>
<s:Form x="357" y="207" defaultButton="{button}">
	<s:FormItem label="AdhNom">
		<s:TextInput id="adhNomTextInput" text="{t_adherents.adhNom}"/>
	</s:FormItem>
	<s:FormItem label="AdhPrenom">
		<s:TextInput id="adhPrenomTextInput" text="{t_adherents.adhPrenom}"/>
	</s:FormItem>
	<s:FormItem label="AdhDateN">
		<s:TextInput id="adhDateNTextInput" text="{t_adherents.adhDateN}"/>
	</s:FormItem>
	<s:FormItem label="AdhSecu">
		<s:TextInput id="adhSecuTextInput2" text="{t_adherents.adhSecu}"/>
	</s:FormItem>
	<s:Button id="button" label="Modifier" click="button_clickHandler(event)"/>
</s:Form>
 
 
protected function button_clickHandler(event:MouseEvent):void
{
	t_adherents.adhNom = adhNomTextInput.text;
	t_adherents.adhPrenom = adhPrenomTextInput.text;
	t_adherents.adhDateN = adhDateNTextInput.text;
	t_adherents.adhSecu = adhSecuTextInput.text;
}
tininou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/09/2011, 22h20   #11
Membre Expert
 
Avatar de Madfrix
 
Inscription : juin 2007
Messages : 2 279
Détails du profil
Informations personnelles :
Localisation : France, Gironde (Aquitaine)

Informations forums :
Inscription : juin 2007
Messages : 2 279
Points : 2 325
Points : 2 325
Je comprends pas trop le soucis en fait car tu récupères de ta table adresse le champs adrLigne1 qui, m'as tu dis, est dorénavant bien récupéré via SQL (cf: "en fait avec logMe($rows) (et non pas row j'ai bien mes données y compris adrLigne1").

Il s'agit donc d'après toi d'un problème uniquement sous Flex de binding de propriétés ?
__________________
Je ne réponds pas aux questions envoyées par mp
Madfrix est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/09/2011, 22h28   #12
Invité régulier
 
Inscription : juin 2004
Messages : 29
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 29
Points : 8
Points : 8
Oui en fait je pense que le soucis viens des services automatiquement créé par Flex :
Y'a plusieurs fichiers dans lesquels je viens de voir que (je colle le début) :
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
25
26
27
28
29
30
31
32
33
34
package valueObjects
{
import com.adobe.fiber.styles.IStyle;
import com.adobe.fiber.styles.Style;
import com.adobe.fiber.valueobjects.AbstractEntityMetadata;
import com.adobe.fiber.valueobjects.AvailablePropertyIterator;
import com.adobe.fiber.valueobjects.IPropertyIterator;
import com.adobe.fiber.core.model_internal;
import com.adobe.fiber.valueobjects.IModelType;
import mx.events.PropertyChangeEvent;
 
use namespace model_internal;
 
[ExcludeClass]
internal class _T_adherentsEntityMetadata extends com.adobe.fiber.valueobjects.AbstractEntityMetadata
{
    private static var emptyArray:Array = new Array();
 
    model_internal static var allProperties:Array = new Array("adhId", "adhNom", "adhPrenom", "adhDateN", "adhSecu");
    model_internal static var allAssociationProperties:Array = new Array();
    model_internal static var allRequiredProperties:Array = new Array("adhId");
    model_internal static var allAlwaysAvailableProperties:Array = new Array("adhId", "adhNom", "adhPrenom", "adhDateN", "adhSecu");
    model_internal static var guardedProperties:Array = new Array();
    model_internal static var dataProperties:Array = new Array("adhId", "adhNom", "adhPrenom", "adhDateN", "adhSecu");
    model_internal static var sourceProperties:Array = emptyArray
    model_internal static var nonDerivedProperties:Array = new Array("adhId", "adhNom", "adhPrenom", "adhDateN", "adhSecu");
    model_internal static var derivedProperties:Array = new Array();
    model_internal static var collectionProperties:Array = new Array();
    model_internal static var collectionBaseMap:Object;
    model_internal static var entityName:String = "T_adherents";
    model_internal static var dependentsOnMap:Object;
    model_internal static var dependedOnServices:Array = new Array();
    model_internal static var propertyTypeMap:Object;
...
Ces fichier sont été crée je pense suite à l'introspection (c'est comme ca qu'on dit ?) de la base.

ca fait une quantité de données à modifier du coup... je me suis dit donc que je m'y était mal pris.... (j'ai laissé faire Flash Builder 4 et Zend pour mes class PHP....)
tininou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/09/2011, 22h32   #13
Membre Expert
 
Avatar de Madfrix
 
Inscription : juin 2007
Messages : 2 279
Détails du profil
Informations personnelles :
Localisation : France, Gironde (Aquitaine)

Informations forums :
Inscription : juin 2007
Messages : 2 279
Points : 2 325
Points : 2 325
Honnêtement...Crée tout toi même c'est bien plus simple en fait et c'est surtout moins le bordel

Si tu as fait comme cela, je me doute que tu sais pas le faire manuellement, donc dis moi ou tu coinces et je t'aiderais à configurer si tu veux
__________________
Je ne réponds pas aux questions envoyées par mp
Madfrix est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/09/2011, 22h38   #14
Invité régulier
 
Inscription : juin 2004
Messages : 29
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 29
Points : 8
Points : 8
Merci pour ton aide et ta proposition que j'accepte volontiers....

Je vais mettre les choses à plat et essayer de repartir de zéro...
Je reviendrais certainement poser des questions.....
tininou 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 23h44.


 
 
 
 
Partenaires

Hébergement Web