| @@ 7-44 (lines=38) @@ | ||
| 4 | ||
| 5 | use Aura\Sql\ConnectionLocator; |
|
| 6 | ||
| 7 | class MysqlIntroductionRepository implements IntroductionRepositoryInterface |
|
| 8 | { |
|
| 9 | ||
| 10 | /** @var Aura\Sql\ConnectionLocator */ |
|
| 11 | protected $connections; |
|
| 12 | ||
| 13 | /** |
|
| 14 | * @param Aura\Sql\ConnectionLocator |
|
| 15 | */ |
|
| 16 | public function __construct(ConnectionLocator $connections) |
|
| 17 | { |
|
| 18 | $this->connections = $connections; |
|
| 19 | } |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @param string $type |
|
| 23 | * @param string $value |
|
| 24 | * |
|
| 25 | * @return array|false |
|
| 26 | */ |
|
| 27 | public function findByType($type, $value = '') |
|
| 28 | { |
|
| 29 | $query = " |
|
| 30 | SELECT `title`, `content`, `image` |
|
| 31 | FROM `jpemeric_blog`.`introduction` |
|
| 32 | WHERE `type` = :type AND `value` = :value |
|
| 33 | LIMIT 1"; |
|
| 34 | $bindings = [ |
|
| 35 | 'type' => $type, |
|
| 36 | 'value' => $value, |
|
| 37 | ]; |
|
| 38 | ||
| 39 | return $this |
|
| 40 | ->connections |
|
| 41 | ->getRead() |
|
| 42 | ->fetchOne($query, $bindings); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||
| @@ 7-42 (lines=36) @@ | ||
| 4 | ||
| 5 | use Aura\Sql\ConnectionLocator; |
|
| 6 | ||
| 7 | class MysqlHuluRepository implements HuluRepositoryInterface |
|
| 8 | { |
|
| 9 | ||
| 10 | /** @var ConnectionLocator */ |
|
| 11 | protected $connections; |
|
| 12 | ||
| 13 | /** |
|
| 14 | * @param ConnectonLocator $connections |
|
| 15 | */ |
|
| 16 | public function __construct(ConnectionLocator $connections) |
|
| 17 | { |
|
| 18 | $this->connections = $connections; |
|
| 19 | } |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @param integer $id |
|
| 23 | * |
|
| 24 | * @return array|false |
|
| 25 | */ |
|
| 26 | public function getHuluById($id) |
|
| 27 | { |
|
| 28 | $query = " |
|
| 29 | SELECT * |
|
| 30 | FROM `jpemeric_stream`.`hulu` |
|
| 31 | WHERE `id` = :id |
|
| 32 | LIMIT 1"; |
|
| 33 | $bindings = [ |
|
| 34 | 'id' => $id, |
|
| 35 | ]; |
|
| 36 | ||
| 37 | return $this |
|
| 38 | ->connections |
|
| 39 | ->getRead() |
|
| 40 | ->fetchOne($query, $bindings); |
|
| 41 | } |
|
| 42 | } |
|
| 43 | ||