Jump to content
Quilter

Call db stored procedure when button is clicked

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Posted (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 by gw1500se

Share this post


Link to post
Share on other sites
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.

 

Share this post


Link to post
Share on other sites
Posted (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 by Barand

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.