2 Replies Latest reply on May 24, 2010 5:48 AM by David_F57

    Queries to retrieve records (using Coldfusion) into arrays

    ndilekli

      I have been reading about Coldfusion and Flex/Flash Builder integration, I am quite the beginner here. So far, I was able to follow the examples I found at Adobe's website. Those tutorials show how to bind the query results into forms. What I want to do is to run a query that will return multiple records, and I would like to store those records in an array. In other words I want to access each of the elements of each object by iterating

       

      Here is an example (I am only putting the relevant part of the code here) of what I could achieve with binding so far


                  protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
                  {
                      getEmployeeDataByRegionResult.token = salesTarget.getEmployeeDataByRegion(/*Enter value(s) for */ 'Central');
                  }


                <s:CallResponder id="getEmployeeDataByRegionResult"/>


          <mx:DataGrid x="477" y="118" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getEmployeeDataByRegionResult.lastResult}">
              <mx:columns>
                  <mx:DataGridColumn headerText="PHONE" dataField="PHONE"/>
                  <mx:DataGridColumn headerText="FIRSTNAME" dataField="FIRSTNAME"/>
                  <mx:DataGridColumn headerText="YTD" dataField="YTD"/>
                  <mx:DataGridColumn headerText="Q1GOAL" dataField="Q1GOAL"/>
                  <mx:DataGridColumn headerText="EMAIL" dataField="EMAIL"/>
                  <mx:DataGridColumn headerText="LASTNAME" dataField="LASTNAME"/>
              </mx:columns>
          </mx:DataGrid>

       

      So instead of this, I basically want to load the results into an array, so that I can iterate through the records as I want. A mysql query in php type of query is exactly what I am looking for. For example

       

      $result = mysql_query("SELECT id, name FROM mytable WHERE .... ");

       

      while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
          printf("ID: %s  Name: %s", $row[0], $row[1]); 
      }

       

      Thank you