質問編集履歴

3

誤字の修正

2020/02/29 20:56

投稿

Eggpan
Eggpan

スコア2729

test CHANGED
File without changes
test CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
 
17
- ###### 1. whereRawメソッドの第2引数にバインド値を入れてしてみた場合
17
+ ###### 1. whereRawメソッドの第2引数にバインド値を入れた場合
18
18
 
19
19
  ```PHP
20
20
 

2

COLLATE の例が utf8mb4_xxx に統一されてなかったので修正しました。

2020/02/29 20:56

投稿

Eggpan
Eggpan

スコア2729

test CHANGED
File without changes
test CHANGED
@@ -20,13 +20,13 @@
20
20
 
21
21
  $search_word = "tes't";
22
22
 
23
- User::whereRaw("name LIKE %?% COLLATE utf8_unicode_ci", [$search_word])->get();
23
+ User::whereRaw("name LIKE %?% COLLATE utf8mb4_unicode_ci", [$search_word])->get();
24
24
 
25
25
 
26
26
 
27
27
  $search_word = "tes't";
28
28
 
29
- User::whereRaw("name LIKE ? COLLATE utf8_unicode_ci", ['%' . $search_word . '%'])->get();
29
+ User::whereRaw("name LIKE ? COLLATE utf8mb4_unicode_ci", ['%' . $search_word . '%'])->get();
30
30
 
31
31
  ```
32
32
 
@@ -34,7 +34,7 @@
34
34
 
35
35
  ```SQL
36
36
 
37
- select * from `users` where name LIKE %tes't% COLLATE utf8_unicode_ci
37
+ select * from `users` where name LIKE %tes't% COLLATE utf8mb4_unicode_ci
38
38
 
39
39
  ```
40
40
 
@@ -52,13 +52,13 @@
52
52
 
53
53
  $search_word = str_replace(['\', "'", '_', '%'], ['\\', "\'", '\_', '\%'], $search_word);
54
54
 
55
- User::whereRaw("name LIKE '%{$search_word}%' COLLATE utf8_unicode_ci")->get();
55
+ User::whereRaw("name LIKE '%{$search_word}%' COLLATE utf8mb4_unicode_ci")->get();
56
56
 
57
57
  ```
58
58
 
59
59
  ```
60
60
 
61
- select * from `users` where name LIKE '%tes\'t%' COLLATE utf8_unicode_ci
61
+ select * from `users` where name LIKE '%tes\'t%' COLLATE utf8mb4_unicode_ci
62
62
 
63
63
  ```
64
64
 

1

SQL文が同じCOLLATEになってない部分があったので修正

2020/02/27 17:43

投稿

Eggpan
Eggpan

スコア2729

test CHANGED
File without changes
test CHANGED
@@ -52,13 +52,13 @@
52
52
 
53
53
  $search_word = str_replace(['\', "'", '_', '%'], ['\\', "\'", '\_', '\%'], $search_word);
54
54
 
55
- User::whereRaw("name LIKE '%{$search_word}%' COLLATE utf8mb4_unicode_ci")->get();
55
+ User::whereRaw("name LIKE '%{$search_word}%' COLLATE utf8_unicode_ci")->get();
56
56
 
57
57
  ```
58
58
 
59
59
  ```
60
60
 
61
- select * from `users` where name LIKE '%tes\'t%' COLLATE utf8mb4_unicode_ci
61
+ select * from `users` where name LIKE '%tes\'t%' COLLATE utf8_unicode_ci
62
62
 
63
63
  ```
64
64