Buy Now
Sign in

One-to-many read data

E
emmexx
I don't understand if it is possible to use the Read data action/fn to retrieve records from 2 tables with a one-to-many relation.
When I add a 2nd table and select Multiple matching records, foreign key in this table in the debugger I see 2 queries, one for the main table and one for the related one. And the 2nd query is not what I expect anyway because it filters records as
SELECT * FROM 2ndTable WHERE foreignKey IN (list of primary table ids).
What I would expect is a query that returns an array similar to:

[0] =>
[mainTable] =>
[field1] => value1,
[field2] => value2,
....
[2ndTable] =>
[fieldA] => valueA,
[fieldB] => valueB
[1] =>
and so on


I was able to achieve something like that only when I set the primary table to retrieve the First matching record.

Is there a way to retrieve a list of records from a main table (say receipts) and the related records (say products) from a 2nd table?

Thank you
maxx
admin
Hi maxx,

The end results should be of the same structure you have listed, and the way to get this is by having the query you have noticed too, so everything is correct, what are the results you get ?

Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
E
emmexx
"admin":
The end results should be of the same structure you have listed, and the way to get this is by having the query you have noticed too, so everything is correct, what are the results you get ?

Sorry, I forgot to update the thread.

I was using the Fields to retrieve property of the related table.
If I leave them empty everything works.

Merry Christmas!

maxx
admin
Hi maxx,

The fields list should be limited to the related model only and should contain the model name, is this correct ?

Happy new year!

Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
E
emmexx
"admin":
The fields list should be limited to the related model only and should contain the model name, is this correct ?


Sorry but I don't remember. When I posted, it wasn't working. Now it is working.
I tried many combinations, with or without model name but I cannot be more specific.
I was in the frenzy to get it to work and forgot to post my results.

Thank you
maxx