Using the Join Method without updating the Data in the Joined table
Using the Join Method without updating the Data in the Joined table
Hello,
I was hoping someone could assist me with an issue I am having with Editor DataTables. I am trying to utilize the LeftJoin() method when querying on two tables and I want my code to display information from both tables but only update the main table when updating a record and not the joined table.
Below is my PHP code
/*
* Example PHP implementation used for the index.html example
*/
// DataTables PHP library
include( "edit-php/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'TABLE1',
array(
'TABLE1.ID_NBR',
'TABLE1.ACTION_DATE',
'TABLE1.ACTION_NAME',
'TABLE1.COMMENTS',
'TABLE1.BADGE',
'TABLE1.ACTION_ID',
'TABLE1.ACTION_INSTANCE',
'TABLE1.TIME_FLAG')
)
->fields(
Field::inst( 'TABLE1.ID_NBR' )
->validator( 'Validate::notEmpty' )
->validator( 'Validate::maxLen', 10 )
->getFormatter( 'Format::CapitaliseStringValues' )
->setFormatter( 'Format::CapitaliseStringValues' ),
Field::inst( 'TABLE1.ACTION_DATE' )
->validator( 'Validate::notEmpty' )
->validator( 'Validate::dateFormat', array(
"format" => Format::DATE_ISO_8601,
"message" => "Please enter a date in the format yyyy-mm-dd"
) )
->getFormatter( 'Format::date_sql_to_format', Format::DATE_ISO_8601 )
->setFormatter( 'Format::date_format_to_sql', Format::DATE_ISO_8601 ),
Field::inst( 'TABLE1.ACTION_NAME' )
->validator( 'Validate::notEmpty' )
->validator( 'Validate::maxLen', 30 )
->getFormatter( 'Format::CapitaliseStringValues' )
->setFormatter( 'Format::CapitaliseStringValues' ),
Field::inst( 'TABLE1.COMMENTS' )
->validator( 'Validate::notEmpty' )
->validator( 'Validate::maxLen', 200 ),
Field::inst( 'TABLE1.BADGE' )
->validator( 'Validate::notEmpty' )
->validator( 'Validate::maxLen', 6 )
->validator( 'Validate::minLen', 6 )
->validator( 'Validate::numeric' ),
Field::inst( 'TABLE1.ACTION_ID' )
->validator( 'Validate::notEmpty' )
->validator( 'Validate::maxLen', 30 )
->getFormatter( 'Format::CapitaliseStringValues' )
->setFormatter( 'Format::CapitaliseStringValues' ),
Field::inst( 'TABLE1.ACTION_INSTANCE' )
->validator( 'Validate::notEmpty' )
->validator( 'Validate::maxLen', 2 )
->validator( 'Validate::minLen', 1 )
->validator( 'Validate::numeric' ),
Field::inst( 'TABLE1.TIME_FLAG' )
->validator( 'Validate::notEmpty' )
->validator( 'Validate::dateFormat', array(
"format" => Format::DATE_ISO_8601,
"message" => "Please enter a date in the format yyyy-mm-dd"
) )
->getFormatter( 'Format::date_sql_to_format', Format::DATE_ISO_8601 )
->setFormatter( 'Format::date_format_to_sql', Format::DATE_ISO_8601 ),
Field::inst( 'TABLE2.CLASS' )
)
->leftJoin( 'TABLE2', 'TABLE2.ID_NBR', '=', 'TABLE1.ID_NBR' )
->process( $_POST )
->json();
Basically, I want to display the 'TABLE2.CLASS' field but I don't want it to update 'TABLE2.CLASS' when I edit a record.
Is there any way to do this?
This discussion has been closed.
Replies
https://editor.datatables.net/manual/php/getting-started#SQL-functions
->set( false )
Also don't have a
TABLE2.CLASS
field defined in your client-side initilisation of Editor.Allan
@rf1234 - Awesome! Thank you for pointing me in the right direction. I completely overlooked this piece. >_<
@allan - Ah okay, thank you for the information and recommendation. I'll make sure to change this going forward.
Hello again, it seems like I am still having issues.
- I have updated "TABLE2.CLASS" to "table2.atis_class" in my oracle datatable
- I have placed ->set( false) in my php code under "table.atis_class"
My table is still not properly updating rows when I attempt edit, insert, delete, etc from the table. It doesn't throw any form of error either, it just doesn't perform the action.
Below is all of my code.
HTML:
JAVASCRIPT:
PHP CODE: