質問編集履歴
2
一文字誤記入してました\.\.\.\(\*\^\^\*\)
test
CHANGED
File without changes
|
test
CHANGED
@@ -62,7 +62,7 @@
|
|
62
62
|
|
63
63
|
$articles[$i]['id'] = $data['parent_id'];
|
64
64
|
|
65
|
-
$articles[$i]['name'] = $data['name
|
65
|
+
$articles[$i]['name'] = $data['name'];
|
66
66
|
|
67
67
|
$i++;
|
68
68
|
|
1
追記しました\.\.♪
test
CHANGED
File without changes
|
test
CHANGED
@@ -29,3 +29,69 @@
|
|
29
29
|
「PDO::FETCH_NAMED」で出来そうなんですけど 使い方が解かりません
|
30
30
|
|
31
31
|
どなたか教えて下さい 宜しくお願い致します。
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
追記です...。
|
40
|
+
|
41
|
+
とりあえずの解決策として下記のコードで思った通りの配列は組めたんですけど...
|
42
|
+
|
43
|
+
```php
|
44
|
+
|
45
|
+
$pdo = new PDO(DNS,DBUSER,DBPASS,array(PDO::ATTR_EMULATE_PREPARES => false));
|
46
|
+
|
47
|
+
$pdo->query('SET NAMES utf8');
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
$stmt = $pdo->query(" SELECT * FROM `parent` ");
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
if($stmt->rowCount() > 0){
|
56
|
+
|
57
|
+
$articles = array();
|
58
|
+
|
59
|
+
$i=0;
|
60
|
+
|
61
|
+
while ($data = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
62
|
+
|
63
|
+
$articles[$i]['id'] = $data['parent_id'];
|
64
|
+
|
65
|
+
$articles[$i]['name'] = $data['name1'];
|
66
|
+
|
67
|
+
$i++;
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
$i=0;
|
72
|
+
|
73
|
+
foreach($articles as $parent){
|
74
|
+
|
75
|
+
$id = $parent['id'];
|
76
|
+
|
77
|
+
$stmt2 = $pdo->query(" SELECT * FROM `child` WHERE `parent_id` = '$id' ");
|
78
|
+
|
79
|
+
while ($data2 = $stmt2->fetch(PDO::FETCH_ASSOC)) {
|
80
|
+
|
81
|
+
$articles[$i]['child']['date'][] = $data2['date'];
|
82
|
+
|
83
|
+
$articles[$i]['child']['weight'][] = $data2['weight'];
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
$i++;
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
return $articles;
|
94
|
+
|
95
|
+
```
|
96
|
+
|
97
|
+
なんか 合理的ではない気がするんです (=ω=。)
|