leftJoin

2 posts by 2 authors in: Forums > CMS Builder
Last Post: November 27, 2014   (RSS)

By zaba - November 26, 2014

Hi, I am trying to do a preRecord nextRecord link thing.

I have 2 tables 1 called sector and the other case_studies. The common field is sector.num and case_studies.sec.

The next and previous record wants to go between sectors based on there being a record in case_studies belonging to that sector, other wise it does't go to that sector.

i.e. there may be sectors in the sectors table that have not got any case studies from the case studies table associated with them, hence I would rather the next previous links only jump to the ones that have records.

I pulled some info from another post but i found it confusing.

list($prevRecord, $nextRecord) = getPrevAndNextRecords(array( 
    'tableName'   => 'sector',
'recordNum' => "$current_sec", 
 'leftJoin' => array('sector.num'), //not sure i have this right
'case_studies' => 'sec', //not sure i have this right
'debugSql' => 'true', 
));


page code

<div class="pagination">
<?php if (@$prevRecord): ?>< <a href="/case-study-list.php?sec=<?php echo $prevRecord['num'] ?>">Previous</a><?php endif; ?>&nbsp;&nbsp;<?php if (@$nextRecord): ?><a href="/case-study-list.php?sec=<?php echo $nextRecord['num'] ?>" >Next</a> ><?php endif; ?>
</div><!-- /pagination -->