On Oct 10, 2012, at 5:26 AM, Peter Gutbrod wrote:

> $map := """        
> food{"meat"}:            [db]meat;
> food{"vegetable"}:        [db]vegetable;
> food{"drink"}:            [db]drink;
> ...
> location{"name"}:        [db]name;
> location{"street"}:    [db]street;
> location{"city"}:        [db]city;
> ...
> $rs := RowSet.newFromSelection(->[db]; $map)
> 
> What I wanted to achive was, to generate 2 collections food and location
> inside the rowset to be able to loop through them.
> 
> But it seems I only get individual collection items in the rowset that are
> even hard to access as $row{ food{"meat"}} is not valid expression.

It is not really clear on what you are trying to do. Your pseudo code is not 
clear if your are talking about tables Food and Location and what the relation 
is between them.

Remember $map is just a key value pair. The key  food{"meat"} would probably 
confuse the heck out of Active4D since it is meant to be a string

meat: [db]meat  -- is all that is needed.

If Location is a "has one" or belongs to in 4D terms, it should automatically 
create the relation.

You can imbed a rowset inside a rowset, Let's say [customer] has many 
[invoices]. You'd create a method that would get the related invoices and 
create a rowset inside the customer rowset.

$map := """
name: [customer]name;
city: [customer]city;
...
invoices: `getInvoices'
"""
Where getInvoices is a local method that gets related invoices and creates an 
"invoices" rowset inside the customers rowset. You have to iterate through the 
customer rowsets and then the invoices rowset for each customer.

Rather they using the standard $row variable do something like:

$customer := $qryCustomer->getRow
iterate
        $customer{"name"} -- to access name attribute
                $invoices := $customer{"invoices"}->getRow
                        iterate


It works, but might not be the best approach.  If I'd do it again, I'd create a 
customer library (model) with a getInovices method and just call it in the 
customer loop.


Again, not clear on what you are trying to do.

Steve








_______________________________________________
Active4D-dev mailing list
[email protected]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/

Reply via email to