Code Duplication    Length = 8-9 lines in 7 locations

db/albummapper.php 1 location

@@ 300-307 (lines=8) @@
297
	 * @param string $userId
298
	 * @return integer
299
	 */
300
	public function count($userId){
301
		$sql = 'SELECT COUNT(*) AS count FROM `*PREFIX*music_albums` '.
302
			'WHERE `user_id` = ?';
303
		$params = array($userId);
304
		$result = $this->execute($sql, $params);
305
		$row = $result->fetch();
306
		return $row['count'];
307
	}
308
309
	/**
310
	 * Returns the count of albums an Artist is featured in

db/ampacheusermapper.php 1 location

@@ 81-89 (lines=9) @@
78
	/**
79
	 * @param string $userId
80
	 */
81
	public function getAll($userId) {
82
		$sql = 'SELECT `id`, `hash`, `description` FROM `*PREFIX*music_ampache_users` '.
83
			'WHERE `user_id` = ?';
84
		$params = array($userId);
85
		$result = $this->execute($sql, $params);
86
		$rows = $result->fetchAll();
87
88
		return $rows;
89
	}
90
}
91

db/artistmapper.php 1 location

@@ 134-141 (lines=8) @@
131
	/**
132
	 * @param string $userId
133
	 */
134
	public function count($userId){
135
		$sql = 'SELECT COUNT(*) AS count FROM `*PREFIX*music_artists` '.
136
			'WHERE `user_id` = ?';
137
		$params = array($userId);
138
		$result = $this->execute($sql, $params);
139
		$row = $result->fetch();
140
		return $row['count'];
141
	}
142
143
}
144

db/trackmapper.php 4 locations

@@ 122-129 (lines=8) @@
119
	 * @param string $userId
120
	 * @return integer
121
	 */
122
	public function countByArtist($artistId, $userId){
123
		$sql = 'SELECT COUNT(*) AS count FROM `*PREFIX*music_tracks` `track` '.
124
			'WHERE `track`.`user_id` = ? AND `track`.`artist_id` = ?';
125
		$params = array($userId, $artistId);
126
		$result = $this->execute($sql, $params);
127
		$row = $result->fetch();
128
		return $row['count'];
129
	}
130
131
	/**
132
	 * @param integer $albumId
@@ 136-143 (lines=8) @@
133
	 * @param string $userId
134
	 * @return integer
135
	 */
136
	public function countByAlbum($albumId, $userId){
137
		$sql = 'SELECT COUNT(*) AS count FROM `*PREFIX*music_tracks` `track` '.
138
			'WHERE `track`.`user_id` = ? AND `track`.`album_id` = ?';
139
		$params = array($userId, $albumId);
140
		$result = $this->execute($sql, $params);
141
		$row = $result->fetch();
142
		return $row['count'];
143
	}
144
145
	/**
146
	 * @param string $userId
@@ 149-156 (lines=8) @@
146
	 * @param string $userId
147
	 * @return integer
148
	 */
149
	public function count($userId){
150
		$sql = 'SELECT COUNT(*) AS count FROM `*PREFIX*music_tracks` '.
151
			'WHERE `user_id` = ?';
152
		$params = array($userId);
153
		$result = $this->execute($sql, $params);
154
		$row = $result->fetch();
155
		return $row['count'];
156
	}
157
158
	/**
159
	 * @param string $name
@@ 195-202 (lines=8) @@
192
	 * @param string $userId
193
	 * @return string[]
194
	 */
195
	public function lastChange($userId){
196
		$sql = 'SELECT MAX(added) last_added, MAX(updated) last_updated FROM `*PREFIX*music_tracks` '.
197
			'WHERE `user_id` = ?';
198
		$params = array($userId);
199
		$result = $this->execute($sql, $params);
200
		$row = $result->fetch();
201
		return $row;
202
	}
203
}
204