I need to be able to pass an input parameter to my query. The plugin doesn't support calling stored procs, and I can't pass an input parameter to a view, so what are my options? I don't want my query to live in the plugin, I want it in my DB. Thanks
Yes, you won't be able to create a new SQL VIEW in your Database through our Plugin, and our SQL Queries are not able to make a new Table in the DB as you know.
All the data from each SQL Query table is stored as JSON Data as part of 'wp_wpdatatables' and 'wp_wpdatatables_rows'.
Also as you said, you can call your pre-made VIEW in our SQL Query Tables like "SELECT * FROM VIEWName", but we can't pass an input parameter through the Plugin inside that VIEW directly.
If you need to have a dynamic SQL Query Table which can change the Query with a parameter from a Page,
1. I will first share one example we got before from our Developers, they said this can be used for custom Dynamic Placeholders of SQL Query Tables.
We don't have this built-in yet, but you can with a workaround. Please note that this does require some experience with writing SQL queries and using WP hooks.
You can create a table with a query like this:
SELECT user_id, user_name, user_address,
CONCAT('<a href="http:/yoursite.com/your_custom_page?user_id=',user_id,'">Details</a>') AS Details
FROM your_table_name
Then, on your_custom_page you will insert a shortcode of the table ID that you need, with a placeholder like this:
[wpdatatable id=1 var1=1]
The second table would be created from a query like this:
SELECT * FROM second_table WHERE user_id = %VAR1%
After that, you can use a hook for dynamic placeholders:
function updateVAR1($tableID){ global $wdtVar1;
//check is set GET parametar user_id
if(isset($_GET['user_id'])){
//get value from form fieald
$wdtVar1 = $_GET['user_id']; } }
add_action('wpdatatables_before_get_table_metadata', 'updateVAR1');
I hope this helps you achieve the results that you need.
2. Another custom example, in this case the scenario was to use PHP or API to dynamically change the Query of a Table on a page.
You can take a look at our available filters for developers here ;
but combining these two or perhaps even just by using that hook/filter,
you might be able to achieve this use-case.
We do like to give more exact examples for certain solutions, but for this use-case, we, unfortunately, don't have anything yet, so at this time you can only try to make a custom solution to make this work.
I need to be able to pass an input parameter to my query. The plugin doesn't support calling stored procs, and I can't pass an input parameter to a view, so what are my options? I don't want my query to live in the plugin, I want it in my DB. Thanks
Hi Jereme,
Yes, you won't be able to create a new SQL VIEW in your Database through our Plugin, and our SQL Queries are not able to make a new Table in the DB as you know.
All the data from each SQL Query table is stored as JSON Data as part of 'wp_wpdatatables' and 'wp_wpdatatables_rows'.
Also as you said, you can call your pre-made VIEW in our SQL Query Tables like "SELECT * FROM VIEWName", but we can't pass an input parameter through the Plugin inside that VIEW directly.
If you need to have a dynamic SQL Query Table which can change the Query with a parameter from a Page,
1. I will first share one example we got before from our Developers, they said this can be used for custom Dynamic Placeholders of SQL Query Tables.
We don't have this built-in yet, but you can with a workaround. Please note that this does require some experience with writing SQL queries and using WP hooks.
You can create a table with a query like this:
Then, on your_custom_page you will insert a shortcode of the table ID that you need, with a placeholder like this:
[wpdatatable id=1 var1=1]
The second table would be created from a query like this:
After that, you can use a hook for dynamic placeholders:
I hope this helps you achieve the results that you need.
2. Another custom example, in this case the scenario was to use PHP or API to dynamically change the Query of a Table on a page.
You can take a look at our available filters for developers here ;
https://wpdatatables.com/documentation/information-for-developers/filters/
-
Our devs pointed out this one :
wpdatatables_filter_mysql_query( $query, $tableId )
because you can use that to manipulate the Query.
There is also an option with Placeholders,
but combining these two or perhaps even just by using that hook/filter,
you might be able to achieve this use-case.
We do like to give more exact examples for certain solutions, but for this use-case, we, unfortunately, don't have anything yet, so at this time you can only try to make a custom solution to make this work.
I hope this helps.
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