| Conditions | 3 |
| Paths | 2 |
| Total Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function __construct( \PDO $pdo, $sheets_table, $coupons_table, $php_class = null) |
||
| 16 | { |
||
| 17 | $sql = "SELECT |
||
| 18 | Sheets.id, |
||
| 19 | Sheets.slug, |
||
| 20 | Sheets.name, |
||
| 21 | Sheets.quantity, |
||
| 22 | Sheets.valid_from, |
||
| 23 | Sheets.valid_until, |
||
| 24 | GROUP_CONCAT(Coupons.code) AS coupons |
||
| 25 | |||
| 26 | FROM `{$sheets_table}` Sheets |
||
| 27 | |||
| 28 | RIGHT JOIN `{$coupons_table}` Coupons |
||
| 29 | ON Coupons.coupon_sheet_id = Sheets.id |
||
| 30 | |||
| 31 | GROUP BY Sheets.id"; |
||
| 32 | |||
| 33 | $stmt = $pdo->prepare( $sql ); |
||
| 34 | |||
| 35 | if (!$stmt->execute()) { |
||
| 36 | throw new \RuntimeException("Could not execute PDOStatement."); |
||
| 37 | } |
||
| 38 | |||
| 39 | $this->coupon_sheets = $stmt->fetchAll(\PDO::FETCH_CLASS, $php_class ?: CouponSheet::class); |
||
| 40 | } |
||
| 41 | |||
| 58 |