-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[5.7] Query builder - dynamic "where" clauses #249
[5.7] Query builder - dynamic "where" clauses #249
Conversation
This is buggy when you have a column starting with
Without the |
Let me make some tests to isolate this, good spot. |
Signed-off-by: Ben Corlett <[email protected]>
@JoostK thanks for the spot. Only diff is that the regex you provided will only catch words that start with an And/Or. Needed to use a positive look-ahead for any capital letters after the And/Or match. |
Oh yes of course, you are right 😃 |
@JoostK, like my test method? lol |
If neither of those fail we are golden! 😉 |
+1 for that, liked the dynamic wheres |
+1 |
3 similar comments
+1 |
+1 |
👍 |
Just quickly updating the PR for the latest database changes. |
Signed-off-by: Ben Corlett <[email protected]> Conflicts: tests/Database/DatabaseQueryBuilderTest.php
Query builder - dynamic "where" clauses
Guys, I am so sorry for the inconvenience, I know this is really old PR, but I've just discovered this feature in verison 5.6. But when I tried to find docs for it, I saw that the latest docs that covers this feature is docs for 5.0. In docs for 5.1 and later versions, there is no mention of dynamic where clauses. I've looked at the changelogs etc, I couldn't find a mention of deprecation of this feature. Am I missing something? Is this discouraged to use? Why there is no docs for this feature after 5.0? |
It's removed in comit laravel/docs@b99cadb. Maybe it was accidental? Does it worth making PR? |
@OrkhanAlikhanov It looks accidental to me. I think you should submit a PR. |
Being an avid believer of Pull Request or STFU, I agreed with issue #241 and how it was a nice feature of Laravel 3.
I believe that dynamic where clauses, e.g.
User::whereFirstNameOrAge('Ben', 21)->first()
can sometimes be a nicer way than puttingUser::where('first_name', '=', 'Ben')->orWhere('age', '=', 21)->first()
. For this reason, I've added the functionality back in for dynamic "where" clauses into the query builder.I also noticed that Sublime has removed a couple of rogue spaces from the end of lines which have been added in. Enjoy.