From d11f66f4669b6faa87fe2d3b3417578ac0ea3085 Mon Sep 17 00:00:00 2001 From: Einar Hansen <49709354+einar-hansen@users.noreply.github.com> Date: Tue, 16 Jul 2024 12:54:46 +0200 Subject: [PATCH 1/3] Update docs with information about the whereLike query --- queries.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/queries.md b/queries.md index e873bd8fad..9eb9fc148d 100644 --- a/queries.md +++ b/queries.md @@ -613,6 +613,43 @@ The `whereNotBetweenColumns` method verifies that a column's value lies outside ->whereNotBetweenColumns('weight', ['minimum_allowed_weight', 'maximum_allowed_weight']) ->get(); +**whereLike / orWhereLike / whereNotLike / orWhereNotLike** + +The `whereLike` method allows you to add "LIKE" clauses to your query for pattern matching. They provide a database-agnostic way of performing string matching queries. By default, it performs a case-insensitive search: + + $users = DB::table('users') + ->whereLike('name', '%John%') + ->get(); + +You can perform a case-sensitive search by passing `true` as the third argument: + + $users = DB::table('users') + ->whereLike('name', '%John%', true) + ->get(); + +The `orWhereLike` method allows you to add an "or" clause with a LIKE condition: + + $users = DB::table('users') + ->where('votes', '>', 100) + ->orWhereLike('name', '%John%') + ->get(); + +The `whereNotLike` method allows you to add "NOT LIKE" clauses to your query: + + $users = DB::table('users') + ->whereNotLike('name', '%John%') + ->get(); + +Similarly, you can use `orWhereNotLike` to add an "or" clause with a NOT LIKE condition: + + $users = DB::table('users') + ->where('votes', '>', 100) + ->orWhereNotLike('name', '%John%') + ->get(); + +> [!WARNING] +> The `whereLike` case-sensitive search option is currently not supported on SQL Server. + **whereIn / whereNotIn / orWhereIn / orWhereNotIn** The `whereIn` method verifies that a given column's value is contained within the given array: From 05760fa3379a43acc196ecc221f691e884869909 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 23 Jul 2024 16:03:58 -0500 Subject: [PATCH 2/3] Update queries.md --- queries.md | 66 +++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/queries.md b/queries.md index 9eb9fc148d..c1ee946168 100644 --- a/queries.md +++ b/queries.md @@ -583,48 +583,18 @@ You may use `whereJsonLength` method to query JSON arrays by their length: ### Additional Where Clauses -**whereBetween / orWhereBetween** - -The `whereBetween` method verifies that a column's value is between two values: - - $users = DB::table('users') - ->whereBetween('votes', [1, 100]) - ->get(); - -**whereNotBetween / orWhereNotBetween** - -The `whereNotBetween` method verifies that a column's value lies outside of two values: - - $users = DB::table('users') - ->whereNotBetween('votes', [1, 100]) - ->get(); - -**whereBetweenColumns / whereNotBetweenColumns / orWhereBetweenColumns / orWhereNotBetweenColumns** - -The `whereBetweenColumns` method verifies that a column's value is between the two values of two columns in the same table row: - - $patients = DB::table('patients') - ->whereBetweenColumns('weight', ['minimum_allowed_weight', 'maximum_allowed_weight']) - ->get(); - -The `whereNotBetweenColumns` method verifies that a column's value lies outside the two values of two columns in the same table row: - - $patients = DB::table('patients') - ->whereNotBetweenColumns('weight', ['minimum_allowed_weight', 'maximum_allowed_weight']) - ->get(); - **whereLike / orWhereLike / whereNotLike / orWhereNotLike** -The `whereLike` method allows you to add "LIKE" clauses to your query for pattern matching. They provide a database-agnostic way of performing string matching queries. By default, it performs a case-insensitive search: +The `whereLike` method allows you to add "LIKE" clauses to your query for pattern matching. These methods provide a database-agnostic way of performing string matching queries, with the ability to toggle case-sensitivity: $users = DB::table('users') ->whereLike('name', '%John%') ->get(); -You can perform a case-sensitive search by passing `true` as the third argument: +You can enable a case-sensitive search via the `caseSensitive` argument: $users = DB::table('users') - ->whereLike('name', '%John%', true) + ->whereLike('name', '%John%', caseSensitive: true) ->get(); The `orWhereLike` method allows you to add an "or" clause with a LIKE condition: @@ -685,6 +655,36 @@ select * from comments where user_id in ( > [!WARNING] > If you are adding a large array of integer bindings to your query, the `whereIntegerInRaw` or `whereIntegerNotInRaw` methods may be used to greatly reduce your memory usage. +**whereBetween / orWhereBetween** + +The `whereBetween` method verifies that a column's value is between two values: + + $users = DB::table('users') + ->whereBetween('votes', [1, 100]) + ->get(); + +**whereNotBetween / orWhereNotBetween** + +The `whereNotBetween` method verifies that a column's value lies outside of two values: + + $users = DB::table('users') + ->whereNotBetween('votes', [1, 100]) + ->get(); + +**whereBetweenColumns / whereNotBetweenColumns / orWhereBetweenColumns / orWhereNotBetweenColumns** + +The `whereBetweenColumns` method verifies that a column's value is between the two values of two columns in the same table row: + + $patients = DB::table('patients') + ->whereBetweenColumns('weight', ['minimum_allowed_weight', 'maximum_allowed_weight']) + ->get(); + +The `whereNotBetweenColumns` method verifies that a column's value lies outside the two values of two columns in the same table row: + + $patients = DB::table('patients') + ->whereNotBetweenColumns('weight', ['minimum_allowed_weight', 'maximum_allowed_weight']) + ->get(); + **whereNull / whereNotNull / orWhereNull / orWhereNotNull** The `whereNull` method verifies that the value of the given column is `NULL`: From cb860e5524359f5d6c798e94952ec7967059e734 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 23 Jul 2024 16:05:17 -0500 Subject: [PATCH 3/3] Update queries.md --- queries.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries.md b/queries.md index c1ee946168..6b0f6c47c9 100644 --- a/queries.md +++ b/queries.md @@ -585,7 +585,7 @@ You may use `whereJsonLength` method to query JSON arrays by their length: **whereLike / orWhereLike / whereNotLike / orWhereNotLike** -The `whereLike` method allows you to add "LIKE" clauses to your query for pattern matching. These methods provide a database-agnostic way of performing string matching queries, with the ability to toggle case-sensitivity: +The `whereLike` method allows you to add "LIKE" clauses to your query for pattern matching. These methods provide a database-agnostic way of performing string matching queries, with the ability to toggle case-sensitivity. By default, string matching is case-insensitive: $users = DB::table('users') ->whereLike('name', '%John%')