質問編集履歴
3
ad
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
-
|
41
|
+
```PHP
|
42
42
|
|
43
43
|
|
44
44
|
|
@@ -98,4 +98,4 @@
|
|
98
98
|
|
99
99
|
|
100
100
|
|
101
|
-
|
101
|
+
```
|
2
a
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
-
\\\
|
41
|
+
\\\PHP
|
42
42
|
|
43
43
|
|
44
44
|
|
1
s
test
CHANGED
File without changes
|
test
CHANGED
@@ -35,3 +35,67 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
どなたかご教授のほどよろしくお願いいたします。
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
\\\php
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
class Model_Countman{
|
46
|
+
|
47
|
+
// コンストラクタ
|
48
|
+
|
49
|
+
public function __construct() {}
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
public function get_count(){
|
54
|
+
|
55
|
+
$url = parse_url(getenv('DATABASE_URL'));
|
56
|
+
|
57
|
+
try{
|
58
|
+
|
59
|
+
$dsn = sprintf('pgsql:host=%s;dbname=%s', $url['host'], substr($url['path'], 1));
|
60
|
+
|
61
|
+
$pdo = new PDO($dsn, $url['user'], $url['pass']);
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
$stmt = $pdo->query('SELECT name, count FROM public.member');
|
66
|
+
|
67
|
+
$result = $stmt->fetchAll();
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
$data = array();
|
72
|
+
|
73
|
+
foreach($result as $row){
|
74
|
+
|
75
|
+
$data[] = array(
|
76
|
+
|
77
|
+
'name' -> $row['name'],
|
78
|
+
|
79
|
+
'count' -> $row['count']
|
80
|
+
|
81
|
+
);
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
}catch (PDOException $e){
|
86
|
+
|
87
|
+
print('connection ERROR!:'.$e->getMessage());
|
88
|
+
|
89
|
+
return $e;
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
return $data;
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
\\\
|