DB data pull using 2 models ?

paulzero 12 Aug, 2016
Hi Bob,

CCV5 connection with 2 models.

Using main model ('t1') to get data from one db table based on a condition & display a list (done) - example result table :


id    value           published
------------------------------
1     abcdefg         1
2     123456          1
3     abc1234         1


User clicks a listing (eg : 2) & goes to 'action > view'.

In resulting 'action > view' I need to pull multiple matched records into an array based on :



Main model 't1'             Second model 't2'
---------------------------------------------------------------
                            #__table2
#__table1                   Field : id
Field : id <--------------> Field : record - both field type int(11)
Field : value               Field : value1
Field : published           Field : value2

Question is how ?

Second model 't2' setup :

[list]
Relation (to main model) : None specified (Tried hasOne, belongsTo & hasMany).
Foreign key : record
Conditions : none
Join conditions : none
Join type : none
Primary key ; none
[/list]

Tried putting a CCV5 select query into 'action > view > code' but either thats the wrong place or formatting is wrong.
Curently CCV5 query in 'action > view > code' is : < ? php return array('t2.record = t1.id'); ? >
Tried putting full jfactory db select query into 'action > view > code' - no joy.

Please assist - thanking you,

PaulZero
GreyHead 12 Aug, 2016
Hi PaulZero,

I'm not skilled enough in CCv5 to know if you can do this using a CC View action. You can certainly do it linking the action to a CF form event. I'd use a DB Read there to load the secondary data and a Custom element to display it in a table layout. If you need a more sophisticated layout then you can probably link to a second CC Listing (I've never tried that).

It is also possible to load the secondary data with the primary listing and display it inside each row - I guess that could use a popup of some kind. But I think that would only work if there were relatively few secondary records for each row.

Bob
paulzero 16 Aug, 2016
Hi Bob,

Re: this matter - have taken your advice & linked CCV5 to CFV5 form. Form displays BD data using the URL value of '&gcb'.

Your help much appreciated - it'll be a large coffee for sure !

Cheers Paul Zero.
webcrea 14 Sep, 2016
Paul could you explain how did you do please?
This topic is locked and no more replies can be posted.