How can I have multiple tables without making a new editor.php file?(EditorDatatable) variable $pkey

How can I have multiple tables without making a new editor.php file?(EditorDatatable) variable $pkey

jlujanjlujan Posts: 9Questions: 3Answers: 0

I am trying to use the editor.php for several tables but it only allows me to put the id of a table in the Editor.php file. Is it possible to use the library for several tables?

I am trying to use the editor.php for several tables but it only allows me to put the id of a table in the Editor.php file. Is it possible to use the library for several tables?
NOTE: I read the following post https://datatables.net/forums/discussion/50871/how-can-i-have-multiple-tables-without-making-a-new-editor-php-file
but I don't understand where the change should be made.

Replies

  • allanallan Posts: 61,452Questions: 1Answers: 10,055 Site admin

    I am trying to use the editor.php for several tables but it only allows me to put the id of a table in the Editor.php file

    You can set the primary key column name using the optional third parameter for the Editor factory method.

    Allan

  • jlujanjlujan Posts: 9Questions: 3Answers: 0

    hi allan I want one shared file for all tables.

    where do I have to put the variable to work with multiple independent tables?

    I was trying this but it doesn't work

    private $_pkey = array('Id_Rol','Id_slider');

    File: editor.php

  • allanallan Posts: 61,452Questions: 1Answers: 10,055 Site admin

    Don't change the Editor.php file we distribute. Instead change how you initialise the Editor instance in the PHP - for example you might use:

    $editor = Editor::inst( $db, 'staff', 'staffid' );
    

    Or if you want the table name and primary key to be variables based on some other logic:

    $editor = Editor::inst( $db, $table, $pkey );
    

    Allan

Sign In or Register to comment.