LeftJoin with multiple conditions and Where Clause

LeftJoin with multiple conditions and Where Clause

amweiss98amweiss98 Posts: 12Questions: 4Answers: 1
edited February 2017 in Free community support

Using the information I've been able to find, here is the code I'm using with DataTables Editor..but when I run this I get an SQL error near the Where clause. I don't know how to see the SQL, so I can't debug it. Any idea what I'm doing wrong? Thanks

$editor = Editor::inst( $db, 'tbl_schedule','schID' )
->fields(
        Field::inst( 'tbl_schedule.userid_fk' ),
        Field::inst( 'tbl_schedule.courseID_fk' ),
        Field::inst( 'tbl_schedule.schDate' ),
        Field::inst( 'tbl_schedule.schOrder' ),
        Field::inst( 'tbl_record_session.timeStamp' )
    )
    
    ->leftJoin( 'tbl_record_session',
        'tbl_schedule.userid_fk', '=',
                'tbl_record_session.userid_fk AND       
                tbl_schedule.courseID_fk = tbl_record_session.courseid_fk AND
                tbl_record_session.sessionNumber=tbl_schedule.schOrder'
               )
    
    
    ->where( 'tbl_schedule.userid_fk', 296 )
    ->where( 'tbl_schedule.courseID_fk', 2)
    ->process( $_POST )
    ->json();

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,850Questions: 1Answers: 10,519 Site admin
    Answer ✓

    Hi,

    The current API doesn't really support complex conditions. However, it is possible to do as described in this thread.

    Allan

  • amweiss98amweiss98 Posts: 12Questions: 4Answers: 1

    Thanks...it turns out once I got rid of the line breaks in the leftJoin, the code works fine.

This discussion has been closed.