DataTables Editor IF statement
DataTables Editor IF statement
LeeMc
Posts: 1Questions: 1Answers: 0
Is it possible to do a MySQL IF statement in the editor?
For example:
Editor::inst( $db, 'todo' )
->fields(
Field::inst( 'Column1' ),
Field::inst( 'Column2' ),
Field::inst( 'IF(Column3 = 0, Column4, Column3)' )
)
->process( $_POST )
->json();
I've tried it but get a SQL error message so wonder if there is another way.
I'd also like to be able to sort / search by it.
This discussion has been closed.
Answers
You could create a VIEW and read from that which would work just fine.
Other option is to read both column3 and column4 and then use a renderer (
columns.render
) on the client-side to conditionally render which one you want.Allan