Hi Daniel,

In the PHP code you provided, you can't pass back the raw $results
variable because its not a normal PHP variable - its a resource, which
holds external data and can only be used by special PHP functions (in
this case, the mysql library.)

To pass back the results from your query, you'll first need to extract
the data into a format that can be passed by AMFPHP. Something similar
to the following:

<?php

 class SimplePerson 
 {
     function getPeople() 
     {
         $mysql = mysql_connect(localhost, "root", "root");
 
         mysql_select_db( "people-test" );
 
         $sSQL = "SELECT * FROM `tblPeople`";
 
         $results =  mysql_query($sSQL);

         $queryResults = array();

         while($queryOb = mysql_fetch_assoc($results))
            $queryResults[] = $queryOb;

          return $queryResults;
     }
 }
 
 ?>

That'll show up in Flex as an array containing generic objects that
contain your query results.

For more info on resources, this link should help:
http://www.php.net/manual/en/language.types.resource.php

Hope this helps!

--- In flexcoders@yahoogroups.com, "Daniel Tse" <[EMAIL PROTECTED]> wrote:
>
> Hi All,
> 
> I have setup AMFPHP and it returns back the recordset object from a
MySQL
> query. I was wondering how I access that array/recordset from the
flex side.
> 
> e.g. I have the following:
> 
> <?php
> //In the services directory of AMFPHP
> class SimplePerson {
>     function getPeople() {
>        $mysql = mysql_connect(localhost, "root", "root");
> 
>          mysql_select_db( "people-test" );
> 
>          $sSQL = "SELECT * FROM `tblPeople`";
> 
>          $results =  mysql_query($sSQL);
> 
>         return $results;
>     }
> }
> 
> ?>
> 
> In Flex..
>            public function getPeople():void {
>                 myService.connect(REMOTESERVERURL);
> 
>                 var responder:Responder = new
Responder(getPeople_Result,
> onFault);
>                 myService.call("SimplePerson.getPeople", responder);
> 
>             }
> 
>             public function
> getPeople_Result(aoResults:WHAT_SHOULD_GO_HERE):void
>             {
>                 //test;
>                 //I'd like to access the result set e.g. iterate
through the
> rows looking at certain columns
>             }
> 
> "Array" doesn't seem to work (the fact that it's a 1-dimensional array
> doesn't help)
> "XMLList" the object doesn't seem to map like that either
> 
> Am I missing some kind of object?
> 
> Thanks,
> -Daniel
> -- 
> -------------
> e: [EMAIL PROTECTED]
> w: http://DanielTse.com/
> -------------
>


Reply via email to