mysql - How to call R script from PHP? -


i have bunch of r scripts calculations , return result. planning of building php website user can submit form data gets passed r script, processed , return result php , update interface.

the plan have database when user submits form, data gets stored in database r can read, process input , insert result in database php can grab it. however, there 2 problems:

  1. how r script knows values have been stored in database can grab values , processing?
  2. when r script finishes processing data , insert mysql db, how php understand @ moment php needs query database , grab value?

let's r script following:

range<-1:20 m<-mean(range) s<-sum(range) print(m) print(s) 

as can see input @ case 1 , 20 define range, , output show values of m , s on webpage.

any idea how accomplish that? thanks!

shell_exec() or exec() best choices in php. this answer explains difference.

echo shell_exec("rscript my_script.r {$_get['range']}"); 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -