0

I have 2 system, the interface I build with PHP and the machine is build with python because I use fuzzy in python.

I have to try get the specific data with PHP and that work

And i have make a function with python to recieve a variable and that work

But I have a problem

The problem is, how to throw a variabel from MySQL with PHP and process it with python ?

after that finish the process, how to throw back the result to PHP and then send to mySQL databases?

The code in php like this, the code is to grab the data from sql

function fuzzy($id = '')
    {   
        $data_sg1 = core::selectWhereCollums('area_proses','default','sg1',array('id'=>$id));
        $data_sg2 = core::selectWhereCollums('area_proses','default','sg2',array('id'=>$id));
        $data_sg3 = core::selectWhereCollums('area_proses','default','sg3',array('id'=>$id));


        $this->session->set_flashdata('success','success');
        redirect('area_proses');
    }

and the code in python like this

def hitung_fuzzy(masukan_sg1, masukan_sg2, masukan_sg3):
    sg1 = fuzz.Antecedent(np.arange(0, 5, 1), 'sg1')
    sg2 = fuzz.Antecedent(np.arange(0, 5, 1), 'sg2')
    sg3 = fuzz.Antecedent(np.arange(0, 5, 1), 'sg3')

---------------------
--------------------

####################################################
#Masukan
start_time = time.time()
a = float(input("Masukan SG1: "))
b = float(input("Masukan SG2: "))
c = float(input("Masukan SG3: "))

z = hitung_fuzzy(a,b,c)

print ("--------------------------------\n")
print ("Hasil Perhitungan:\n")
print (z)
print ("--------------------------------\n")
print ("Waktu proses adalah :\n")
print("%s detik\n" % (time.time() - start_time))
print ("--------------------------------\n")
raw_input("Tekan enter untuk keluar")
Misdan Wijaya
  • 39
  • 1
  • 2
  • 11

1 Answers1

0

The simplest solution would be to use PHP's exec function. Of course this is with assumption that the Python code accept command line arguments and gives its output in stdout (and/or stderr). If the Python itself is another standalone web service, then the solution would be different. So, if you want more specific answer you must give more specific details.

LeleDumbo
  • 9,192
  • 4
  • 24
  • 38