Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6380183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:14:06+00:00 2026-05-25T02:14:06+00:00

In our current application I have a report that contains something like: if($foo ==

  • 0

In our current application I have a report that contains something like:

if($foo == 3 || $bar > 3) {
    $e = someFunction();
};

but for a different client that same expression might be:

if($foo == 3 || $bar == 5 && $foobar != 9) {
    $e = someFunction();
};

Is there an straight-forward way to store the two different expressions, just the

$foo == 3 || $bar > 3 OR $foo == 3 || $bar == 5

bits in the database (MySQL) so I do not have to hard code all of these rules by client or maintain client versions of the same report. I’m trying to figure out if I can set a variable o replace the conditions. Something like:

$conditions = $row_rsConditions['condition_row']    //Get $foo == 3 || $bar > 3 from the DB and store it as $conditions
if($conditions) {
    $e = someFunction();
};

There could be > 100 different clients and each client could/would have a different set of expressions.
I’m just not sure of the right/best way to do this.

UPDATE:

I think I understand the issues using PHP’s eval() function. But because of the number of possible combinations I am leaning towards using the DB to store the conditions (not sure about using eval() just yet)

Does it make any difference (safer) if there is no user facing interface that writes to the condition field/table? It could be something we manage on our end alone.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:14:06+00:00Added an answer on May 25, 2026 at 2:14 am

    i would be very careful about storing logic in the database.

    1. you code is no longer all in one place.
    2. logic in the database is unlikely to be under source control
    3. if you change the code and breaks all of that client specific logic, you have to go back into the database and edit it for every client.
    4. other people could have access to the database and could change the code to something malicious.

    this might not be the best solution
    but i would suggest creating an abstract base class, then inherit from that, a class specific to each client.

    Any functions that are customised can be added as a method to the base class, and overridden for client specific implementation.

    use a switch statement to instantiate the class based on a client id or name (something that doesn’t change) that you already store in the database.

    switch ($client_name) {
    
    case "abc ltd":
       $customlogic = new CustomLogicAbc();
       break;
    
    case "zyx ltd":
       $customlogic = new CustomLogicXyz();
       break;
    
    default: 
       $customlogic = new CustomLogicDefault();
       break;
    
    }
    
    if ($customlogic->doSomething($parm1, $parm2)) {
      // custom logic has been applied
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question regarding handling errors in a J2EE application. Our current application
We're about to start a new project, and our client's current application is .NET
I have written a winform application that connects to a database on our corporate
We want to update an existing Application but unfortunately we have a problem. Our
I am writing a WPF application that I need to authenticate with our current
In our current database development evironment we have automated build procceses check all the
In our current project we are providing a PDF download that can be customized
I have been asked to provide information on available techniques for assessing our current,
I developed a Word 2003 report generation application that extracts data from a database.
I have been supporting a web application at work for our Call Center unit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.