Okay
  Public Ticket #3562047
What happens on backend during Copying/Duplicating a wpdatable?
Closed

Comments

  • Frank Bell started the conversation

    Can you tell me exactly what happens on the backend when I duplicate a wpdatatable from the front end?

    I wanted to know what is retained within the data structure so I can try to do some automation around this.

    Thanks!

  •  1,689
    Miloš replied

    Hi Frank,

    When it comes to duplicating Tables, this is not possible from Front-End.

    You can only use the "duplicate" functionality from the Back-End, on the "browse tables" list.

    5514277976.png

    A Side Note, when duplicating Tables : For manual tables, we strongly advise leaving this"Duplicate option" enabled:

    1081620257.png

    This way, the plugin will create a new table in the database, so changes in the new table will not affect the original table.

    2813286680.png

    When it comes to what happens exactly on the Back-End when a duplication of a table happens, as you asked, such as what is retained within the data structure,  for a possible automation attempt from your end;

    I am honestly not sure exactly how many details we will be able to provide, but we will ask our Developers.

    Just please note that our Support does not cover custom solutions/ custom work, so we are very limited when it comes to topics like that, but we will do our best.


    As soon as they advice on this subject, we will report back right away.

    Thank you for your patience.



    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  1,689
    Miloš replied

    Hi Frank,

    Our Developers did their best to try to provide some details to describe the basics of what happens during the 'duplication' process/ when we duplicate a table.

    -

    The logic is, our Plugin takes the table ID which is being copied ( it gets it from front-end depending on which table is selected);

    In the same way, from front-end, it gets a new Name for the Table;

    It also checks , if the Table needs to be 'synchronized in the duplication'/duplicated in the SQL Database, which is visually presented in the interface as the additional "duplicate option" choice :

    1081620257.png

    9985366194.png

    Then with this ID it pulls the Table in the Database;

    After that, the part which checks if the same Table Name already exists in the DB.

    If there is already another Tabl with the same Name, it adds _1 at the end, in order to make a new Table in the Database with a new Table ID, then it pulls all the data from the DB for that ID, takes all the columns, and inserts all that in wp_wpdatatables_columns in the DB with a new Table ID.

    -

    Or, if it is for a Simple Table, then the data just gets inserted in wp_wpdatatables_rows.

    ( The wp_ is the default WP Table Prefix/ while on your Site it can have a different DB Table Prefix)

    -

    The logic which happens in form of the code, is in this PHP file :

    ..\wp-content\plugins\wpdatatables\controllers\wdt_admin_ajax_actions.php

    around line 257, find this :

    function wdtDuplicateTable()
    
    9564088740.png

    When it comes to the front-end, it pulls the data from it/ in other words, the ID of the Table which gets duplicated,  the new Table name and if the option to copy the Database Table is checked or not.

    -

    Anything more advanced than this would be going into too many details and reaching custom work level, but I hope that could help as a starting point; that is the best information we could gather about this process.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables