| @@ 7-42 (lines=36) @@ | ||
| 4 | ||
| 5 | use Aura\Sql\ConnectionLocator; |
|
| 6 | ||
| 7 | class MysqlPieceRepository implements PieceRepositoryInterface |
|
| 8 | { |
|
| 9 | ||
| 10 | /** @var Aura\Sql\ConnectionLocator */ |
|
| 11 | protected $connections; |
|
| 12 | ||
| 13 | /** |
|
| 14 | * @param Aura\Sql\ConnectionLocator $connections |
|
| 15 | */ |
|
| 16 | public function __construct(ConnectionLocator $connections) |
|
| 17 | { |
|
| 18 | $this->connections = $connections; |
|
| 19 | } |
|
| 20 | ||
| 21 | public function getPieces($limit = null, $offset = 0) |
|
| 22 | { |
|
| 23 | $query = " |
|
| 24 | SELECT `id`, `title`, `title_url`, `category` |
|
| 25 | FROM `jpemeric_portfolio`.`piece` |
|
| 26 | WHERE `display` = :is_active |
|
| 27 | ORDER BY `date` DESC"; |
|
| 28 | if ($limit != null) { |
|
| 29 | $query .= " |
|
| 30 | LIMIT {$offset}, {$limit}"; |
|
| 31 | } |
|
| 32 | ||
| 33 | $bindings = [ |
|
| 34 | 'is_active' => 1, |
|
| 35 | ]; |
|
| 36 | ||
| 37 | return $this |
|
| 38 | ->connections |
|
| 39 | ->getRead() |
|
| 40 | ->fetchAll($query, $bindings); |
|
| 41 | } |
|
| 42 | } |
|
| 43 | ||
| @@ 7-42 (lines=36) @@ | ||
| 4 | ||
| 5 | use Aura\Sql\ConnectionLocator; |
|
| 6 | ||
| 7 | class MysqlLogRepository implements LogRepositoryInterface |
|
| 8 | { |
|
| 9 | ||
| 10 | /** @var Aura\Sql\ConnectionLocator */ |
|
| 11 | protected $connections; |
|
| 12 | ||
| 13 | /** |
|
| 14 | * @param Aura\Sql\ConnectionLocator $connections |
|
| 15 | */ |
|
| 16 | public function __construct(ConnectionLocator $connections) |
|
| 17 | { |
|
| 18 | $this->connections = $connections; |
|
| 19 | } |
|
| 20 | ||
| 21 | public function getActiveLogs($limit = null, $offset = 0) |
|
| 22 | { |
|
| 23 | $query = " |
|
| 24 | SELECT `id`, `title`, `alias`, `date`, `publish_date`, `introduction` |
|
| 25 | FROM `jpemeric_waterfall`.`log` |
|
| 26 | WHERE `is_public` = :public |
|
| 27 | ORDER BY `date` DESC"; |
|
| 28 | if ($limit != null) { |
|
| 29 | $query .= " |
|
| 30 | LIMIT {$offset}, {$limit}"; |
|
| 31 | } |
|
| 32 | ||
| 33 | $bindings = [ |
|
| 34 | 'public' => 1, |
|
| 35 | ]; |
|
| 36 | ||
| 37 | return $this |
|
| 38 | ->connections |
|
| 39 | ->getRead() |
|
| 40 | ->fetchAll($query, $bindings); |
|
| 41 | } |
|
| 42 | } |
|
| 43 | ||
| @@ 7-44 (lines=38) @@ | ||
| 4 | ||
| 5 | use Aura\Sql\ConnectionLocator; |
|
| 6 | ||
| 7 | class MysqlWaterfallRepository implements WaterfallRepositoryInterface |
|
| 8 | { |
|
| 9 | ||
| 10 | /** @var Aura\Sql\ConnectionLocator */ |
|
| 11 | protected $connections; |
|
| 12 | ||
| 13 | /** |
|
| 14 | * @param Aura\Sql\ConnectionLocator $connections |
|
| 15 | */ |
|
| 16 | public function __construct(ConnectionLocator $connections) |
|
| 17 | { |
|
| 18 | $this->connections = $connections; |
|
| 19 | } |
|
| 20 | ||
| 21 | public function getWaterfalls($limit = null, $offset = 0) |
|
| 22 | { |
|
| 23 | $query = " |
|
| 24 | SELECT `waterfall`.`id`, `waterfall`.`name`, `waterfall`.`alias`, |
|
| 25 | `watercourse`.`name` AS `watercourse`, `watercourse`.`alias` AS `watercourse_alias` |
|
| 26 | FROM `jpemeric_waterfall`.`waterfall` |
|
| 27 | INNER JOIN `jpemeric_waterfall`.`watercourse` ON `waterfall`.`watercourse` = `watercourse`.`id` |
|
| 28 | WHERE `is_public` = :public |
|
| 29 | ORDER BY `name`, `watercourse`"; |
|
| 30 | if ($limit != null) { |
|
| 31 | $query .= " |
|
| 32 | LIMIT {$offset}, {$limit}"; |
|
| 33 | } |
|
| 34 | ||
| 35 | $bindings = [ |
|
| 36 | 'public' => 1, |
|
| 37 | ]; |
|
| 38 | ||
| 39 | return $this |
|
| 40 | ->connections |
|
| 41 | ->getRead() |
|
| 42 | ->fetchAll($query, $bindings); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||