回答編集履歴
2
new
test
CHANGED
@@ -72,7 +72,7 @@
|
|
72
72
|
|
73
73
|
```
|
74
74
|
|
75
|
-
$userRepository = \MyApp\Repository\User();
|
75
|
+
$userRepository = new \MyApp\Repository\User();
|
76
76
|
|
77
77
|
$user = $userRepository->find("1");
|
78
78
|
|
1
edit
test
CHANGED
@@ -63,3 +63,35 @@
|
|
63
63
|
}
|
64
64
|
|
65
65
|
```
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
もうちょい体裁直すと
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
$userRepository = \MyApp\Repository\User();
|
76
|
+
|
77
|
+
$user = $userRepository->find("1");
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
public function find($anumber)
|
82
|
+
|
83
|
+
{
|
84
|
+
|
85
|
+
$stmt = $this->db->prepare('select * from users where anumber = :anumber');
|
86
|
+
|
87
|
+
$stmt->execute(compact('anumber'));
|
88
|
+
|
89
|
+
return $stmt->fetchObject();
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
```
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
※ そもそもこの実装パターンは「モデル」じゃなくて「リポジトリ」です
|