Okay
  Public Ticket #3188761
Editing SQL table without table id shown
Closed

Comments

  •  1
    Klemen started the conversation

    Hi, I've setup a wpDataTables table with SQL query and using foreign key feature, which works great. But in order to edit or delete an entry in the table, the table id needs to be shown on the front end. If id is hidden, the edit feature attempts to run the SQL query but fails with an error message saying empty WHERE clause. Similar happens when deleting an entry. I'm not sure if there's a way to display entire SQL query somehow to be more helpful. For now I'm including the id column on the front end but would really like to hide it. Do you have any suggestions what to try? Thanks

  •  1,708
    Miloš replied

    Hi, Klemen 

     Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.

    -

    We can hide the column from the front-end,  in the table back-end settings, column settings.

    But if you have to have it showing in the Editing modal,  then we can hide it with CSS, as well.

    But i am not sure if i fully understood the details of your use-case.

    Could you please elaborate a bit more, show me some screenshots,  how is your column structure in this table in regards to the foreign key column, etc?

    I can certainly take a look at both front and back-end of the table and i can advise you what might be the best solution.

    -

    Please provide me a temporary WP-admin (administrator) user for your site where this happens, so we could log in and take a look ‘from the inside’ as that’s the most efficient way to see and resolve the issue. 

    We do not interfere with any data or anything else except for the plugin (in case that’s a production version of the site), and of course, we do not provide login data to third parties. 

    You can write credentials here just check PRIVATE Reply so nobody can see them except us.

    And point me to the table ID, please.

    Thank you

    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
    Klemen replied

    Hi Miloš,

    thanks for your reply, and sorry for late reply. I tried to reproduce the problem soon after your reply, and wasn't successful. I thought to give it a bit more try if it will come back with other SQL tables that I'm playing around with, but so far I seem to be unsuccessful at reproducing it - in other words it works as expected.

    Thanks!

  •  1,708
    Miloš replied

    Hi, Klemen 

    Firstly my apologies for replying just now.

    We had a New Year's break,  but i will do my best to be quick going forward as we are back now.

    -

    It seems you were at first not able to reproduce the issue anymore, but you wrote on Jason's ticket with more details https://tmsplugins.ticksy.com/ticket/3169035

    You said :

    ' I have a foreign key to another table and I set up the linkage for that field in wpDataTables. This works for one WP table, but not for the second one. In the second table whenever I select the Type (bcc_shareholders.type_id) other than empty, there are not results, as indicated in screenshots. 

    From what I can tell, the difference between the tables/queries is that in second table the LEFT JOIN can generate rows with type_id IS NULL, whereas the first always contains a valid type_id. 

    Filtering works for this SQL:

    SELECT bcc_shares.id,
           bcc_shares.identification,
           bcc_shares.comment,
           bcc_shares.type_id,
           bcc_shareholders.name
    FROM bcc_shares LEFT JOIN bcc_shareholders ON bcc_shares.id=bcc_shareholders.share_id

    but not for this one:

    SELECT bcc_shareholders.id,

           bcc_shareholders.name,
           bcc_shareholders.address,
           bcc_shareholders.share_id,
           bcc_shares.type_id,
           bcc_shareholders.status_id,
           bcc_shareholders.comment,
           CONCAT('<a href="/shareholder?shareholder_id=', bcc_shareholders.id, '">Details</a>') as details
    FROM bcc_shareholders LEFT JOIN bcc_shares ON bcc_shareholders.share_id=bcc_shares.id

    '

    And screenshots :

    3239575762.png

    2705746104.png

    4752726388.png

    Can you please send me WP-Admin access, so that we can check the back-end of the table in question?

    Please send me URL for WP-Admin and Administrator user credentials so that we can check the back-end setup.

    If you send us any credentials, please mark the reply as PRIVATE, so that only we can see it.

    And please point out to both Table ID's,   

    what is the first Table ID that is working without issues;

    and what is the Table ID with the issue as well.

    Then we can check everything for you.

    It will be good if you also grant us access to your database, so that we can check the columns and setup there.

    It can be either link with credentials to PhPMyAdmin or cPanel access.

    Thank you

    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
    Klemen replied

    Hi Miloš,

    Happy New Year!

    The original issue in this ticket was that whenever my 'ID' column was hidden from the front-end, the editing wouldn't work. I've created several more tables since then and I never saw the same issue again. So I consider that one closed.


    The comment to Jason's ticket is a different one. It has to do with wdt filtering of the table fields when using LEFT JOINs. I'm happy to continue the discussion in that ticket. Unfortunately I can't share the WP-admin details with you since my database contains PII data. From the troubleshooting perspective like in this case, I think it would be useful for the wpDataTables to have a switch to turn on debugging, log the actual SQL statements, or even provide more WP hooks.

    -- Klemen

  •  1,708
    Miloš replied

    Hi, Klemen 

    I apologise for all the waiting time.

    1.  I am glad that that initial issue has not came back, it seems it is solved, but let us know if it comes back at any point.


    2.  Regarding the comment for filtering, on the other ticket.

    I have been examining the details you sent on your comment on ticket https://tmsplugins.ticksy.com/ticket/3169035, but despite best efforts i still can't give you an advice what might be the root of that particular issue.

    -

    I have escalated it with our 2nd level Team, and they will do their best to advise based on your description and screenshots,

    as soon as they advise i will report back right away,

    but it would be best if you can also open a new, separate ticket - so that we can focus better on following all the issues separately,

    it will be more effective for our coordination, if that is OK with you.

    I will certainly monitor all tickets and will gather all the information in one place.

    Thank you

    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,708
    Miloš replied

    Hi, Klemen

    We have an update on the filtering issue.

    Our logic is based on a PHP SQL parser which has full support for the SQL dialect for the following statement types

    SELECT, INSERT, UPDATE, DELETE, REPLACE, RENAME, SHOW, SET, DROP, CREATE INDEX, CREATE TABLE, EXPLAIN and DESCRIBE.

    Some of them are disabled for security reasons.

    Filtering, sorting, and search may not work properly if you include:

    • Accent graves ( ` ) around the table name
    • JOIN functions
    • UNION functions
    • CONCAT functions
    • sub-queries


    In order to avoid this,

    you can try preparing a MySQL view (which will return the data that you need, call it e.g. “view1” and then build a wpDataTables based on a simple query like "SELECT * FROM view1″.

     If you need help with that, you can see our video, where we show an example of using View in our plugin.

    -

    Let me know If that helped. Thank you



    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
    Klemen replied

    Hi,

    I appreciate your reply and explanation of the behavior. The solution with views works for read-only tables, but not with editable tables. At least for MySQL that we're using, inserting and updating to the view is limited, as stated in the MySQL documentation:

    To be more specific, a view is not updatable if it contains any of the following: ....
    Certain joins (see additional join discussion later in this section)

    And after that:

    It is sometimes possible for a multiple-table view to be updatable, assuming that it can be processed with the MERGE algorithm. For this to work, the view must use an inner join (not an outer join or a UNION).


  •  1,708
    Miloš replied

    Hi, Klemen

    Thank you for this update, I think I can now understand better about your use-case.

    Yes, editing in our plugin has limitations if you use data from multiple tables, or JOIN in SQL.

    When you are using JOINS with more tables in wpdatatables,

     just one table can be editable at the moment and that is the reason why you can't edit fields in table that you made from two tables.

    I am sorry for the inconvenience.

    So, the View is good for resolving filtering/search issues in tables - but for editing, the limitations as we explained apply.

    Let me know if you have any questions, and please correct me if I am still misunderstanding the issue. Thank you

    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