3 Replies Latest reply on Oct 15, 2010 2:44 AM by juedvaga80

    Store into an array the results of a PhpService


      Hi all I have a problem with flex and I'm stuck and we need help, this is urgent !!!!!! please


      My problem is that I would like to store in an array or ArrayCollection the result of running a php function (in my case "getTestSesion ()") to make any changes on some of the elements that my array will contain, before placing it on my  DataGrid.dataProvider (when I say change I mean items such as concatenate something to a specific element)


      I leave more and less what I have done.


      This is my table in mysql:

        `id_ses` int(1) NOT NULL AUTO_INCREMENT,
        `nombre_sesion` varchar(18) NOT NULL,
        `detalle_sesion` varchar(32) DEFAULT NULL,
        PRIMARY KEY (`id_ses`)
      ) ENGINE=InnoDB


      and I create this function to read my table using the Flash Builder wizard for DB connection:


      public function getTestSesion() {
           $stmt = mysqli_prepare($this->connection,
                "select id_ses as id,
                   nombre_sesion as nombre
                 from sesion");    
            $rows = array();
            mysqli_stmt_bind_result($stmt, $row->id, $row->nombre);
            while (mysqli_stmt_fetch($stmt)) {
                $rows[] = $row;
                $row = new stdClass();
                mysqli_stmt_bind_result($stmt, $row->id, $row->nombre);
            return $rows;


      and on my aplication i have:


         protected function miDatagrid_creationCompleteHandler(event:FlexEvent):void
                createSesionResult.token = pruebasService.getTestSesion();
      <s:CallResponder id="createSesionResult"/>
          <mx:DataGrid x="139" y="90" id="dataGrid"
                  <mx:DataGridColumn headerText="id" dataField="id"/>
                  <mx:DataGridColumn headerText="nombre" dataField="nombre"/>

        • 1. Re: Store into an array the results of a PhpService
          juedvaga80 Level 1

          Hello everybody


          please can somebody help me:


          this is another simple example:


          I have this function into my service class:


          public function test($my_string)
            // creating an array by explode command
            $my_array = explode(" ",$my_string);
            return $my_array; // returning the array


          and since my aplication i call this like this:


          var myarray:Array = salfventasseriesService.test("this is a test");


          but i have this error:


          Multiple markers at this line:
          -1067: Implicit coercion of a value of type mx.rpc:AsyncToken to an unrelated type Array.


          How can I put the resul into an ARRAY ?


          can anybody help me ?

          • 2. Re: Store into an array the results of a PhpService
            Sameer Bhatt Adobe Employee

            You can add a result handler to the call responder, get the result, modify it and assign it to the datagrid.

            <s:CallResponder id="createSesionResult" result="resultHandler(event)"/>
            protected function resultHandler(event:ResultEvent):void
                   // event.result or createSesionResult.lastResult will give the result
                   // modify the result here and assign it to the datagrid
            1 person found this helpful
            • 3. Re: Store into an array the results of a PhpService
              juedvaga80 Level 1



              THANKS A LOT man,


              it really was helpfull, i didn't have an idea that i could use "result" inside CallResponder