Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Supporting Technologies > Flash Remoting

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-15-2003, 12:45 PM   #1
heyder
creative soloper
 
Join Date: Sep 2002
Posts: 43
Default RecordSet/DataGlue -amfphp

Wondering what I need to do to be able to use the DataGlue API, or if it even works with amfphp.

I've been able to get data back from php/mySql and populate a combobox but... I would like to figure out how to bind the data using DataGlue.

When I recieve the data back using amfphp is that considered a RecordSet or do I have to create a RecordSet in flash using

new RecordSet (colunmNames) or something

heyder is offline   Reply With Quote
Old 07-15-2003, 01:51 PM   #2
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

Depends on how you are getting the data, if you simple return the result of a query from your class, it is a recordset in flash.

Consider this class I use to get data from a people database in MySQL. Both getPeople and getPersonById will return a recordset to flash.

PHP Code:
<?php
class People
{
    var 
$db;
    var 
$DBHOST =  "localhost";
    var 
$DBUSER "********";
    var 
$DBPASS "*********";
    var 
$DBNAME "********";
    
    function 
People()
    {
        
$this->methodTable = array(            
            
"getPeople" => array(                
            
"description" => "Return a list of people from the database."
            
"access" => "remote"
            
"roles" => "role, getPeople"
            
"arguments" => array ()),
            
"getPersonById" => array(                
            
"description" => "Return a person detail"
            
"access" => "remote"
            
"roles" => "role, getPersonById"
            
"arguments" => array ("person_id"))
        );    
        
$this->db mysql_connect($this->DBHOST$this->DBUSER$this->DBPASS);
        
mysql_select_db($this->DBNAME);
    }

    function 
getPeople() {
        return 
mysql_query("SELECT person_id, person_name_first, person_name_last from person");
    }

    function 
getPersonById($person_id) {
        return 
mysql_query("SELECT * from person WHERE person_id = '$person_id'");
    }

}

?>
So if I call the getPeople method I get three fields back id firstname and lastname. Here is what my actionscript might look like.
ActionScript Code:
#include "NetServices.as" #include "NetDebug.as" #include "DataGlue.as" init = false; if(defaultGateway == undefined) defaultGateway = "http://freddy/amf2/simpleGateway.php"; function connect() {     if(init == false) {         init = true;         NetServices.setDefaultGatewayURL(defaultGateway);         conn = NetServices.createGatewayConnection();         myservice = conn.getService("People", this);         myservice.getPeople();     } } connect(); function getPeople_Result(result) {     DataGlue.bindFormatStrings (myList, result, "#person_id# = #person_name_first# #person_name_last#");    } stop();

AS you can probably see its fairly simple to use.

Or if you want to have labels and data in the listbox you can use the bindFormatFunction method like
ActionScript Code:
#include "NetServices.as" #include "NetDebug.as" #include "DataGlue.as" init = false; if(defaultGateway == undefined) defaultGateway = "http://freddy/amf2/simpleGateway.php"; function connect() {     if(init == false) {         init = true;         NetServices.setDefaultGatewayURL(defaultGateway);         conn = NetServices.createGatewayConnection();         myservice = conn.getService("People", this);         myservice.getPeople();     } } connect(); function getPeople_Result(result) {     DataGlue.bindFormatFunction (myList, result, myCustomFunc)} function myCustomFunc ( record ) {     var myLabel = record.person_name_last + ", " + record.person_name_first;     return {label: myLabel, data: record.person_id}; } stop();
freddycodes is offline   Reply With Quote
Old 07-15-2003, 07:53 PM   #3
heyder
creative soloper
 
Join Date: Sep 2002
Posts: 43
Default

Sweet, thanks so much for the example code, I've just started playing around with this stuff so the more code samples I can get my hands on the better.
heyder is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:34 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.