Unable to Perform one to many join

Unable to Perform one to many join

Martyn.sMartyn.s Posts: 1Questions: 1Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
->join(
Mjoin::inst('workSites')
//->name('w')
->link('a.announcementID','announcementsToWorkSites.announcementID')
->link('workSites.workSiteID','announcementsToWorkSites.workSiteID')
->fields(
Field::inst('locationName')
)
)
Error messages shown:
DataTables warning: table id=announcementsListing - Join was performed on the field 'announcementID' which was not included in the Editor field list. The join field must be included as a regular field in the Editor instance.

Description of problem:
Trying to execute a one to many join for an announcement table using data tables, but it refuses to work. Any idea why?

Answers

  • rf1234rf1234 Posts: 3,037Questions: 88Answers: 423
    edited February 1

    Well, the error message says it clearly: You need to include the field "a.announcementID" in the field list of the Editor containing the MJoin. Please use Markdown as described below to highlight your code.

    Editor::inst( $db, 'a' ) 
    ->field(
        Field::inst( 'a.announcementID' )->set( false )
    )
    ->join(
    Mjoin::inst('workSites')
        //->name('w')
        ->link('a.announcementID','announcementsToWorkSites.announcementID')
        ->link('workSites.workSiteID','announcementsToWorkSites.workSiteID')
        ->fields(
            Field::inst('locationName')
        )
    )
    
Sign In or Register to comment.