How access row's data just after a create action
How access row's data just after a create action
Hi Allan.
I,ve looked for in forum but I don´t find answer. Excuse me if you have answered this question yet.
I want to perform a second insert in my sql database just after a create action in my editor.
I use a create.php just like in your examples with this code :
include( "customer.php" );
$editor
->process($_POST)
->json();
I want use the data of the row I´ve inserted here to perform a second insert in another table of the database.
How can I refer to them in this create.php ?
Thanks.
I,ve looked for in forum but I don´t find answer. Excuse me if you have answered this question yet.
I want to perform a second insert in my sql database just after a create action in my editor.
I use a create.php just like in your examples with this code :
include( "customer.php" );
$editor
->process($_POST)
->json();
I want use the data of the row I´ve inserted here to perform a second insert in another table of the database.
How can I refer to them in this create.php ?
Thanks.
This discussion has been closed.
Replies
*edit* Sorry - I got myself confused with two very similar, but not the same, questions - this answer has been updated for this specific question...!
To get the data, use the `data()` method rather than `json()` (you can then simply use `json_encode()` from PHP to echo out the JSON data, but `data()` will let you actually access the data of the row.
So you would have something like:
[code]
$data = $editor
->process($_POST)
->data();
if ( isset( $_POST['action'] ) && $_POST['action'] === 'create' ) {
// .. row information is in $data['row']
}
[/code]
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 used only the code you propose to me, I didn´t add any line of code.
I checked that in $data I got the row´s data I have created with an echo and after I deleted this echo.
But in editor´s window I received:
"An error has occurred - Please contact the system administrator"
Do you know why ?
Note.- The row was created correctly.
Thanks
I solve it with this :
$object = $editor->process($_POST) ;
// Get data
$data = $object->data();
// Here I work with $data
.......
// Return result to the rutine create.php
$object->json();
With this code I don´t get the error and the row is created correctly.
What is your opinion ?
Allan
$editor
->process($args)
->json();
I want use the data of the row I´ve deleted here to perform a second delete in another table of the database.
How can I refer to them in this remove.php ?