Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upWhere group #186
Where group #186
Conversation
Created the initial function but came across an issue where the $whereClause doesn't work in the $where method when using an OR combiner, so need to fix that first
Methods and functions complete but failed testing in phpunit so needing to fix
PHPUnit tests succeeded.
Cleaned up trailing combiner in tests
| @@ -126,110 +127,110 @@ function createCertificate( | |||
| /** | |||
| * Creates an equality comparison expression with the given arguments. | |||
| */ | |||
| function eq($x, $y, $and = null, ...$args) | |||
| function eq($x, $y, $and = null, $group = null, ...$args) | |||
codeclimate
bot
Apr 21, 2020
Method eq has 5 arguments (exceeds 4 allowed). Consider refactoring.
Method eq has 5 arguments (exceeds 4 allowed). Consider refactoring.
techno-express
Apr 21, 2020
Contributor
All these bring in another required field? Whereas ...$args already covers that. You should try adding additional logic in the other methods instead to get the same results you are after.
The logic could be some kind of token/trigger word, to extract to get the desired action.
This is far beyond a breaking change, unnecessary, the logic should include a way for the current code to continue to work. The current tests should still pass.
All these bring in another required field? Whereas ...$args already covers that. You should try adding additional logic in the other methods instead to get the same results you are after.
The logic could be some kind of token/trigger word, to extract to get the desired action.
This is far beyond a breaking change, unnecessary, the logic should include a way for the current code to continue to work. The current tests should still pass.
| return $expression; | ||
| } | ||
|
|
||
| /** | ||
| * Creates a non equality comparison expression with the given arguments. | ||
| */ | ||
| function neq($x, $y, $and = null, ...$args) | ||
| function neq($x, $y, $and = null, $group = null, ...$args) |
codeclimate
bot
Apr 21, 2020
Method neq has 5 arguments (exceeds 4 allowed). Consider refactoring.
Method neq has 5 arguments (exceeds 4 allowed). Consider refactoring.
| return $expression; | ||
| } | ||
|
|
||
| /** | ||
| * Creates the other non equality comparison expression with the given arguments. | ||
| */ | ||
| function ne($x, $y, $and = null, ...$args) | ||
| function ne($x, $y, $and = null, $group = null, ...$args) |
codeclimate
bot
Apr 21, 2020
Method ne has 5 arguments (exceeds 4 allowed). Consider refactoring.
Method ne has 5 arguments (exceeds 4 allowed). Consider refactoring.
| return $expression; | ||
| } | ||
|
|
||
| /** | ||
| * Creates a lower-than comparison expression with the given arguments. | ||
| */ | ||
| function lt($x, $y, $and = null, ...$args) | ||
| function lt($x, $y, $and = null, $group = null, ...$args) |
codeclimate
bot
Apr 21, 2020
Method lt has 5 arguments (exceeds 4 allowed). Consider refactoring.
Method lt has 5 arguments (exceeds 4 allowed). Consider refactoring.
| return $expression; | ||
| } | ||
|
|
||
| /** | ||
| * Creates a lower-than-equal comparison expression with the given arguments. | ||
| */ | ||
| function lte($x, $y, $and = null, ...$args) | ||
| function lte($x, $y, $and = null, $group = null, ...$args) |
codeclimate
bot
Apr 21, 2020
Method lte has 5 arguments (exceeds 4 allowed). Consider refactoring.
Method lte has 5 arguments (exceeds 4 allowed). Consider refactoring.
|
you will need to come up with a solution for the bc, to have tests pass as is. |
Changed from breaking changes to use the existing extra `$args`. All existing PHPUnit tests run without failing.
| @@ -485,6 +493,19 @@ function replace($table = '', $keyValue) | |||
| : false; | |||
| } | |||
|
|
|||
| function flattenWhereConditions($whereConditions) | |||
codeclimate
bot
Apr 22, 2020
Function flattenWhereConditions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Function flattenWhereConditions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
techno-express
Apr 23, 2020
Contributor
This function should be in the class method being used in. It's a private helper function that should not be called directly by user/developer.
This function should be in the class method being used in. It's a private helper function that should not be called directly by user/developer.
dpDesignz
Apr 23, 2020
Author
Contributor
Very good point. I have moved this to the ezQuery file as a private method.
Very good point. I have moved this to the ezQuery file as a private method.
| } | ||
| } | ||
|
|
||
| public function whereGroup(...$whereConditions) |
codeclimate
bot
Apr 22, 2020
Function whereGroup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Function whereGroup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
techno-express
Apr 23, 2020
Contributor
What you think about just calling it group or grouping?
The only place it can be used in is with where already.
Repeating the same word within the same function call trying to stay away from, and keep naming somewhat similar to regular SQL dialect.
What you think about just calling it group or grouping?
The only place it can be used in is with where already.
Repeating the same word within the same function call trying to stay away from, and keep naming somewhat similar to regular SQL dialect.
dpDesignz
Apr 23, 2020
Author
Contributor
Good idea. Have updated the code and tests. I didn't want to call it group as that felt too close to groupBy for me and I thought it might get confused, but I like grouping.
Good idea. Have updated the code and tests. I didn't want to call it group as that felt too close to groupBy for me and I thought it might get confused, but I like grouping.
Incorrectly made a modification to the return of the `where` method instead of the `whereGroup` method
Thanks, I didn't even really think of using the existing Updated the code to use the existing options to avoid breaking changes. |
|
You will need to re-sync with master branch, the CI travis and appveyor systems and github see a conflicting file, and Travis still has a fail. |
Synced with master branch to reduce conflicts
Synced with master branch to reduce conflicts
Thanks. Still learning how this all works with open source and larger projects. I've only really used GitHub for small personal projects until recently. Both CI checks passed :) |
Changed the method from `whereGroup` to `grouping` and moved the flatten function to be a private method in the `ezQuery` file as per @techno-express recommendations.
| } | ||
| } | ||
|
|
||
| public function grouping(...$whereConditions) |
codeclimate
bot
Apr 23, 2020
Function grouping has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Function grouping has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Added a brief example in the readme file underneath the shortcut methods. Will add a detailed example in the wiki once approved.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Resolves #164
UPDATE: There are no longer breaking changes
Example code from
pdo\pdo_mysqlTest.phpfile:or another example without the function
The combiner will add itself at the end of the group.