Hi Daniel,

*> I noticed on the AMFPHP browser page it can actually create a table based
> on the recordset that is returned. e.g. the table automatically changes
based
> on my sql result and it doesn't seem like there's any specific binding to
> columns. I'm curious as to how they did that.

*You will notice that if you change the settings from AMF3 to AMF0, it will
no longer work. You must use AMF3 to get results back as an ArrayCollection.
You can see how he creates the DataGrid by looking at the servicebrowser
source here:

http://www.5etdemi.com/uploads/servicebrowser.zip

Regards,
~Aaron


On Mon, Mar 24, 2008 at 11:54 PM, Daniel Tse <[EMAIL PROTECTED]> wrote:

>   Thanks Aaron,
>
> I'll see what I can look up on the RemoteObject as well.
>
> CaffeineWabbit,
>
> Thanks for the pointers. I saw that Mike Potter's AMFPHP example also
> created a php array instead of using the mysql results object but... I
> noticed on the AMFPHP browser page it can actually create a table based on
> the recordset that is returned. e.g. the table automatically changes based
> on my sql result and it doesn't seem like there's any specific binding to
> columns. I'm curious as to how they did that.
>
> In short, I'd like to find a convenient way for the client to parse the
> results of a remote sql query.
>
> Thanks all!
> -Daniel
>
> On Mon, Mar 24, 2008 at 5:53 PM, Aaron Miller <
> [EMAIL PROTECTED]> wrote:
>
> >   Just as a follow up. I verified that using RemoteObject does in fact
> > return an ArrayCollection as the result, while NetConnection does not
> > (returns an outdated ResultSet object). Hopefully someone at Adobe could
> > explain the difference in remoting procedure between the two methods.
> >
> > Regards,
> > ~Aaron
> >
> >
> >
> > On Mon, Mar 24, 2008 at 5:23 PM, Aaron Miller <
> > [EMAIL PROTECTED]> wrote:
> >
> > > Hello again. I did some more reading on this and I think the problem
> > > is with using NetConnection instead of RemoteObject. Apperently, using
> > > NetConnection does not always send the right headers to tell AMFPHP to use
> > > AMF3 encoding, thus it tries to return a ResultSet instead of an
> > > ArrayCollection. You can tell you got a ResultSet if the return object 
> > > has a
> > > serverInfo property. From what I've read, using RemoteObject is a surefire
> > > way to get the right headers (AMF3) and will guarantee an ArrayCollection 
> > > is
> > > returned. However, having been accustomed to NetConnection myself, and I 
> > > am
> > > trying to figure out a way to do this without RemoteObject. Setting
> > > NetConnection.objectEncoding to ObjectEncoding.AMF3 did not help for
> > > some reason. Maybe someone else can chime in on this.
> > >
> > > In  the mean time, here is a good tutorial on RemoteObject with
> > > AMFPHP:
> > >
> > > http://www.sephiroth.it/tutorials/flashPHP/flex_remoteobject/index.php
> > >
> > > Best Regards,
> > > ~Aaron
> > >
> > >
> > > On Mon, Mar 24, 2008 at 3:57 PM, caffeinewabbit <
> > > [EMAIL PROTECTED]> wrote:
> > >
> > > >   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 <flexcoders%40yahoogroups.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/
> > > > > -------------
> > > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Aaron Miller
> > > Chief Technology Officer
> > > Open Base Interactive, LLC.
> > > [EMAIL PROTECTED]
> > > http://www.openbaseinteractive.com
> > >
> >
> >
> >
> > --
> > Aaron Miller
> > Chief Technology Officer
> > Open Base Interactive, LLC.
> > [EMAIL PROTECTED]
> > http://www.openbaseinteractive.com
> >
>
>
>
> --
> -------------
> e: [EMAIL PROTECTED]
> w: http://DanielTse.com/
> -------------
> 
>



-- 
Aaron Miller
Chief Technology Officer
Open Base Interactive, LLC.
[EMAIL PROTECTED]
http://www.openbaseinteractive.com

Reply via email to