Hello,
Im' new in DataTables and I need to do the following:
After Execute an Insert (clicking the button) , I need to execute a second MySQL query...
Were and how can I do That?
[code]
if ( isset( $_POST['action'] ) && $_POST['action'] === 'create' ) {
// ... do SQL insert
}
[/code]
Immediately after the process() (or json() call depending on how you want the code ordered). You can use the sql() method of the Database class to execute raw SQL: http://editor.datatables.net/docs/current/php/class-DataTables.Database.html#_sql
The data submitted is available in $_POST['data']['NIPC'] (or exchange `NIPC` for any other variable that is being defined in Editor if you want to use others). rom there you can use it in an SQL query or anywhere else that you want to.
Replies
What you would do is add:
[code]
if ( isset( $_POST['action'] ) && $_POST['action'] === 'create' ) {
// ... do SQL insert
}
[/code]
Immediately after the process() (or json() call depending on how you want the code ordered). You can use the sql() method of the Database class to execute raw SQL: http://editor.datatables.net/docs/current/php/class-DataTables.Database.html#_sql
Regards,
Allan
I've got another question...
I Have a form to get the following fiels...
Editor::inst( $db, 'TEmpresas' )
->fields(
Field::inst( 'Empresa' ),
Field::inst( 'Morada' ),
Field::inst( 'NIPC' ),
Field::inst( 'Telefone' ),
Field::inst( 'Email' )
)
->process( $_POST )
->json();
And I need to update a table with the value inserted by the user in, for example, the field 'NIPC'....
How can I do this?
Allan