Okay
  Public Ticket #1364446
SQL query
Closed

Comments

  • strutture_energia started the conversation

    Hi, when I run this query on server side I still have more then 1 row. When I run it locally it works fine. How can I place the LIMIT function properly? On my admin side the LIMIT funtion works. Thanks

    SELECT *
    FROM wp_frm_items
    WHERE wp_frm_items.user_id <> 0
    ORDER BY wp_frm_items.updated_at DESC
    LIMIT 1;

  •  471
    Isidora replied

    Hi strutture_energia,
    Thank you for your purchase.

    If your MySQL-query based wpDataTable doesn’t work correctly with server-side processing, probably this is happening because wpDataTables server has problems with parsing of the query and building new queries dynamically (happens rarely, but does sometimes). To avoid this please prepare a MySQL view (a stored query), which will return the data that you need, call it e.g. “view1” and then build a wpDataTabled based on a simple query like “SELECT * FROM view1″.

    Please note some this when working with the server-side processing feature:

    • Please do not use “LIMIT” in the SELECT statement. wpDataTables adds it automatically and it will be overridden.
    • Please do not use “ORDER BY” in the SELECT statement. wpDataTables has its own sorting engine so it makes no sense to use MySQL’s sorting, since it will be overridden. Also server-side processing feature adds this part of statement automatically when users triggers the sorting on the front-end, and having it in initial statement may cause the table to crash.

    Kind Regards, 

    Isidora Markovic

    wpDataTables: FAQFacebookTwitterFront-end and back-end demoDocs

    Amelia: FAQFacebookTwitter |  Amelia demo sites | Docs

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

    Powerful FiltersGravity Forms Integration for wpDataTablesFormidable Forms Integration for wpDataTables

  • strutture_energia replied

    Hi, thanks for the reply.

    You said:

    "Please do not use “LIMIT” in the SELECT statement. wpDataTables adds it automatically and it will be overridden."

    Does it mean that I can specify it from the table wizard? If yes, can you please guide me cause I do not see this option.

    In case is it possible to limit form wizard, the Client still doesn't download the whole table and then limit the display, correct?

    Thanks for the attention


  •  471
    Isidora replied

    Hi strutture_energia,

    Sorry for late response. 

    We are located in Serbia and our working time is from 10:00 to 17:00 CET. business days.

    Yes you can specify over the Display length. 

    wpDataTables with server-side processing enabled fetch only the amount of rows needed on the page at this exact moment. By default it equals to the number of rows that administrator defines for the table in the “Display length” setting, then the front-user can change it. E.g. if the table is configured to show 10 rows by default, only 10 rows would be queried from MySQL; and when the user switches to the next page, sorts the table by some column, filters by some column, an AJAX-request is sent to the server, query is processed by MySQL, and 10 rows are returned again. 

    Kind Regards, 

    Isidora Markovic

    wpDataTables: FAQFacebookTwitterFront-end and back-end demoDocs

    Amelia: FAQFacebookTwitter |  Amelia demo sites | Docs

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

    Powerful FiltersGravity Forms Integration for wpDataTablesFormidable Forms Integration for wpDataTables