• Hi Peter,
    I have built some queries that make updates, inserts and deletes.
    How can I simply put a link into a static page to execute these queries ?
    Thank you
    Roger

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    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

    Thread Starter sturmy31

    (@sturmy31)

    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”]

    Thread Starter sturmy31

    (@sturmy31)

    … 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

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    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

    Thread Starter sturmy31

    (@sturmy31)

    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

    Thread Starter sturmy31

    (@sturmy31)

    … 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 !

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Queries inside static pages’ is closed to new replies.