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 149317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:06:42+00:00 2026-05-11T09:06:42+00:00

I am trying to create an object that is capable of handling query-like conditional

  • 0

I am trying to create an object that is capable of handling query-like conditional statements. This is so I can ‘join’ two conditions together to create a dependency between them based on the type of ‘join’ being used. I currently have a simple object that contains the following methods:

public function addCondition ( Condition $condition, $join = null ) {     $this->conditions[] = $condition; }  public function validate ( ) {     foreach ( $this->conditions as $condition )     {         $result = $condition->validate( );         [...]     } } 

The problem is, I need to be able to perform a conditional join between two statements, that will affect the return value of the the validate method. The idea is that you could supply a condition as follows:

$this->addCondition($condition_1); $this->addCondition($condition_2, 'AND'); $this->addCondition($condition_3, 'NOT'); 

This would then generate the logic required to specify that the results of the third condition would backwards-chain to affect the results of the first condition.

In the example, lets say:

 condition_1 = Apple is Red condition_2 = Apple is Ripe condition_3 = Apple is Golden Delicious 

Using this I should assume that if I was to pass a ripe, red and golden delicious apple, the result of validate() would be false. The method should fail because the ‘join’ for condition_3 is NOT.

However, at present there is no way of telling the code that the result of the entire method depends on the result of the previous condition and the way it is joined to it.

Any help is greatly appreciated! Thanks.

  • 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. 2026-05-11T09:06:42+00:00Added an answer on May 11, 2026 at 9:06 am

    Put the logic in your Condition subclasses.

    Create a Condition_And class that takes two (or more) Condition objects and returns true only if they are both true.

    Create a Condition_Or class that takes two (or more) Condition objects and returns false if any is true.

    Create a Condition_Not class if you feel it is necessary (Apple is NOT Golden Delicious).

    Stringing these together should get you any query you’re looking for. Since they’re all subclasses of the same type, you can build them up putting NOTs inside of ORs inside of ANDs inside of ORs and so on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an PHP object that can load objects in other files
I'm trying to create a QML object that acts like a wrapper for other
I have a VB6 dll that is trying to create a COM object using
I'm trying to create a custom JSP tag that would take an array object
I'm trying to create a custom object that behaves properly in set operations. I've
I'm trying to create a Messages object that inherits Array. The messages will gather
I am trying to create a custom object that simply inherits the NSString class
I'm trying to create a __set for an object in PHP that works with
I am trying to create a Game so that I can change its data
I’m trying to create a count down timer. I user a Timer object that

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.