Join Tables over a hierarchy

4 posts by 2 authors in: Forums > CMS Builder
Last Post: August 3, 2011   (RSS)

By ryanGT - August 2, 2011 - edited: August 2, 2011

Hi all,

I was just wondering if it possible to join tables in a hierarchy situation.

I have 3 tables linked to each other through 2 different fields.
tableA (level 1)
)
- relatedField1 (dropdown Menu)
)
tableB (level 2)
)
- relatedField2 (dropdown Menu)
)
tableC (level 3)

I need all the results to be returned in one array, so that i can display all the relating data to tableA

Any help would be greatly appreciated.

Many thanks - Ryan

Re: [ryanGT] Join Tables over a hierarchy

By Jason - August 2, 2011

Hi Ryan,

Are you currently able to get all of the information you need as 3 different arrays (ie, 3 different database calls)?

If so, the easiest solution would be to use array_merge() to combine them all into 1 array like this:

<?php
$mergedArray = array_merge($tableARecords, $tableBRecords, $tableCRecords);
?>


Does this sound like what you're looking for?

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Join Tables over a hierarchy

By ryanGT - August 2, 2011

Hi Jason,

Yeah that sounds like it might do it.

Could you give me an example of how i would extract the title information from tableB (assuming the field name would be title)?

If you can tell me that i should be able to figure the rest out

Cheers - Ryan