You can take 2 approaches on the Array of VO's.  First approach is to
create the array of VO's in PHP instead of passing back a PHP
resultset.  The other option is to put the returned PHP resultset
through a Factory AS object and create teh Array of VO's on the
Flex/AS side.

You can pass Array of Typed PHP objects from PHP to Flex through
AMFPHP which might be you best bet.  It's somewhat personal perference
and just how you want to make it consistent (ie: All Factory logic in
PHP or AS).

Renaun

--- In [email protected], "Stefan Schmalhaus" <[EMAIL PROTECTED]> 
wrote:
>
> I have two very basic questions regarding lists of VOs in Cairngorm.
> I'm using AMFPHP to retreive data from a MySQL database. A usual
> method looks like this (PHP):
> 
> ---------------------------------------------
> 
> function getUsers() {
>     $query = "SELECT uid,username,password,email FROM users";
>     $result = mysql_query($query);
>     while ($row = mysql_fetch_object($result)) {
>         $arrayOfUsers[] = $row;
>     }
>     return($arrayOfUsers);
> } 
> ---------------------------------------------
> 
> Everything works fine, the data is stored as an array in the
> ModelLocator (model.users), and I use DataBinding to populate a
> DataGrid. But I learned from Steven Webster's excellent 6-part article
> series that it is good practice to store information as VOs or as a
> list of VOs (in his example it's the list of the product's in a
> customer's shopping cart). 
> 
> Question 1: How do I "convert" my array into a list of VOs? Or is my
> array already a list of VOs?
> 
> Question 2: Let's say I want to use the same array (model.users) as a
> dataProvider for a ComboBox component somewhere else in the
> application. I can set up DataBinding for the ComboBox like I did with
> the DataGrid. But the ComboBox needs a "data" and a "label" field. I
> can set the label field to "username" with the "labelField" property,
> but how do I set the "data" field? I want the "uid" field from my SQL
> query to be the data field in the ComboBox. - Or am I supposed to use
> an SQL statement like this "SELECT uid,uid AS data,username, password,
> email FROM users"?
> 
> Thanks in advance.
> 
> Stefan Schmalhaus
>






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Great things are happening at Yahoo! Groups.  See the new email design.
http://us.click.yahoo.com/SktRrD/hOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to