Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81728

Left join where FK is in the other table

$
0
0

Trying to do a left join, which I have done in the past OK, but in this instance the fk is not in the parent table 'unit' but the other table 'unit_outcome'

Editor::inst( $db_cm_md, 'unit', 'unit_pk' )    
    ->field(
        Field::inst( 'unit.unit_code' ),
        Field::inst( 'unit.unit_name' ),
        Field::inst( 'unit.points' ),
        Field::inst( 'unit.modified' ),
        Field::inst( 'unit.modified_by' )->setValue( $user ),
        Field::inst( 'unit.year_fk' )
            ->options( Options::inst()
                ->table( 'year' )
                ->value( 'year_pk' )
                ->label( 'year_name' )
            ),
        Field::inst( 'year.year_name' ),
            Field::inst( 'unit_outcome.unit_fk' )
            ->options( Options::inst()
                ->table( 'unit_outcome' )
                ->value( 'unit_outcome_pk' )
                ->label( 'unit_outcome' )
            ),
        Field::inst( 'unit_outcome.unit_outcome' )
    )
    
    ->leftJoin( 'year', 'year.year_pk', '=', 'unit.year_fk' )
    ->leftJoin( 'unit_outcome', 'unit_outcome.unit_outcome_pk', '=', 'unit.unit_fk' )
    ->process($_POST)
    ->json();

Viewing all articles
Browse latest Browse all 81728

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>