Simple Join of two tables for

4 posts by 2 authors in: Forums > CMS Builder
Last Post: February 17, 2017   (RSS)

By Twocans - February 17, 2017

Hi sorry, 

I got it to work. 

// load records from 'test_table_1'
list($test_table_1Records, $test_table_1MetaData) = getRecords(array(
'tableName' => 'test_table_1',
'debugSql' => true,
'loadUploads' => true,
'allowSearch' => false,
'leftJoin' => array(
'test_table_2' => 'ON test_table_1.num = test_table_2.table2fk'

<table width="760" border="0" cellpadding="10">
<tbody> <?php foreach ($test_table_1Records as $record): ?>
<td><?php echo htmlencode($record['test_table_2.num']) ?></td>
<td> <?php echo htmlencode($record['test_table_2.title']) ?></td>
<td><?php echo htmlencode($record['title']) ?></td>
</tr> <?php endforeach ?>

<?php if (!$test_table_1Records): ?>
No records were found!<br/><br/>
<?php endif ?>

By ross - February 17, 2017

Hi Twocans

Glad you got that going.

I wanted to add a comment about a really handy function we built into CMS Builder.

It's called "showme()" and what it does is output the contents of an array so you can see what is available.

For example, if you put it inside your "foreach loop" like this:

<?php foreach ($test_table_1Records as $record): ?>
<?php showme($record);
<?php endforeach ?>

you would get a list of all the values available in $record.

It's really handy for figuring out what you have and what you can use.

Keep in mind that the output is not going to be pretty so it's definitely strictly a debugging tool.  

Let me know any questions.

Ross Fairbairn - Consulting

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting:

By Twocans - February 17, 2017

Thank you very much Ross,

I will avail of that, 

And also make use of this other stuff that I was not aware of.