where clause in editor
where clause in editor
![marianchoy](https://secure.gravatar.com/avatar/cfbbca5997b6084b232fca6db3a26375/?default=https%3A%2F%2Fvanillicon.com%2Fcfbbca5997b6084b232fca6db3a26375_200.png&rating=g&size=120)
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~