This topic is locked

Trigger an event to save data from external php script

11/15/2017 1:12:50 AM
PHPRunner General questions
C
cjs99 author

Hello,

I'm new to phprunner and despite a lot of searching cannot see how to enter data automatically to a phprunner MySQL database (from a php script).
I receive data from an app (http POST request) to a php script and need to send the resulting array to phprunner and trigger an 'Add' event or similar to save it in a new record.
Can anyone help me please!
Thanks in advance.

bobdutil 11/15/2017



Hello,

I'm new to phprunner and despite a lot of searching cannot see how to enter data automatically to a phprunner MySQL database (from a php script).
I receive data from an app (http POST request) to a php script and need to send the resulting array to phprunner and trigger an 'Add' event or similar to save it in a new record.
Can anyone help me please!
Thanks in advance.


If I understand you correctly, you wouldn't need to do this in phpRunner. I would have the script call a stored procedure in your MySql database to insert the records into your table. Google "calling mysql stored procedure using php script".

admin 11/15/2017

I think you can have better luck handling all this in your own script. Passing data to PHPRunner and executing events is somewhat complicated. You can probably execute the same event code in your own script. You can place event code into some external PHP file and include this file in both PHPRunner and your own PHP script.

C
cjs99 author 11/17/2017



If I understand you correctly, you wouldn't need to do this in phpRunner. I would have the script call a stored procedure in your MySql database to insert the records into your table. Google "calling mysql stored procedure using php script".

C
cjs99 author 11/17/2017

Thanks for your suggestions. I will try the stored procedure approach first and will let you know how I get on.

C
cjs99 author 12/4/2017



Thanks for your suggestions. I will try the stored procedure approach first and will let you know how I get on.


Ok. I can now insert new data directly into the MySQL database from my external script.

But this does not seem to trigger any events in phprunner. The page does not automatically refresh for instance.
I would like to automatically send email using phprunner functions (the email addresses are stored in another table) immediately after the new data has been inserted. How can I do this?
Thanks!

C
cjs99 author 12/6/2017



I think you can have better luck handling all this in your own script. Passing data to PHPRunner and executing events is somewhat complicated. You can probably execute the same event code in your own script. You can place event code into some external PHP file and include this file in both PHPRunner and your own PHP script.


Ok but can you give me an example please. or tell me what phprunner 'event code' I can use and where it is. In particular I want to send an email when the database has a new record inserted externally.
Thanks in advance,

Jim

admin 12/6/2017

Just send that email from the same external script that inserts data. It is just not clear why do you need PHPRunner here.