Hi Roger,
I guess you are referring to the Query Builder? The current version of the Query Builder does not support execution from another location than the Query Builder itself. But this was just the first step. Plans are to make queries available from:
– Shortcodes
– Publications (to support joins, grouping, etc)
– A task manager (cron jobs)
Plans are to add these new features after the summer. If you need to perform queries right away, you can use the Code Manager and execute a query from a PHP shortcode.
I created a minimal example to help you to get started. Please follow this link:
https://code-manager.com/code/?wpda_search_column_code_name=Execute%20query%20from%20PHP%20shortcode
Hope this helps for now. A better solution is planned… 😊
Best regards,
Peter
Thank you Peter for the code.
I copied / pasted and adapted your example.
But, how can I put the shortcode in a post ? This post is used as Static page in WPDA project.
I put the shortcode in the Post body but it is interpreted as text.
[cmruncode name=”Execute query from PHP shortcode”]
… more, when I preview the post with the shortcode I have the following error :
Fatal error: Uncaught Error: Call to undefined method wpdb::get_restults() in /datas/vol4/yulpa164130/var/www/fistf.net/htdocs/wp-content/plugins/code-manager/Code_Manager/Code_Manager.php(172) : eval()’d code:7 Stack trace: #0
Hi Roger,
That must be: get_results
Sorry, something must have gone wrong while copying that code.
Please use query instead of get_results for updates, inserts and deletes. The return value is the number of rows affected. For example:
$rows = $wpdadb->query( ‘update dept set x = 1 where y = 2’ );
Hope this helps,
Peter
Hi Peter,
I had an error in the name of the function get_results. Now the post is displayed correctly.
But when I display this post in the WPDA backend as a static page, the shortcode is not interpreted and the page displays “[cmruncode name =” Execute query from PHP shortcode ”]”
I send to you screenshots in PM.
Thanks
Roger
… Of course, this feature for me is to call a stored procedure for updates and not to retrieve select results.
So your last reply is useful !