Bonjour,
Étant grand débutant en Flex j'ai quelques soucis avec des opérations qui pourrait sembler assez basique.
J'essaie pour l'instant de faire afficher dans une DataGrid le contenu d'une table de ma base de donnée. Je suis pour cela passé dans Flex Builder 4 par "Connexion donnée/service PHP" et j'ai généré un exemple à partir de ma base de données. Je rentre les infos (root/localhost/nom_base) la connexion s'effectue, je choisi ma table. Les fichiers sont générés, je fais un drag drop de ma fonction "getAllnom_tableResult" sur le DataGrid qui ajuste automatiquement les noms de colonne en fonction. Jusque là tout correspond avec les différents tutos dont je me suis inspiré. J'exécute tout ça et j'obtiens un joli message:

"Canal déconnecté - Canal déconnecté avant l'obtention de l'accusé de réception"

On dirai qu'il n'arrive pas à accéder à la BDD alors que pourtant lors de la création de service la connexion et detection des différentes tables s'effectuait parfaitement.


code Flex:


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<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" minWidth="955" minHeight="600"  xmlns:totalauroraservice="services.totalauroraservice.*">
    <fx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.events.FlexEvent;
 
            protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
            {
                getAllTotalauroraResult.token = totalauroraService.getAllTotalaurora();
            }
 
        ]]>
    </fx:Script>
    <fx:Declarations>
        <s:CallResponder id="getAllTotalauroraResult"/>
        <totalauroraservice:TotalauroraService id="totalauroraService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
        <!-- Placer ici les éléments non visuels (services et objets de valeur, par exemple). -->
    </fx:Declarations>
    <s:Button x="209" y="267" label="Button"/>
    <mx:DataGrid x="62" y="81" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getAllTotalauroraResult.lastResult}">
        <mx:columns>
            <mx:DataGridColumn headerText="date" dataField="date"/>
            <mx:DataGridColumn headerText="ond1" dataField="ond1"/>
            <mx:DataGridColumn headerText="ond2" dataField="ond2"/>
            <mx:DataGridColumn headerText="ond3" dataField="ond3"/>
            <mx:DataGridColumn headerText="ond4" dataField="ond4"/>
            <mx:DataGridColumn headerText="ond5" dataField="ond5"/>
            <mx:DataGridColumn headerText="ond6" dataField="ond6"/>
            <mx:DataGridColumn headerText="ond7" dataField="ond7"/>
            <mx:DataGridColumn headerText="ond8" dataField="ond8"/>
            <mx:DataGridColumn headerText="ond9" dataField="ond9"/>
            <mx:DataGridColumn headerText="Total" dataField="Total"/>
        </mx:columns>
    </mx:DataGrid>
</s:Application>
PHP :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
53
54
55
56
57
58
59
class TotalauroraService {
 
    var $username = "root";
    var $password = "";
    var $server = "localhost";
    var $port = "";
    var $databasename = "database";
    var $tablename = "totalaurora";
 
    var $connection;
 
    /**
     * The constructor initializes the connection to database. Everytime a request is 
     * received by Zend AMF, an instance of the service class is created and then the
     * requested method is invoked.
     */
    public function __construct() {
          $this->connection = mysqli_connect(
                                  $this->server,  
                                  $this->username,  
                                  $this->password, 
                                  $this->databasename,
                                  $this->port
                              );
 
        $this->throwExceptionOnError($this->connection);
    }
 
    /**
     * Returns all the rows from the table.
     *
     * Add authroization or any logical checks for secure access to your data 
     *
     * @return array
     */
    public function getAllTotalaurora() {
 
        $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename");        
        $this->throwExceptionOnError();
 
        mysqli_stmt_execute($stmt);
        $this->throwExceptionOnError();
 
        $rows = array();
 
        mysqli_stmt_bind_result($stmt, $row->date, $row->ond1, $row->ond2, $row->ond3, $row->ond4, $row->ond5, $row->ond6, $row->ond7, $row->ond8, $row->ond9, $row->Total);
 
        while (mysqli_stmt_fetch($stmt)) {
          $row->date = new DateTime($row->date);
          $rows[] = $row;
          $row = new stdClass();
          mysqli_stmt_bind_result($stmt, $row->date, $row->ond1, $row->ond2, $row->ond3, $row->ond4, $row->ond5, $row->ond6, $row->ond7, $row->ond8, $row->ond9, $row->Total);
        }
 
        mysqli_stmt_free_result($stmt);
        mysqli_close($this->connection);
 
        return $rows;
    }
Si quelqu'un a une idée pour me sortir de là. Merci d'avance.