Slide 25
Slide 25 text
ఆ͠ͳ͚ΕͳΒͳ͍ঢ়گ͕ݮͬͨ
const TIMESTAMP_FORMAT = 'Y-m-d\TH:i:s.uP';
public function findAll(\DateTime $startAt, \DateTime $endAt, string $status): array
{
if (!in_array($status, ['OPEN', 'NEW', 'FIXED'], true)) {
throw new \InvalidArgumentException('status should be in "OPEN","NEW","FIXED"');
}
$sql = 'SELECT bug_id, summary, reported_at FROM Bugs
WHERE reported_at >= :startAt AND reported_at < :endAt
AND status = :status';
$stmt = $this->pdo->prepare($sql);
$stmt->bindValue(':startAt', $startAt->format(self::TIMESTAMP_FORMAT), \PDO::PARAM_STR);
$stmt->bindValue(':endAt', $endAt->format(self::TIMESTAMP_FORMAT), \PDO::PARAM_STR);
$stmt->bindValue(':status', $status, \PDO::PARAM_STR);
$stmt->execute();
return $stmt->fetchAll(\PDO::FETCH_CLASS, Bug::class);
}
˞ຊߨԋͰ1PTUHSF42-ͷUJNFTUBNQXJUIUJNF[POFܕͷΧϥϜʹ֨ೲ͍ͯ͠Δͱߟ͍͑ͯͩ͘͞