質問編集履歴
19
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,6 +12,12 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
+
※変数に格納してあるデータが1Mちょうどで収まっているのを確認しました。つまり1Mを超えたデータについては切られている状況になります。
|
16
|
+
|
17
|
+
そのため、json配列の「 ] 」も切られているので、nullが取得されていると考えています。
|
18
|
+
|
19
|
+
|
20
|
+
|
15
21
|
###コード
|
16
22
|
|
17
23
|
```
|
18
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,6 +16,18 @@
|
|
16
16
|
|
17
17
|
```
|
18
18
|
|
19
|
+
protected $casts = array(
|
20
|
+
|
21
|
+
'result' => 'array',
|
22
|
+
|
23
|
+
'query' => 'array',
|
24
|
+
|
25
|
+
);
|
26
|
+
|
27
|
+
```
|
28
|
+
|
29
|
+
```
|
30
|
+
|
19
31
|
$data = Search::select('result', 'query')->where('id', 5)->first();
|
20
32
|
|
21
33
|
$all = $data ? $data['result'] : [];
|
17
一部更新
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
【laravel】DBに保存されている配列がnullになり取得できない(取得するjson配列が途中で切れる)
|
1
|
+
【laravel・RDS】DBに保存されている配列がnullになり取得できない(取得するjson配列が途中で切れる)
|
test
CHANGED
File without changes
|
16
現状報告
test
CHANGED
File without changes
|
test
CHANGED
@@ -284,6 +284,14 @@
|
|
284
284
|
|
285
285
|
|
286
286
|
|
287
|
+
##現状報告
|
288
|
+
|
289
|
+
調べたところ、1MBを境目にエラーが発生しているようです。
|
290
|
+
|
291
|
+
そのため、phpとmysqlの設定をあらっている現状になります。
|
292
|
+
|
293
|
+
|
294
|
+
|
287
295
|
####バージョン
|
288
296
|
|
289
297
|
php7
|
15
DBはRDSを使っています
test
CHANGED
File without changes
|
test
CHANGED
@@ -289,3 +289,5 @@
|
|
289
289
|
php7
|
290
290
|
|
291
291
|
laravel5.1
|
292
|
+
|
293
|
+
データベース:RDS(mysql5.7)
|
14
タイトル追加
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
【laravel】DBに保存されている配列がnullになり取得できない
|
1
|
+
【laravel】DBに保存されている配列がnullになり取得できない(取得するjson配列が途中で切れる)
|
test
CHANGED
File without changes
|
13
更新
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
12
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -276,7 +276,11 @@
|
|
276
276
|
|
277
277
|
|
278
278
|
|
279
|
+
「LENGTH(result)」:1053784
|
280
|
+
|
281
|
+
|
282
|
+
|
279
|
-
「
|
283
|
+
「RIGHT(result, 10)」:1576,3449]
|
280
284
|
|
281
285
|
|
282
286
|
|
11
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -277,3 +277,11 @@
|
|
277
277
|
|
278
278
|
|
279
279
|
「LENGTH(result)」「RIGHT(result, 10)」:1576,3449]
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
####バージョン
|
284
|
+
|
285
|
+
php7
|
286
|
+
|
287
|
+
laravel5.1
|
10
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -265,3 +265,15 @@
|
|
265
265
|
}
|
266
266
|
|
267
267
|
```
|
268
|
+
|
269
|
+
###追記②
|
270
|
+
|
271
|
+
「strlen(getAttribute['result'])」:1041645
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
「substr(getAttribute['result'], -10)」:"7392,7372,"
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
「LENGTH(result)」「RIGHT(result, 10)」:1576,3449]
|
9
わからないこと修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,9 +4,9 @@
|
|
4
4
|
|
5
5
|
しかし、該当箇所でnullとなり、dd()で確認したところ、配列が途中までしか表示されておりませんでした。
|
6
6
|
|
7
|
-
|
7
|
+
すべての表示結果でそうなるわけではなく、一定数以上の件数でのみそうなっており、データ量が影響しているのではと考えております。
|
8
|
-
|
8
|
+
|
9
|
-
|
9
|
+
どうしてそうなるのかがわかっておらず、したがってどう対処すればよいのかわかっておりません。
|
10
10
|
|
11
11
|
ご教授いただければ幸いです。
|
12
12
|
|
8
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -164,14 +164,104 @@
|
|
164
164
|
|
165
165
|
```
|
166
166
|
|
167
|
+
$search = (int)request()->input('search');
|
168
|
+
|
169
|
+
if ($search) {
|
170
|
+
|
171
|
+
$data = Search::select('result', 'query')->where('id', $search)->first();
|
172
|
+
|
173
|
+
dd(strlen($data->getAttributeFromArray('result')));
|
174
|
+
|
175
|
+
$all = $data ? $data['result'] : [];
|
176
|
+
|
177
|
+
$q = isset($data['query']['q']) ? $data['query']['q'] : '';
|
178
|
+
|
179
|
+
$phaseIds[0] = isset($data['query']['phase']) ? $data['query']['phase'] : [];
|
180
|
+
|
181
|
+
$privacy = isset($data['query']['privacy']) ? $data['query']['privacy'] : [];
|
182
|
+
|
183
|
+
} else {
|
184
|
+
|
185
|
+
$phaseIds[0] = array_unique(array_map('intval', (array)request()->input('phase')));
|
186
|
+
|
187
|
+
if ($phaseIds[0]) {
|
188
|
+
|
189
|
+
} elseif (request()->ajax()) {
|
190
|
+
|
191
|
+
unset($phaseIds[0]);
|
192
|
+
|
193
|
+
unset($phaseIds[1]);
|
194
|
+
|
195
|
+
$phaseIds = array_values($phaseIds);
|
196
|
+
|
197
|
+
} else {
|
198
|
+
|
199
|
+
$phaseIds[0] = array_values(array_diff(last($phaseIds),(array)Option::getArray(Option::JPHASE_FINISH)));
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
// 検索フォームでの検索値の取得
|
204
|
+
|
205
|
+
$q = (string)request()->input('q');
|
206
|
+
|
207
|
+
// 各種ポータルサイトへの公開/非公開設定の取得
|
208
|
+
|
209
|
+
$privacy = array_unique((array)request()->input('privacy'));
|
210
|
+
|
211
|
+
// 全案件のidを取得
|
212
|
+
|
167
|
-
$all = self::commitSearch($q, $phaseIds[0], $privacy);
|
213
|
+
$all = self::commitSearch($q, $phaseIds[0], $privacy);
|
168
|
-
|
214
|
+
|
169
|
-
// インスタンスの生成
|
215
|
+
// インスタンスの生成
|
170
|
-
|
216
|
+
|
171
|
-
$search = new Search();
|
217
|
+
$search = new Search();
|
172
|
-
|
218
|
+
|
173
|
-
$search['result'] = $all;
|
219
|
+
$search['result'] = $all;
|
220
|
+
|
174
|
-
|
221
|
+
$search['query'] = ['phase'=>$phaseIds[0],'q'=>$q,'privacy'=>$privacy];
|
222
|
+
|
175
|
-
|
223
|
+
$search->save();
|
224
|
+
|
176
|
-
|
225
|
+
$search = $search['id'];
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
|
177
|
-
```
|
231
|
+
```
|
232
|
+
|
233
|
+
```
|
234
|
+
|
235
|
+
public static function commitSearch($q, $phaseIds, $privacy, $ids = NULL) {
|
236
|
+
|
237
|
+
$fulltext = Fulltext::where('type', 'job')->orderBy('time','DESC');
|
238
|
+
|
239
|
+
if ($ids) $fulltext->whereIn('main_id', $ids);
|
240
|
+
|
241
|
+
if ($phaseIds) $fulltext->whereIn('phase_id', $phaseIds);
|
242
|
+
|
243
|
+
if ($q !== '') $fulltext->whereIndex($q);
|
244
|
+
|
245
|
+
if (!$privacy || count($privacy) === 3) {
|
246
|
+
|
247
|
+
return array_map('intval', $fulltext->lists('main_id')->toArray());
|
248
|
+
|
249
|
+
} elseif (!($ids = array_map('intval', Job::whereIn('privacy', $privacy)->lists('id')->toArray()))) {
|
250
|
+
|
251
|
+
return [];
|
252
|
+
|
253
|
+
} elseif (count($ids) <= 10000) {
|
254
|
+
|
255
|
+
$fulltext->whereIn('main_id', $ids);
|
256
|
+
|
257
|
+
return array_map('intval', $fulltext->lists('main_id')->toArray());
|
258
|
+
|
259
|
+
} else {
|
260
|
+
|
261
|
+
return array_values(array_intersect(array_map('intval', $fulltext->lists('main_id')->toArray()), $ids));
|
262
|
+
|
263
|
+
}
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
```
|
7
一部追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -157,3 +157,21 @@
|
|
157
157
|
]
|
158
158
|
|
159
159
|
```
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
##追記
|
164
|
+
|
165
|
+
```
|
166
|
+
|
167
|
+
$all = self::commitSearch($q, $phaseIds[0], $privacy);
|
168
|
+
|
169
|
+
// インスタンスの生成
|
170
|
+
|
171
|
+
$search = new Search();
|
172
|
+
|
173
|
+
$search['result'] = $all;
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
```
|
6
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -152,4 +152,8 @@
|
|
152
152
|
|
153
153
|
"result" => "[142264,142265,142266,142263,142262,142261,142260,...]
|
154
154
|
|
155
|
+
"query" => "{"phase":[1,2,3,5,6,8,12,32,10,11,28,29,27,26,25,31,24,0],"q":"","privacy":[]}"
|
156
|
+
|
157
|
+
]
|
158
|
+
|
155
159
|
```
|
5
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -127,3 +127,29 @@
|
|
127
127
|
]
|
128
128
|
|
129
129
|
```
|
130
|
+
|
131
|
+
###ddの結果
|
132
|
+
|
133
|
+
```
|
134
|
+
|
135
|
+
Search {#987 ▼
|
136
|
+
|
137
|
+
#table: "searches"
|
138
|
+
|
139
|
+
#casts: array:3 [▶]
|
140
|
+
|
141
|
+
#connection: null
|
142
|
+
|
143
|
+
#primaryKey: "id"
|
144
|
+
|
145
|
+
#perPage: 15
|
146
|
+
|
147
|
+
+incrementing: true
|
148
|
+
|
149
|
+
+timestamps: true
|
150
|
+
|
151
|
+
#attributes: array:2 [▼
|
152
|
+
|
153
|
+
"result" => "[142264,142265,142266,142263,142262,142261,142260,...]
|
154
|
+
|
155
|
+
```
|
4
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -118,11 +118,11 @@
|
|
118
118
|
|
119
119
|
array:3 [▼
|
120
120
|
|
121
|
-
"pha
|
121
|
+
"pha" => array:18 [▶]
|
122
122
|
|
123
123
|
"q" => ""
|
124
124
|
|
125
|
-
"pri
|
125
|
+
"pri" => []
|
126
126
|
|
127
127
|
]
|
128
128
|
|
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -111,3 +111,19 @@
|
|
111
111
|
) ENGINE=InnoDB AUTO_INCREMENT=89390 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_c
|
112
112
|
|
113
113
|
```
|
114
|
+
|
115
|
+
###queryの中身
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
array:3 [▼
|
120
|
+
|
121
|
+
"phase" => array:18 [▶]
|
122
|
+
|
123
|
+
"q" => ""
|
124
|
+
|
125
|
+
"privacy" => []
|
126
|
+
|
127
|
+
]
|
128
|
+
|
129
|
+
```
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,7 +18,11 @@
|
|
18
18
|
|
19
19
|
$data = Search::select('result', 'query')->where('id', 5)->first();
|
20
20
|
|
21
|
+
$all = $data ? $data['result'] : [];
|
22
|
+
|
21
23
|
```
|
24
|
+
|
25
|
+
上記の「$data['result']」にddをかけるとnullが取得されます。
|
22
26
|
|
23
27
|
※Searchはsearchesというテーブルを指します。
|
24
28
|
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -67,3 +67,43 @@
|
|
67
67
|
|
68
68
|
|
69
69
|
よろしくお願いいたします。
|
70
|
+
|
71
|
+
##追加事項
|
72
|
+
|
73
|
+
###モデル
|
74
|
+
|
75
|
+
```
|
76
|
+
|
77
|
+
protected $table = 'searches';
|
78
|
+
|
79
|
+
protected $casts = array(
|
80
|
+
|
81
|
+
'id' => 'integer',
|
82
|
+
|
83
|
+
'result' => 'array',
|
84
|
+
|
85
|
+
'query' => 'array',
|
86
|
+
|
87
|
+
);
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
###テーブル構造
|
92
|
+
|
93
|
+
```
|
94
|
+
|
95
|
+
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
96
|
+
|
97
|
+
`result` longtext COLLATE utf8_unicode_ci NOT NULL,
|
98
|
+
|
99
|
+
`query` longtext COLLATE utf8_unicode_ci NOT NULL,
|
100
|
+
|
101
|
+
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
102
|
+
|
103
|
+
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
104
|
+
|
105
|
+
PRIMARY KEY (`id`)
|
106
|
+
|
107
|
+
) ENGINE=InnoDB AUTO_INCREMENT=89390 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_c
|
108
|
+
|
109
|
+
```
|