Jump to content

diesel_heart

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

diesel_heart's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Oops!! [quote author=daiwa link=topic=105313.msg420731#msg420731 date=1156345786] Just a quick note on the dangers of Eval. its not something you really want to be doing evaluating code that's in a database. As Rasmus Lerdof (creator of PHP) put it "If eval is the answer your asking the wrong question". [/quote] It's tempting not to think why Eval is around if it's meant not to be used...I think that remarks like that must be taken with caution...maybe Rasmus Lerdorf said that in a specific context where the statement made sense...I tend to think that on solid established programming languages (as PHP, which is pretty recent when compared to C, for example, but is widely used) when some tool or technique is around, then there must be some usage for it...it's up to the programmer to "ask the right questions"... Nevertheless, I thank and welcome your feedback and I would appreciate if you could explain this ideia (as I said, I'm a newbie in PHP and I take this as an opportunity to learn more...). Also, if you could present another alternative to my problem's solution, I would be grateful and we all would be more enlighted.
  2. "I suspected we weren't talking about fruit and that this might be more complicated." Indeed, we weren't talking about fruit...but I find that if you shoot complex examples or domain-specific issues on help forums, people tend to shy away from answering...anyway, the fruit stuff did fine!! :-) Thanks a lot for your support. I believe that Eval might be the solution to my problem. I will want to test it and then, if it tests sucessfully, I'll give some feedback. (Incidentally, I will be on vacations next week so I'll test only in a couple of days...) As for the checking and the tweaking, I'll work it out myself. Thanks again!
  3. First of all, I'd like to thank you for your help! This is a good starter for the solution. My example was not only silly but also a bit simplistic: I forgot to mention that I will need to perform multiplications, divisions, and also to have the possibility of use constants. For example: Apples_Oranges = (1 - (Apples*Oranges)/(10 - Apples)) * 100% Anyway, it's like you said: "Anything more complicated will require an extension to this solution." If you think this subject is off-topic or not appropriate for this forum can you please give some tip where to find information on stuff like this? Once again, thanks a lot.
  4. Hello, I'm a newbie to PHP and I'm currently developing a system where you have to perform some calculations on a set of values. One of systems requisite is that the formulas used in the calculations must be stored on the data base. This happens because the formulas are expected to change a lot during the systems life, so you have to have way of just changing the formulas WITHOUT recoding the system. My question is how can you do this with PHP? Like, execute a formula that has been retrieved from the BD, and have it producing a numerical result. Here's a (pretty silly) example: - on the BD you have two tables: Fruits and Formulas like this: Fruits table: Fruit          Number -------------------- Apple          2 Orange        3 Banana        5 Formula table: Name                        Formula -------------------------------------- Total_fruits          Apple + Orange + Banana Apples_Oranges    Apple + Orange So you want to preform a first query to get the calculating formula and a second query for the data. If tomorrow you want to exchange the Apples_Oranges formula to "Apple - Orange" it would be just a matter of changing the BD. Any help on this would be widely appreciated. Thanks in advance.
×
×
  • 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.