Quilter Posted August 31, 2019 Share Posted August 31, 2019 Hello - I need a way to execute a stored procedure from a wordpress site with an external database where the stored procedure is housed. I am very limited in php code. All I know is from what little I have used My Custom Functions plugin. Please be very detailed. This stored procedure I run truncates and re-populates a number of tables I use for various reports. I am pulling data from the wp db and creating tables in the external db which make the data easier to read than through the wp meta data. The tables are housed in a separate db so as not to slow down the wp db. The hosting company does not allow 'Events' to run on the mySql db so I am left with figuring out how to create a cron job using a php file which would be the best. Aside from that, I thought a button on an admin page for execution would make it easier if I have to do it be hand. Thanks for your help. Quote Link to comment Share on other sites More sharing options...
gw1500se Posted August 31, 2019 Share Posted August 31, 2019 (edited) This is really a MySQL question. The stored procedure is executed via MySQL. To initiate it, you simply execute the proper query in PHP just like any other query. If you are looking for the syntax of that query, you need to ask in the MySQL forum. Edited August 31, 2019 by gw1500se Quote Link to comment Share on other sites More sharing options...
gw1500se Posted August 31, 2019 Share Posted August 31, 2019 1 minute ago, gw1500se said: This is really a MySQL question. The stored procedure is executed via MySQL. To initiate it, you simply execute the proper query in PHP just like any other query. If you are looking for the syntax of that query, you need to ask in the MySQL forum. Perhaps this article will help. Quote Link to comment Share on other sites More sharing options...
Barand Posted August 31, 2019 Share Posted August 31, 2019 (edited) The syntax to run a stored procedure from PHP is as follows (where $db is the database connection)... $db->query("CALL my_procedure()"); or, if the procedure requires parameters... $db->query("CALL my_procedure($param1, $param2,...)"); Edited August 31, 2019 by Barand Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.