質問編集履歴
3
編集した
title
CHANGED
File without changes
|
body
CHANGED
@@ -49,7 +49,7 @@
|
|
49
49
|
$termId = $wpdb->get_var("SELECT term_id FROM wp_terms WHERE name = '$exNm'");
|
50
50
|
insertDataToTermTaxonomyTable($termId, $wpdb);
|
51
51
|
|
52
|
-
// term_relationships
|
52
|
+
// term_relationships
|
53
53
|
$postId = $id->post_id;
|
54
54
|
$termTaxonomyId = $wpdb->get_var("SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE term_id = '$termId'");
|
55
55
|
$relationshipData = compact("postId", "termTaxonomyId");
|
2
追記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -21,6 +21,42 @@
|
|
21
21
|
);
|
22
22
|
}
|
23
23
|
```
|
24
|
+
#foreach文
|
25
|
+
```php
|
26
|
+
foreach (array($ids) as $id) {
|
27
|
+
$exId = $id->meta_value;
|
28
|
+
$json = getExData($exId);
|
29
|
+
$exNm = $json->ExList[0]->ExNm;
|
30
|
+
$prefNm = $json->ExList[0]->PrefNm;
|
31
|
+
$areaNm = $json->ExList[0]->AreaNm;
|
32
|
+
$latitude = $json->ExList[0]->Latitude;
|
33
|
+
$longitude = $json->ExList[0]->Longitude;
|
34
|
+
$exInnCd = $json->ExList[0]->ExInnCd;
|
35
|
+
$exSaleCd = $json->ExList[0]->ExSaleCd;
|
36
|
+
$timestamp = time();
|
37
|
+
$updatedAt = date("Y-m-d H:i:s", $timestamp);
|
38
|
+
|
39
|
+
// wp_exs
|
40
|
+
$acmData = compact("exId", "exNm", "prefNm", "areaNm", "latitude", "longitude", "exInnCd", "exSaleCd", "updatedAt");
|
41
|
+
insertDataToExsTable($acmData, $wpdb);
|
42
|
+
|
43
|
+
// wp_terms
|
44
|
+
$encodedExNm = rawurlencode($exNm);
|
45
|
+
$tagData = compact("exNm", "encodedExNm");
|
46
|
+
insertDataToTermsTable($tagData, $wpdb);
|
47
|
+
|
48
|
+
// wp_term_taxonomy
|
49
|
+
$termId = $wpdb->get_var("SELECT term_id FROM wp_terms WHERE name = '$exNm'");
|
50
|
+
insertDataToTermTaxonomyTable($termId, $wpdb);
|
51
|
+
|
52
|
+
// term_relationshipsテーブルに情報を入れて紐付ける
|
53
|
+
$postId = $id->post_id;
|
54
|
+
$termTaxonomyId = $wpdb->get_var("SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE term_id = '$termId'");
|
55
|
+
$relationshipData = compact("postId", "termTaxonomyId");
|
56
|
+
insertDataToTermRelationships($relationshipData, $wpdb);
|
57
|
+
}
|
58
|
+
```
|
59
|
+
|
24
60
|
#エラーコード
|
25
61
|
- Warning: Invalid argument supplied for foreach()
|
26
62
|
|
1
誤植
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
[WordPress] get_resultsを使ったコード
|
1
|
+
[WordPress] get_resultsを使ったコードの関数化ができない
|
body
CHANGED
File without changes
|