Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add parenthesis in query #168

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from
Open

add parenthesis in query #168

wants to merge 1 commit into from

Conversation

kernel64
Copy link

@kernel64 kernel64 commented May 5, 2022

Sametimes we need to write a query with parenthesis like this exemple :

WHERE ( categorie = 'informatique' AND stock < 20 )
OR ( categorie = 'fourniture' AND stock < 200 )

So with this merge we will be able to write it like this :

$subject1 = new Parenthesis(new Conditional('categorie', '=', 'informatique'), 'AND', new Conditional('stock', '<', 20));
$subject2 = new Parenthesis(new Conditional('categorie', '=', 'fourniture'), 'AND', new Conditional('stock', '<', 200));
$subject  = new Conditional($subject1, 'OR', $subject2);

@kwhat
Copy link
Collaborator

kwhat commented Aug 11, 2022

This should already be covered by the Grouping clause.

$subject  = new Grouping(
    'OR',
    new Grouping(
        'AND', 
        new Conditional('categorie', '=', 'informatique'), 
        new Conditional('stock', '<', 20)
    ),
    new Grouping(
        'AND', 
        new Conditional('categorie', '=', 'fourniture'), 
        new Conditional('stock', '<', 200)
    ),
);

@kernel64
Copy link
Author

kernel64 commented Sep 4, 2022

You are right. Thank you @kwhat for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants