Uncaugth exception on insert with self-referencing join

Uncaugth exception on insert with self-referencing join

MaikelMaikel 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-&gt;_insert_or_update(NULL, Array)
#1 /home/deb28415/domains/puka.be/public_html/inc/editor/Editor/Editor.php(900): DataTables\Editor-&gt;_insert(Array)
#2 /home/deb28415/domains/puka.be/public_html/inc/editor/Editor/Editor.php(661): DataTables\Editor-&gt;_process(Array)
#3 /home/deb28415/domains/puka.be/public_html/inc/pages/admin/blacklist.php(69): DataTables\Editor-&gt;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)

Replies

  • MaikelMaikel Posts: 75Questions: 18Answers: 1

    Hmm, when i remove the leftJoin i can't reproduce this ...

  • allanallan Posts: 61,822Questions: 1Answers: 10,129 Site admin

    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

  • MaikelMaikel Posts: 75Questions: 18Answers: 1

    hmm, where can i see the version of editor?

    it never dumps the debu, it just dups the php error ...

  • allanallan Posts: 61,822Questions: 1Answers: 10,129 Site admin

    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

This discussion has been closed.