1<?php 2 3namespace App\Repository; 4 5/** 6 * Repository class for retrieving data from the bugdb_pulls database table. 7 */ 8class PullRequestRepository 9{ 10 /** 11 * Database handler. 12 * @var \PDO 13 */ 14 private $dbh; 15 16 /** 17 * Class constructor. 18 */ 19 public function __construct(\PDO $dbh) 20 { 21 $this->dbh = $dbh; 22 } 23 24 /** 25 * Retrieve all pull requests by bug id. 26 * 27 * @param int $bugId 28 * @return array 29 */ 30 public function findAllByBugId(int $bugId) 31 { 32 $sql = 'SELECT github_repo, github_pull_id, github_title, github_html_url, developer 33 FROM bugdb_pulls 34 WHERE bugdb_id = ? 35 ORDER BY github_repo, github_pull_id DESC 36 '; 37 38 $statement = $this->dbh->prepare($sql); 39 $statement->execute([$bugId]); 40 41 return $statement->fetchAll(); 42 } 43} 44