where clause in editor
where clause in editor
marianchoy
Posts: 3Questions: 2Answers: 0
I have the following php working ok:
Editor::inst( $this->editorDb, 'importApplication', 'importNo' )
->fields(
Field::inst( 'importApplication.appNo' ),
Field::inst( 'importApplication.seqNo' ),
Field::inst( 'importApplication.title' ),
// cut short
Field::inst( 'importApplication.lastModifiedBy' ),
Field::inst( 'supportDocReview.lastModified' )
->options( Options::inst()
->table( 'supportDocReview' )
->value( 'appNo' )
->label( 'lastModified' )
)
)
->leftJoin ( 'supportDocReview', 'importApplication.appNo', '=', 'supportDocReview.appNo')
->process( $_POST )
->json();
then wanna add a where clause to filter data from a column (code):
$codeList = ( 406, 407 ); // list of codes to display
Editor::inst( $this->editorDb, 'importApplication', 'importNo' )
->fields(
Field::inst( 'importApplication.appNo' ),
Field::inst( 'importApplication.seqNo' ),
Field::inst( 'importApplication.title' ),
// cut short
Field::inst( 'importApplication.lastModifiedBy' ),
Field::inst( 'supportDocReview.lastModified' )
->options( Options::inst()
->table( 'supportDocReview' )
->value( 'appNo' )
->label( 'lastModified' )
)
)
->leftJoin ( 'supportDocReview', 'importApplication.appNo', '=', 'supportDocReview.appNo')
->where( function ( $q ) {
$q->where( 'code', $codeList, 'IN', false ); // where clause to get all those codes
} )
->process( $_POST )
->json();
end up with this error,
DataTables warning: table id=appSummary - Invalid JSON response.
please help.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
If you look at the response from the server you will probably find an error about
$codeList
being undefined in the anonymous function. You need to use:That's a PHP syntax thing (bonkers imho, but I guess the only way they could make it work) - see full details here.
Allan
thanks much Allan~