Okay
  Public Ticket #3549209
SQL server side process and filter
Closed

Comments

  •  1
    Michael started the conversation

    Dear Team

    There is a problem with filtering which is not explained in your documentation.

    I have an SQL based table with the function "user can only see/edit ther own data". This function requires the server side processing (which will be automatically set, if I use the "user can only see/edit ther own data" function).

    Having this set the filter on columns which are based on SQL (like Year(wp_wpdatatable_1.date) doesn't work. It leads to zero entries.

    Best Regards Michael

  •  1,846
    Miloš replied

    Hello,

    Could you show me the SQL Query that was used for this table - and I can advise if maybe some small modification/correction is needed to get the search to work?

    -

    But you can also check these points to save time if you wish.

    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

    -

    So, first you can check for accent graves around the table name, if you have this, remove it...

    Then, see if you used CONCAT to create any column.

    If so, go into this column setting, and disable it from "global search" in the Filtering tab.

    -

    7138515403.png

    -

    If none of that helps,

    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, and i can take a look at the Query, as well.

    Thank yousmile.png

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

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

    Hi Milos

    Thanks for your anwser, which I didn't recognize due to holidays. Here is the SQL Query.

    As described, with server side process the column "Jahr" cannot be filtered.

    SELECT *, Year(wp_wpdatatable_1.datum) AS Jahr
    FROM wp_wpdatatable_1

  •  1,846
    Miloš replied

    Hi Michael,

    If you do the "star" inside your SELECT statement, then you won't be able to select a specific Column like :

    SELECT * (ALL) , then add a specific Column Name after the "all" part, that is not good practice in the SQL Syntax.

    It means you are already calling all Columns once - then you are 'doubling' calling one of the Columns again.

    Instead, only call the columns you need once, like :

    SELECT ColumnA,
    Column B,
    ColumnC,
    FROM wp_wpdatatable_1

    Try to avoid using the ALIAS ( AS) , but rather just call the Column Name as it is from the SQL Database.

    I am also a bit confused, the way you are calling this "Year" Column;

    Can you check, in the SQL Database, under the wp_wpdatatable_1,  what is the Origin Column name, is it "datum", or is it "Year"?

    Please log in your PHPMyAdmin/ or any other DB Management Tool, and double-check, what is the Origin Colum Name, then just call it like that in the Query.

    So, let's say if it is just "datum", along with a couple other Columns, then something like :

    SELECT Colum 1,
    Column2
    datum
    FROM wp_wpdatatable1

    Then, in the Column's Display Name, you can change it to anything you need.

    3662420401.png

    Here is my example. Let's say if I wanted to call this table dummy_employees from my Database and some specific columns.

    If i say : SELECT *  - that means SELECT ALL columns;  then if i add another specific Column name, after i already call all of them - then the Plugins SQL Parser will get 'confused' since you already called this column twice, in my example once as 'birthdate' then again as alias AS 'some other Column name'.

    In that case, the filtering won't work correctly.

    5969773293.png
    3291571142.png
    9148714560.png

    The solution is as proposed above - you can try adding ALIAS / AS to a Column, just don't call the same Column twice - call each of the existing Column once in your Query, such as, on my example :

    SELECT firstname,
    lastname,
    birthdate,
    date_hired AS hired,
    position
    FROM dummy_employees
    
    8460398513.png

    So, if you can even avoid having the ALIAS/AS, and just call each Column by their Origin Name, then you can edit the Displayed Header names as needed - but the filtering should work.

    -

    Other than that, you can also disable server-side processing if you need more 'flexibility' in the Query.

    Let me know if that helps.

    If you still can't solve the issue, we can remote in - we would just need access as Admin and to the Database.

    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 us to the Table ID.

    Thank you.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

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

    Hi Milos

    Thanks for your explanation. Now I know how it works and what is the difference between server side process and not.

    My users record there riding distances on a specific day. My aim was to extract the year out of the recording date to provide an easy filter option (year). The filter for the recording date works in the way (Form ... to... date).

    Because I like to edit/add records from the frontend I need the server side process where filtering works only for columns which are defined in the database.

    Sorry for using your time and thanks for your time too.

    Michael


  •  1,846
    Miloš replied

    Hi Michael,

    You're welcome, I am happy to advise.

    It is not a problem at all, you can always ask us any questions about any Plugin function/option, it is very easy to lose some 'detail' since there are a lot of options and workarounds to go through;

     so please don't hesitate to reach out with new tickets whenever any new question comes up.

    Thank you.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    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