ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

One-to-many read data

emmexx 13 Dec, 2017
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
Max_admin 25 Dec, 2017
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
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
emmexx 25 Dec, 2017
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
Max_admin 27 Dec, 2017
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
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
emmexx 27 Dec, 2017
1 Likes
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
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com