So I'd like to use wpdatatables using PHP Serialized Array. Before using my own query, I decided to just copy and paste the sample code in the documentation and tweaked it a little bit to see if it's really working. I followed the instructions in the video and it showed the result. But when I added the URL and hit save, it says 'No data.' What could be the problem?
Hi Eli Marie Natividad, Thank you for your purchase.
You have "space" in the beginning of the file so please delete it and try again. Also in ../wpdatatables/source/class.wdttools.php around line 82 find this line of code:
So while waiting for your response, I tried using the MySQL query. (Please see the attached file for the query.) However, it returns "No data." What could be the problem?
About the query: Can you please tell me did you try to make a VIEW in phpmyadmin or any other database management system and see if it is returning the right result.
SELECT ID, post_date, GROUP_CONCAT(order_items separator '\n') AS order_items, post_status, shipping_flight_number, letter_code, terminal, order_total, full_name FROM ( SELECT p.ID, date(p.post_date) AS post_date, p.post_status AS post_status, concat(max( CASE WHEN o.meta_key = '_qty' and i.order_item_id = o.order_item_id THEN o.meta_value END ), ' ', i.order_item_name) as order_items, max( CASE WHEN pm.meta_key = 'shipping_flight_number' and p.ID = pm.post_id THEN pm.meta_value END ) as shipping_flight_number, substring_index(max( CASE WHEN pm.meta_key = 'shipping_flight_number' and p.ID = pm.post_id THEN pm.meta_value END )," ",1) as letter_code, ( SELECT terminal_id FROM wp_shipping_airlines WHERE letter_code = substring_index(max( CASE WHEN pm.meta_key = 'shipping_flight_number' and p.ID = pm.post_id THEN pm.meta_value END )," ",1)) as terminal, max( CASE WHEN pm.meta_key = '_order_total' and p.ID = pm.post_id THEN pm.meta_value END ) as order_total, concat(max( CASE WHEN pm.meta_key = '_billing_first_name' and p.ID = pm.post_id THEN pm.meta_value END ), ' ', max( CASE WHEN pm.meta_key = '_billing_last_name' and p.ID = pm.post_id THEN pm.meta_value END )) as full_name FROM wp_posts AS p LEFT JOIN wp_postmeta pm on p.ID = pm.post_id LEFT JOIN wp_woocommerce_order_items AS i ON p.ID = i.order_id LEFT JOIN wp_woocommerce_order_itemmeta AS o ON i.order_item_id = o.order_item_id WHERE p.post_type = 'shop_order' AND i.order_item_type = 'line_item' AND p.post_status != 'trash' GROUP BY i.order_item_name, p.ID) AS t GROUP BY ID, post_date, shipping_flight_number, letter_code, terminal, order_total, full_name
It's working well except when I add the third select:
( SELECT terminal_id FROM wp_shipping_airlines WHERE letter_code = substring_index(max( CASE WHEN pm.meta_key = 'shipping_flight_number' and p.ID = pm.post_id THEN pm.meta_value END )," ",1)) as terminal
The query does not return any data when you enter another select. Am I right? If that is the case the issue is in the query. Did you try to use our wpDataTables constructor? Here is the documentationabout wpDataTables constructor so please take a look. Also please note this from our documentation
"Please note that MySQL query constructor is not an ‘ultimate generator’, it should be consider a helper that constructs a suggestion of a query trying to ‘guess’ what you want. We constantly work on improving it, but SQL is such a complicated and flexible language that full automation for constructing queries is hardly possible. So the more complicated your request is, the higher is the chance that it will not return exactly what you need. Play around with the resulting query to achieve better results."
So our suggestion is when you have queries like this, make a VIEW and then if the VIEW is returning the desired data use that query as Add from data source option to create tables.
I tried using the wpDataTables constructor, but it's limited and my query is a bit complex.
My query is working when I run it in PHPMyAdmin but it's not when I convert it to View Table. If it will help you better analyze my problem, I can give you access to my database.
I also attached a screenshot so you can see that there's data showing in my query.
When you add third SELECT and if it is not working in phpmyadmin then the issue is in the query. Unfortunately writing query is not included in support. Included support covers help with bugs and general inquiries for the plugin features, but not writing queries.
Did you try to add the query that is working and create the table with Add from data source option.
Hi,
So I'd like to use wpdatatables using PHP Serialized Array. Before using my own query, I decided to just copy and paste the sample code in the documentation and tweaked it a little bit to see if it's really working. I followed the instructions in the video and it showed the result. But when I added the URL and hit save, it says 'No data.' What could be the problem?
Your prompt response is highly appreciated.
Sincerely,
Eli
Hi Eli Marie Natividad,
Thank you for your purchase.
You have "space" in the beginning of the file so please delete it and try again.
Also in ../wpdatatables/source/class.wdttools.php around line 82 find this line of code:
and change it to look like this : (Add just this $data = trim( $data ); )
Let me know the result.
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 | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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
Hi Bogdan,
Adding
did the trick.
So while waiting for your response, I tried using the MySQL query. (Please see the attached file for the query.) However, it returns "No data." What could be the problem?
Thanks,
Eli
Hi Eli,
I am glad that now everything is working fine.
About the query:
Can you please tell me did you try to make a VIEW in phpmyadmin or any other database management system and see if it is returning the right result.
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 | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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
Hi Bogdan,
Yes, I did try.
SELECT ID, post_date, GROUP_CONCAT(order_items separator '\n') AS order_items, post_status, shipping_flight_number, letter_code, terminal, order_total, full_name
FROM (
SELECT
p.ID,
date(p.post_date) AS post_date,
p.post_status AS post_status,
concat(max( CASE
WHEN o.meta_key = '_qty' and
i.order_item_id = o.order_item_id
THEN o.meta_value
END ), ' ', i.order_item_name) as order_items,
max( CASE WHEN pm.meta_key = 'shipping_flight_number' and p.ID = pm.post_id THEN pm.meta_value END ) as shipping_flight_number,
substring_index(max( CASE WHEN pm.meta_key = 'shipping_flight_number' and p.ID = pm.post_id THEN pm.meta_value END )," ",1) as letter_code,
( SELECT terminal_id FROM wp_shipping_airlines WHERE letter_code = substring_index(max( CASE WHEN pm.meta_key = 'shipping_flight_number' and p.ID = pm.post_id THEN pm.meta_value END )," ",1)) as terminal,
max( CASE WHEN pm.meta_key = '_order_total' and p.ID = pm.post_id THEN pm.meta_value END ) as order_total,
concat(max( CASE WHEN pm.meta_key = '_billing_first_name' and p.ID = pm.post_id THEN pm.meta_value END ), ' ', max( CASE WHEN pm.meta_key = '_billing_last_name' and p.ID = pm.post_id THEN pm.meta_value END )) as full_name
FROM wp_posts AS p
LEFT JOIN wp_postmeta pm on p.ID = pm.post_id
LEFT JOIN wp_woocommerce_order_items AS i ON p.ID = i.order_id
LEFT JOIN wp_woocommerce_order_itemmeta AS o ON i.order_item_id = o.order_item_id
WHERE p.post_type = 'shop_order' AND i.order_item_type = 'line_item' AND p.post_status != 'trash'
GROUP BY i.order_item_name, p.ID) AS t
GROUP BY ID, post_date, shipping_flight_number, letter_code, terminal, order_total, full_name
It's working well except when I add the third select:
( SELECT terminal_id FROM wp_shipping_airlines WHERE letter_code = substring_index(max( CASE WHEN pm.meta_key = 'shipping_flight_number' and p.ID = pm.post_id THEN pm.meta_value END )," ",1)) as terminal
I'm not sure what's causing the issue.
Thanks,
Eli
Hi Eli
The query does not return any data when you enter another select. Am I right?
If that is the case the issue is in the query.
Did you try to use our wpDataTables constructor?
Here is the documentationabout wpDataTables constructor so please take a look.
Also please note this from our documentation
"Please note that MySQL query constructor is not an ‘ultimate generator’, it should be consider a helper that constructs a suggestion of a query trying to ‘guess’ what you want. We constantly work on improving it, but SQL is such a complicated and flexible language that full automation for constructing queries is hardly possible. So the more complicated your request is, the higher is the chance that it will not return exactly what you need. Play around with the resulting query to achieve better results."
So our suggestion is when you have queries like this, make a VIEW and then if the VIEW is returning the desired data use that query as Add from data source option to create tables.
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 | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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
Hi Bogdan,
I tried using the wpDataTables constructor, but it's limited and my query is a bit complex.
My query is working when I run it in PHPMyAdmin but it's not when I convert it to View Table. If it will help you better analyze my problem, I can give you access to my database.
I also attached a screenshot so you can see that there's data showing in my query.
Let me know,
-Eli
Hi Eli
When you add third SELECT and if it is not working in phpmyadmin then the issue is in the query.
Unfortunately writing query is not included in support.
Included support covers help with bugs and general inquiries for the plugin features, but not writing queries.
Did you try to add the query that is working and create the table with Add from data source option.
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 | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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