0

I have a database table with the name of validation that contains data like

 vNo    Chkvalidate
   1    Check_Value ('Category_Code', '', '', '1', '', '1')=1
   2    Check_Value ('Category_Code', '', '', '2', '', '')=1 AND Check_Value ('Subject_Code', '', '', '1', '', '1')=1 

The function definitions written in validation.php file like this:

 function Check_Value($col_name, $to_range, $from_range, $list_value, $stat, $counter)
    {
      // Some definition here...
    }

How can I invoke the function Check_Value when I fetch record row by row from validation table...?

5
  • I'm not sure I understand what your problem is exactly? Fetching the records, or something else? Commented Jan 9, 2011 at 10:13
  • It seems you not only want to invoke it but also compare against a value (=1)? The function that shall not be named seems to be the easiest way.... but its evil! Commented Jan 9, 2011 at 10:15
  • Please show us your real database schema and data. Is this the same Check_Value function as in your last question? stackoverflow.com/questions/4615468/… Commented Jan 9, 2011 at 10:25
  • PEkka: my problem is that when i fetch the records from database can i invoke the function on the basis of the record...? Commented Jan 9, 2011 at 11:33
  • mario: Check_Value function is a function store in a table but its definition store in validation.php file. Commented Jan 9, 2011 at 11:38

1 Answer 1

0

You simply need to use PHP's eval function to evaluate the string you obtain from the database.

That said, I'd be very tempted to re-factor the offending part of the application, as storing (and subsequently evaluating) functions that reside in a database gives off such a strong code smell that a gas mask is required.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.