Hi all,
i have a problem with one of my tables. It has joined data on an oracle-db, when trying to edit a row or insert a new one.
Here are my codes:
PHP
<?php
/*
* Editor server script for DB table STG_TAB_ARTIKEL
* Created by http://editor.datatables.net/generator
*/
// DataTables PHP library and database connection
include( "lib/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, 'STG_TAB_ARTIKEL a', 'a.PK_ARTIKEL_ID' )
->debug(true)
->fields(
Field::inst( 'a.ARTNR' )
->validator( 'Validate::unique' )
->validator( 'Validate::required' )
->validator( 'Validate::numeric' ),
Field::inst( 'a.FK_STG_TAB_ARTKAT' )
->options( Options::inst()
->table( 'STG_TAB_ARTIKELKATEGORIE' )
->value( 'ARTKATNR' )
->label( 'ARTKAT' )
)
->validator( 'Validate::dbValues' ),
Field::inst( 'a.ARTBEZ' )
->validator( 'Validate::notEmpty' ),
Field::inst( 'a.ARTMAß' ),
Field::inst( 'ak.ARTKAT' )
)
->leftJoin( 'STG_TAB_ARTIKELKATEGORIE ak', 'ak.ARTKATNR', '=', 'a.FK_STG_TAB_ARTKAT')
->process( $_POST )
->json();
?>
JS
/*
* Editor client script for DB table STG_TAB_KUNDEN
* Created by http://editor.datatables.net/generator
*/
(function($){
$(document).ready(function() {
var editor = new $.fn.dataTable.Editor( {
ajax: 'sources/table.STG_TAB_ARTIKEL.php',
table: '#STG_TAB_ARTIKEL',
fields: [
{
"label": "Artikel:",
"name": "a.ARTNR"
},
{
"label": "Artikelkategorie:",
"name": "a.FK_STG_TAB_ARTKAT",
"type": "select",
"placeholder" : "Bitte Kategorie auswählen.."
},
{
"label": "Bezeichnung:",
"name": "a.ARTBEZ"
},
{
"label": "Maße:",
"name": "a.ARTMAß"
}
]
} );
var table = $('#STG_TAB_ARTIKEL').DataTable( {
dom: 'Bfrtip',
ajax: 'sources/table.STG_TAB_ARTIKEL.php',
serverSide: true,
scrollY: '70vh',
scrollCollapse: true,
paging: false,
cache: true,
columns: [
{
"data": "a.ARTNR"
},
{
"data": "ak.ARTKAT"
},
{
"data": "a.ARTBEZ"
},
{
"data": "a.ARTMAß"
}
],
select: "single",
lengthChange: false,
buttons: [
{ extend: 'create', editor: editor }
,{ extend: 'edit', editor: editor }
]
} );
} );
}(jQuery));
On debbuging the data-Header seems correct:
data[row_5760][a][ARTNR]:-2
data[row_5760][a][FK_STG_TAB_ARTKAT]:23
data[row_5760][a][ARTBEZ]:HTV - Einweg
data[row_5760][a][ARTMAß]:0x0
But on the debugSql-array on Preview Page doesn't start an update:
(see attachment) [2]query: SELECT a.PK_ARTIKEL_ID as "a.PK_ARTIKEL_ID", a.ARTNR as "a.ARTNR", a.FK_STG_TAB_ARTKAT as "a.FK_STG_TAB_ARTKAT", a.ARTBEZ as "a.ARTBEZ", a.ARTMAß as "a.ARTMAß", ak.ARTKAT as "ak.ARTKAT" FROM STG_TAB_ARTIKEL a LEFT JOIN STG_TAB_ARTIKELKATEGORIE ak ON ak.ARTKATNR = a.FK_STG_TAB_ARTKAT WHERE a.PK_ARTIKEL_ID = :where_0
Don't know why it isn't working, i have another table w/o the leftJoin() param which is working perfectly.
Looking forward to any help!
Thanks in advance
Br Toni