Code Duplication    Length = 7-11 lines in 15 locations

lib/private/AppConfig.php 1 location

@@ 226-236 (lines=11) @@
223
	 *
224
	 * Removes all keys in appconfig belonging to the app.
225
	 */
226
	public function deleteApp($app) {
227
		$this->loadConfigValues();
228
229
		$sql = $this->conn->getQueryBuilder();
230
		$sql->delete('appconfig')
231
			->where($sql->expr()->eq('appid', $sql->createParameter('app')))
232
			->setParameter('app', $app);
233
		$sql->execute();
234
235
		unset($this->cache[$app]);
236
	}
237
238
	/**
239
	 * get multiple values, either the app or key can be used as wildcard by setting it to false

apps/federation/lib/DbHandler.php 1 location

@@ 100-106 (lines=7) @@
97
	 *
98
	 * @param int $id
99
	 */
100
	public function removeServer($id) {
101
		$query = $this->connection->getQueryBuilder();
102
		$query->delete($this->dbTable)
103
			->where($query->expr()->eq('id', $query->createParameter('id')))
104
			->setParameter('id', $id);
105
		$query->execute();
106
	}
107
108
	/**
109
	 * get trusted server with given ID

lib/private/Authentication/Token/DefaultTokenMapper.php 1 location

@@ 118-125 (lines=8) @@
115
	 * @param IUser $user
116
	 * @param int $id
117
	 */
118
	public function deleteById(IUser $user, $id) {
119
		/* @var $qb IQueryBuilder */
120
		$qb = $this->db->getQueryBuilder();
121
		$qb->delete('authtoken')
122
			->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
123
			->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())));
124
		$qb->execute();
125
	}
126
127
}
128

lib/private/BackgroundJob/JobList.php 1 location

@@ 282-288 (lines=7) @@
279
	 *
280
	 * @param IJob $job
281
	 */
282
	public function unlockJob($job) {
283
		$query = $this->connection->getQueryBuilder();
284
		$query->update('jobs')
285
			->set('reserved_at', $query->expr()->literal(0, IQueryBuilder::PARAM_INT))
286
			->where($query->expr()->eq('id', $query->createNamedParameter($job->getId(), IQueryBuilder::PARAM_INT)));
287
		$query->execute();
288
	}
289
290
	/**
291
	 * get the id of the last ran job

apps/federatedfilesharing/lib/RequestHandler.php 1 location

@@ 572-578 (lines=7) @@
569
	 * @param IShare $share
570
	 * @param int $permissions
571
	 */
572
	protected function updatePermissionsInDatabase(IShare $share, $permissions) {
573
		$query = $this->connection->getQueryBuilder();
574
		$query->update('share')
575
			->where($query->expr()->eq('id', $query->createNamedParameter($share->getId())))
576
			->set('permissions', $query->createNamedParameter($permissions))
577
			->execute();
578
	}
579
580
}
581

apps/files_external/lib/Service/DBConfigService.php 2 locations

@@ 241-249 (lines=9) @@
238
	 * @param int $mountId
239
	 * @param string $newMountPoint
240
	 */
241
	public function setMountPoint($mountId, $newMountPoint) {
242
		$builder = $this->connection->getQueryBuilder();
243
244
		$query = $builder->update('external_mounts')
245
			->set('mount_point', $builder->createNamedParameter($newMountPoint))
246
			->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
247
248
		$query->execute();
249
	}
250
251
	/**
252
	 * @param int $mountId
@@ 255-263 (lines=9) @@
252
	 * @param int $mountId
253
	 * @param string $newAuthBackend
254
	 */
255
	public function setAuthBackend($mountId, $newAuthBackend) {
256
		$builder = $this->connection->getQueryBuilder();
257
258
		$query = $builder->update('external_mounts')
259
			->set('auth_backend', $builder->createNamedParameter($newAuthBackend))
260
			->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
261
262
		$query->execute();
263
	}
264
265
	/**
266
	 * @param int $mountId

apps/federatedfilesharing/lib/FederatedShareProvider.php 3 locations

@@ 388-394 (lines=7) @@
385
	 * @param int $shareId
386
	 * @param string $token
387
	 */
388
	protected function updateSuccessfulReShare($shareId, $token) {
389
		$query = $this->dbConnection->getQueryBuilder();
390
		$query->update('share')
391
			->where($query->expr()->eq('id', $query->createNamedParameter($shareId)))
392
			->set('token', $query->createNamedParameter($token))
393
			->execute();
394
	}
395
396
	/**
397
	 * store remote ID in federated reShare table
@@ 542-551 (lines=10) @@
539
	 *
540
	 * @param string $shareId
541
	 */
542
	private function removeShareFromTableById($shareId) {
543
		$qb = $this->dbConnection->getQueryBuilder();
544
		$qb->delete('share')
545
			->where($qb->expr()->eq('id', $qb->createNamedParameter($shareId)));
546
		$qb->execute();
547
548
		$qb->delete('federated_reshares')
549
			->where($qb->expr()->eq('share_id', $qb->createNamedParameter($shareId)));
550
		$qb->execute();
551
	}
552
553
	/**
554
	 * @inheritdoc
@@ 843-852 (lines=10) @@
840
	 * @param string $uid
841
	 * @param int $shareType
842
	 */
843
	public function userDeleted($uid, $shareType) {
844
		//TODO: probabaly a good idea to send unshare info to remote servers
845
846
		$qb = $this->dbConnection->getQueryBuilder();
847
848
		$qb->delete('share')
849
			->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE)))
850
			->andWhere($qb->expr()->eq('uid_owner', $qb->createNamedParameter($uid)))
851
			->execute();
852
	}
853
854
	/**
855
	 * This provider does not handle groups

apps/dav/lib/Migration/FixBirthdayCalendarComponent.php 1 location

@@ 53-61 (lines=9) @@
50
	/**
51
	 * @inheritdoc
52
	 */
53
	public function run(IOutput $output) {
54
		$query = $this->connection->getQueryBuilder();
55
		$updated = $query->update('calendars')
56
			->set('components', $query->createNamedParameter('VEVENT'))
57
			->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)))
58
			->execute();
59
60
		$output->info("$updated birthday calendars updated.");
61
	}
62
}
63

lib/private/Files/Config/UserMountCache.php 2 locations

@@ 283-289 (lines=7) @@
280
	 *
281
	 * @param IUser $user
282
	 */
283
	public function removeUserMounts(IUser $user) {
284
		$builder = $this->connection->getQueryBuilder();
285
286
		$query = $builder->delete('mounts')
287
			->where($builder->expr()->eq('user_id', $builder->createNamedParameter($user->getUID())));
288
		$query->execute();
289
	}
290
291
	public function removeUserStorageMount($storageId, $userId) {
292
		$builder = $this->connection->getQueryBuilder();
@@ 300-306 (lines=7) @@
297
		$query->execute();
298
	}
299
300
	public function remoteStorageMounts($storageId) {
301
		$builder = $this->connection->getQueryBuilder();
302
303
		$query = $builder->delete('mounts')
304
			->where($builder->expr()->eq('storage_id', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)));
305
		$query->execute();
306
	}
307
}
308

apps/dav/lib/DAV/Sharing/Backend.php 2 locations

@@ 104-110 (lines=7) @@
101
	/**
102
	 * @param $resourceId
103
	 */
104
	public function deleteAllShares($resourceId) {
105
		$query = $this->db->getQueryBuilder();
106
		$query->delete('dav_shares')
107
			->where($query->expr()->eq('resourceid', $query->createNamedParameter($resourceId)))
108
			->andWhere($query->expr()->eq('type', $query->createNamedParameter($this->resourceType)))
109
			->execute();
110
	}
111
112
	public function deleteAllSharesByUser($principaluri) {
113
		$query = $this->db->getQueryBuilder();
@@ 112-118 (lines=7) @@
109
			->execute();
110
	}
111
112
	public function deleteAllSharesByUser($principaluri) {
113
		$query = $this->db->getQueryBuilder();
114
		$query->delete('dav_shares')
115
			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principaluri)))
116
			->andWhere($query->expr()->eq('type', $query->createNamedParameter($this->resourceType)))
117
			->execute();
118
	}
119
120
	/**
121
	 * @param IShareable $shareable