SQL CONCAT on serverside
SQL CONCAT on serverside
Hi everybody,
Does anybody figured a way to update on server one column in the DB, using data provided from multiple user-side columns? Something like:
[code]
Field::inst( 'COLUMN1' ),
Field::inst( 'COLUMN2' ),
Field::inst( 'COLUMN3' )->setFormatter( \'CONCAT(COLUMN1, $constant, COLUMN2)\' ),
[/code]
Thank you.
Does anybody figured a way to update on server one column in the DB, using data provided from multiple user-side columns? Something like:
[code]
Field::inst( 'COLUMN1' ),
Field::inst( 'COLUMN2' ),
Field::inst( 'COLUMN3' )->setFormatter( \'CONCAT(COLUMN1, $constant, COLUMN2)\' ),
[/code]
Thank you.
This discussion has been closed.
Replies
I'm sorry to say that the Editor PHP libraries currently do not support SQL functions. The SQL would need to be executed directly (with the sql() method for example: https://editor.datatables.net/docs/current/php/class-DataTables.Database.html#_sql ) or the logic performed outside of the SQL engine.
This is certainly an area that is going to be looked at for improvements in future, but that the moment the logic just doesn't handle SQL functions and it tries to escape them...
Allan
But for now... is there a way to modify the submited field before submision, something like:
[code]
"events": {
"onPreSubmit": function ( o ) {
$('#DTE_Field_FIELD_1').attr( 'value', $('#DTE_Field_FIELD_1').val() + $('#DTE_Field_FIELD_2').val() )
}
[/code]
I tried the code above, but no luck so far... I guess the field should be called as a data array element, data[FIELD_1] ?
[code]
onPreSubmit: function ( o ) {
o.data.myField1 = o.data.myField1 + o.data.myField2;
}
[/code]
The format of `o` is the same as the data submitted to the server as described here: https://editor.datatables.net/server/ (in fact, it is exactly the data submitted to the server, so whatever you do to manipulate `o` will be reflected in what is sent to the server.
Regards,
Allan