| @@ 113-140 (lines=28) @@ | ||
| 110 | * |
|
| 111 | * @throws RecordsNotFoundException Thrown when no records are found |
|
| 112 | */ |
|
| 113 | public function fetchBy(array $where = []) |
|
| 114 | { |
|
| 115 | $queryBuilder = $this->connection->createQueryBuilder() |
|
| 116 | ->select('*') |
|
| 117 | ->from(self::TABLE); |
|
| 118 | ||
| 119 | if (count($where) > 0) { |
|
| 120 | foreach ($where as $column => $value) { |
|
| 121 | $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value)); |
|
| 122 | } |
|
| 123 | } |
|
| 124 | ||
| 125 | $statement = $queryBuilder->execute(); |
|
| 126 | ||
| 127 | $result = $statement->fetchAll(); |
|
| 128 | ||
| 129 | if ($statement->rowCount() === 0) { |
|
| 130 | throw new RecordsNotFoundException('No records with given where clause found'); |
|
| 131 | } |
|
| 132 | ||
| 133 | $geoCaches = []; |
|
| 134 | ||
| 135 | foreach ($result as $item) { |
|
| 136 | $geoCaches[] = $this->getEntityFromDatabaseArray($item); |
|
| 137 | } |
|
| 138 | ||
| 139 | return $geoCaches; |
|
| 140 | } |
|
| 141 | ||
| 142 | /** |
|
| 143 | * Fetches a GeoCache by given where clause. |
|
| @@ 112-139 (lines=28) @@ | ||
| 109 | * |
|
| 110 | * @throws RecordsNotFoundException Thrown when no records are found |
|
| 111 | */ |
|
| 112 | public function fetchBy(array $where = []) |
|
| 113 | { |
|
| 114 | $queryBuilder = $this->connection->createQueryBuilder() |
|
| 115 | ->select('*') |
|
| 116 | ->from(self::TABLE); |
|
| 117 | ||
| 118 | if (count($where) > 0) { |
|
| 119 | foreach ($where as $column => $value) { |
|
| 120 | $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value)); |
|
| 121 | } |
|
| 122 | } |
|
| 123 | ||
| 124 | $statement = $queryBuilder->execute(); |
|
| 125 | ||
| 126 | $result = $statement->fetchAll(); |
|
| 127 | ||
| 128 | if ($statement->rowCount() === 0) { |
|
| 129 | throw new RecordsNotFoundException('No records with given where clause found'); |
|
| 130 | } |
|
| 131 | ||
| 132 | $geoCaches = []; |
|
| 133 | ||
| 134 | foreach ($result as $item) { |
|
| 135 | $geoCaches[] = $this->getEntityFromDatabaseArray($item); |
|
| 136 | } |
|
| 137 | ||
| 138 | return $geoCaches; |
|
| 139 | } |
|
| 140 | ||
| 141 | /** |
|
| 142 | * Fetch latest user geo cache log. |
|
| @@ 49-76 (lines=28) @@ | ||
| 46 | * |
|
| 47 | * @throws RecordsNotFoundException Thrown when no records are found |
|
| 48 | */ |
|
| 49 | public function fetchBy(array $where = []) |
|
| 50 | { |
|
| 51 | $queryBuilder = $this->connection->createQueryBuilder() |
|
| 52 | ->select('*') |
|
| 53 | ->from(self::TABLE); |
|
| 54 | ||
| 55 | if (count($where) > 0) { |
|
| 56 | foreach ($where as $column => $value) { |
|
| 57 | $queryBuilder->andWhere($column . ' = ' . $queryBuilder->createNamedParameter($value)); |
|
| 58 | } |
|
| 59 | } |
|
| 60 | ||
| 61 | $statement = $queryBuilder->execute(); |
|
| 62 | ||
| 63 | $result = $statement->fetchAll(); |
|
| 64 | ||
| 65 | if ($statement->rowCount() === 0) { |
|
| 66 | throw new RecordsNotFoundException('No records with given where clause found'); |
|
| 67 | } |
|
| 68 | ||
| 69 | $blocks = []; |
|
| 70 | ||
| 71 | foreach ($result as $item) { |
|
| 72 | $blocks[] = $this->getEntityFromDatabaseArray($item); |
|
| 73 | } |
|
| 74 | ||
| 75 | return $blocks; |
|
| 76 | } |
|
| 77 | ||
| 78 | /** |
|
| 79 | * Creates a block in the database. |
|