Code Duplication    Length = 13-18 lines in 8 locations

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

lib/private/Settings/Mapper.php 1 location

@@ 117-129 (lines=13) @@
114
	 * @param string $className
115
	 * @return bool
116
	 */
117
	public function has($table, $className) {
118
		$query = $this->dbc->getQueryBuilder();
119
		$query->select('class')
120
			->from($table)
121
			->where($query->expr()->eq('class', $query->createNamedParameter($className)))
122
			->setMaxResults(1);
123
124
		$result = $query->execute();
125
		$row = $result->fetch();
126
		$result->closeCursor();
127
128
		return (bool)$row;
129
	}
130
131
	/**
132
	 * deletes an settings or admin entry from the given table

lib/private/BackgroundJob/JobList.php 1 location

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

apps/sharebymail/lib/ShareByMailProvider.php 1 location

@@ 968-985 (lines=18) @@
965
	 * @return array
966
	 * @throws ShareNotFound
967
	 */
968
	protected function getRawShare($id) {
969
970
		// Now fetch the inserted share and create a complete share object
971
		$qb = $this->dbConnection->getQueryBuilder();
972
		$qb->select('*')
973
			->from('share')
974
			->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
975
976
		$cursor = $qb->execute();
977
		$data = $cursor->fetch();
978
		$cursor->closeCursor();
979
980
		if ($data === false) {
981
			throw new ShareNotFound;
982
		}
983
984
		return $data;
985
	}
986
987
	public function getSharesInFolder($userId, Folder $node, $reshares) {
988
		$qb = $this->dbConnection->getQueryBuilder();

apps/oauth2/lib/Db/AccessTokenMapper.php 1 location

@@ 43-56 (lines=14) @@
40
	 * @return AccessToken
41
	 * @throws AccessTokenNotFoundException
42
	 */
43
	public function getByCode($code) {
44
		$qb = $this->db->getQueryBuilder();
45
		$qb
46
			->select('*')
47
			->from($this->tableName)
48
			->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code))));
49
		$result = $qb->execute();
50
		$row = $result->fetch();
51
		$result->closeCursor();
52
		if($row === false) {
53
			throw new AccessTokenNotFoundException();
54
		}
55
		return AccessToken::fromRow($row);
56
	}
57
58
	/**
59
	 * delete all access token from a given client

apps/oauth2/lib/Db/ClientMapper.php 2 locations

@@ 43-56 (lines=14) @@
40
	 * @return Client
41
	 * @throws ClientNotFoundException
42
	 */
43
	public function getByIdentifier($clientIdentifier) {
44
		$qb = $this->db->getQueryBuilder();
45
		$qb
46
			->select('*')
47
			->from($this->tableName)
48
			->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier)));
49
		$result = $qb->execute();
50
		$row = $result->fetch();
51
		$result->closeCursor();
52
		if($row === false) {
53
			throw new ClientNotFoundException();
54
		}
55
		return Client::fromRow($row);
56
	}
57
58
	/**
59
	 * @param string $uid internal uid of the client
@@ 63-76 (lines=14) @@
60
	 * @return Client
61
	 * @throws ClientNotFoundException
62
	 */
63
	public function getByUid($uid) {
64
		$qb = $this->db->getQueryBuilder();
65
		$qb
66
			->select('*')
67
			->from($this->tableName)
68
			->where($qb->expr()->eq('id', $qb->createNamedParameter($uid, IQueryBuilder::PARAM_INT)));
69
		$result = $qb->execute();
70
		$row = $result->fetch();
71
		$result->closeCursor();
72
		if($row === false) {
73
			throw new ClientNotFoundException();
74
		}
75
		return Client::fromRow($row);
76
	}
77
78
	/**
79
	 * @return Client[]

apps/federatedfilesharing/lib/FederatedShareProvider.php 1 location

@@ 819-836 (lines=18) @@
816
	 * @return array
817
	 * @throws ShareNotFound
818
	 */
819
	private function getRawShare($id) {
820
821
		// Now fetch the inserted share and create a complete share object
822
		$qb = $this->dbConnection->getQueryBuilder();
823
		$qb->select('*')
824
			->from('share')
825
			->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
826
827
		$cursor = $qb->execute();
828
		$data = $cursor->fetch();
829
		$cursor->closeCursor();
830
831
		if ($data === false) {
832
			throw new ShareNotFound;
833
		}
834
835
		return $data;
836
	}
837
838
	/**
839
	 * Create a share object from an database row