DAO について修正
This commit is contained in:
+16
-4
@@ -53,11 +53,10 @@ Thread
|
||||
|
||||
public static function
|
||||
find (
|
||||
int $id)
|
||||
: \Dto\Thread
|
||||
SQLite3 $db,
|
||||
int $id)
|
||||
: ?\Dto\Thread
|
||||
{
|
||||
// TODO: 書くこと
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
t.id,
|
||||
@@ -78,6 +77,19 @@ Thread
|
||||
latest DESC";
|
||||
|
||||
$result = $db -> query ($sql);
|
||||
$row = $result -> fetchArray (SQLITE3_ASSOC);
|
||||
|
||||
if ($row === false)
|
||||
return null;
|
||||
|
||||
$thread = new \Dto\Thread;
|
||||
|
||||
$thread -> id = $row['id'];
|
||||
$thread -> title = $row['title'];
|
||||
$thread -> explain = $row['explain'];
|
||||
$thread -> length = $row['length'];
|
||||
|
||||
return $thread;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user