Uncaugth exception on insert with self-referencing join
Uncaugth exception on insert with self-referencing join
Maikel
Posts: 75Questions: 18Answers: 1
I get the following exception when i try to do an insert on a self-referencing table, i followed the example https://editor.datatables.net/examples/advanced/joinSelf.html
But it seems i'm missing something
<br />
<b>Fatal error</b>: Uncaught Error: Call to a member function insertId() on null in /home/deb28415/domains/puka.be/public_html/inc/editor/Editor/Editor.php:1596
Stack trace:
#0 /home/deb28415/domains/puka.be/public_html/inc/editor/Editor/Editor.php(1040): DataTables\Editor->_insert_or_update(NULL, Array)
#1 /home/deb28415/domains/puka.be/public_html/inc/editor/Editor/Editor.php(900): DataTables\Editor->_insert(Array)
#2 /home/deb28415/domains/puka.be/public_html/inc/editor/Editor/Editor.php(661): DataTables\Editor->_process(Array)
#3 /home/deb28415/domains/puka.be/public_html/inc/pages/admin/blacklist.php(69): DataTables\Editor->process(Array)
#4 /home/deb28415/domains/puka.be/public_html/inc/server.php(50): server(Array)
#5 /home/deb28415/domains/puka.be/public_html/index.php(7): require('/home/deb28415/...')
#6 {main}
thrown in <b>/home/deb28415/domains/puka.be/public_html/inc/editor/Editor/Editor.php</b> on line <b>1596</b><br />
my php:
DataTables\Editor::inst( $db, 'info' )
->fields(
DataTables\Editor\Field::inst( 'info.parent' )->validator( 'Validate::notEmpty' )
->options(
DataTables\Editor\Options::inst()
->table('info')
->value('id')
->label('title')
),
DataTables\Editor\Field::inst( 'info.title' )->validator( 'Validate::notEmpty' ),
DataTables\Editor\Field::inst( 'info.txt' )->validator( 'Validate::notEmpty' ),
DataTables\Editor\Field::inst( 'parent.title' )->validator( 'Validate::notEmpty' )
)
->leftJoin( 'info as parent', 'info.parent', '=', 'parent.id' )
->debug( true )
->process( $p )
->json();
my js
editor = new jQuery.fn.dataTable.Editor( {
ajax: "/admin/blacklist/server",
table: "#example",
fields: [ {
label: "Titel",
name: "info.title",
}, {
label: "Parent:",
name: "info.parent",
type: "select"
}, {
label: "Text:",
name: "info.txt",
type: "textarea"
}
]
} );
var columns = [
{ data: "info.title"},
{ data: "info.parent",
render: function ( data, type, row, meta ) {
console.log(row);
return row.parent.title;
}
}
];
createDataTable( "example", "/admin/info/server", columns, editor, 1, 0)
This discussion has been closed.
Replies
Hmm, when i remove the leftJoin i can't reproduce this ...
I must confess there isn't anything obviously wrong there. What version of Editor is it that you are using, and do the PHP libraries match that version?
I see you have the
debug( true )
method enabled. Does the server respond with the SQL that it is executing as well?Regards,
Allan
hmm, where can i see the version of editor?
it never dumps the debu, it just dups the php error ...
The debugger will tell you the client-side version. The server-side find can be found in the Editor.php file. A parameter near the top of the file called
version
.Allan