Implimenting C algorithm into php interface/mySQL database

Discussion in 'PHP' started by enephs, Aug 16, 2012.

  1. #1
    I have a complex algorithm, written in C, which I am adding to a php/mySQL site to create a web appication. Currently the algorithm pulls data from a .csv table, does it's work, then outputs the calculated results. Basically, when introducting this into a php/mySQL site, I am struggling to understand the limitations of server-side/client-side language interactions. I do all of my coding in php, never touching C, so I am wondering if this technique will even work. I know that I can exec the C code using PHP. I know I can connect to the mySQL database in C and get my data sets. I am just confused about steps 3/4.

    Heres what I wan't to happen:

    1) Submit the inputs using a html form
    2) Run algorithm (written in C) using the submitted inputs and datasets pulled from a mySQL database
    3) Generate results within the algorithm
    4) Display and save the results to the mySQL database

    Essentially, I wan't the web app to function as if it is entirely php/mySQL, only the number crunching is done by C code for speed. My first version of the algorithm was written in PHP and everything was gravy, except it took MUCH MUCH longer to generate a solution. Because of this, I had the same algorithm written in Java and C and I am trying to find the best way to impliment it.
     
    enephs, Aug 16, 2012 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,899
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    PHP can do that easily, I'm not sure how you are getting stuck. You don't need to "exec", just code the formula into a PHP function(s) and off you go.

    displaying the results is just printing or echo'ing them out. Saving into the database is a core function of php, you just have to decide how you need the tables structured.
     
    sarahk, Aug 16, 2012 IP
  3. enephs

    enephs Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm sorry, i'm confused. Are you saying to rewrite the algorithm in PHP and not use the C file at all?
     
    enephs, Aug 17, 2012 IP
  4. enephs

    enephs Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Never mind finally found a thread: /showthread.php?t=120505
     
    Last edited: Aug 17, 2012
    enephs, Aug 17, 2012 IP