Code Duplication    Length = 13-18 lines in 5 locations

lib/private/BackgroundJob/JobList.php 1 location

@@ 220-234 (lines=15) @@
217
	 * @param int $id
218
	 * @return IJob|null
219
	 */
220
	public function getById($id) {
221
		$query = $this->connection->getQueryBuilder();
222
		$query->select('*')
223
			->from('jobs')
224
			->where($query->expr()->eq('id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
225
		$result = $query->execute();
226
		$row = $result->fetch();
227
		$result->closeCursor();
228
229
		if ($row) {
230
			return $this->buildJob($row);
231
		} else {
232
			return null;
233
		}
234
	}
235
236
	/**
237
	 * get the job object from a row in the db

lib/private/Settings/Manager.php 1 location

@@ 261-273 (lines=13) @@
258
	 * @param string $className
259
	 * @return bool
260
	 */
261
	private function has($table, $className) {
262
		$query = $this->dbc->getQueryBuilder();
263
		$query->select('class')
264
			->from($table)
265
			->where($query->expr()->eq('class', $query->createNamedParameter($className)))
266
			->setMaxResults(1);
267
268
		$result = $query->execute();
269
		$row = $result->fetch();
270
		$result->closeCursor();
271
272
		return (bool) $row;
273
	}
274
275
	/**
276
	 * deletes an settings or admin entry from the given table

apps/workflowengine/lib/Manager.php 1 location

@@ 155-169 (lines=15) @@
152
	 * @return array
153
	 * @throws \UnexpectedValueException
154
	 */
155
	protected function getOperation($id) {
156
		$query = $this->connection->getQueryBuilder();
157
		$query->select('*')
158
			->from('flow_operations')
159
			->where($query->expr()->eq('id', $query->createNamedParameter($id)));
160
		$result = $query->execute();
161
		$row = $result->fetch();
162
		$result->closeCursor();
163
164
		if ($row) {
165
			return $row;
166
		}
167
168
		throw new \UnexpectedValueException($this->l->t('Operation #%s does not exist', $id));
169
	}
170
171
	/**
172
	 * @param string $class

apps/federatedfilesharing/lib/FederatedShareProvider.php 1 location

@@ 802-819 (lines=18) @@
799
	 * @return array
800
	 * @throws ShareNotFound
801
	 */
802
	private function getRawShare($id) {
803
804
		// Now fetch the inserted share and create a complete share object
805
		$qb = $this->dbConnection->getQueryBuilder();
806
		$qb->select('*')
807
			->from('share')
808
			->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
809
810
		$cursor = $qb->execute();
811
		$data = $cursor->fetch();
812
		$cursor->closeCursor();
813
814
		if ($data === false) {
815
			throw new ShareNotFound;
816
		}
817
818
		return $data;
819
	}
820
821
	/**
822
	 * Create a share object from an database row

apps/sharebymail/lib/ShareByMailProvider.php 1 location

@@ 710-727 (lines=18) @@
707
	 * @return array
708
	 * @throws ShareNotFound
709
	 */
710
	protected function getRawShare($id) {
711
712
		// Now fetch the inserted share and create a complete share object
713
		$qb = $this->dbConnection->getQueryBuilder();
714
		$qb->select('*')
715
			->from('share')
716
			->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
717
718
		$cursor = $qb->execute();
719
		$data = $cursor->fetch();
720
		$cursor->closeCursor();
721
722
		if ($data === false) {
723
			throw new ShareNotFound;
724
		}
725
726
		return $data;
727
	}
728
729
	public function getSharesInFolder($userId, Folder $node, $reshares) {
730
		$qb = $this->dbConnection->getQueryBuilder();