Code Duplication    Length = 9-11 lines in 6 locations

factory/ideas.php 3 locations

@@ 237-247 (lines=11) @@
234
	 *
235
	 * @return array|false The idea row set, or false if not found.
236
	 */
237
	public function get_idea($id)
238
	{
239
		$sql = 'SELECT *
240
			FROM ' . $this->table_ideas . '
241
			WHERE idea_id = ' . (int) $id;
242
		$result = $this->db->sql_query_limit($sql, 1);
243
		$row = $this->db->sql_fetchrow($result);
244
		$this->db->sql_freeresult($result);
245
246
		return $row;
247
	}
248
249
	/**
250
	 * Returns an idea specified by its topic ID.
@@ 256-266 (lines=11) @@
253
	 *
254
	 * @return array|false The idea row set, or false if not found.
255
	 */
256
	public function get_idea_by_topic_id($id)
257
	{
258
		$sql = 'SELECT idea_id
259
			FROM ' . $this->table_ideas . '
260
			WHERE topic_id = ' . (int) $id;
261
		$result = $this->db->sql_query_limit($sql, 1);
262
		$idea_id = (int) $this->db->sql_fetchfield('idea_id');
263
		$this->db->sql_freeresult($result);
264
265
		return $this->get_idea($idea_id);
266
	}
267
268
	/**
269
	 * Do a live search on idea titles. Return any matches based on a given search query.
@@ 454-464 (lines=11) @@
451
	 *
452
	 * @return string The idea's title
453
	 */
454
	public function get_title($id)
455
	{
456
		$sql = 'SELECT idea_title
457
			FROM ' . $this->table_ideas . '
458
			WHERE idea_id = ' . (int) $id;
459
		$result = $this->db->sql_query_limit($sql, 1);
460
		$idea_title = $this->db->sql_fetchfield('idea_title');
461
		$this->db->sql_freeresult($result);
462
463
		return $idea_title;
464
	}
465
466
	/**
467
	 * Submits a vote on an idea.

migrations/m2_initial_data.php 1 location

@@ 15-23 (lines=9) @@
12
13
class m2_initial_data extends \phpbb\db\migration\migration
14
{
15
	public function effectively_installed()
16
	{
17
		$sql = 'SELECT * FROM ' . $this->table_prefix . 'ideas_statuses';
18
		$result = $this->db->sql_query_limit($sql, 1);
19
		$row = $this->db->sql_fetchrow($result);
20
		$this->db->sql_freeresult($result);
21
22
		return $row !== false;
23
	}
24
25
	static public function depends_on()
26
	{

migrations/m4_update_statuses.php 1 location

@@ 15-25 (lines=11) @@
12
13
class m4_update_statuses extends \phpbb\db\migration\migration
14
{
15
	public function effectively_installed()
16
	{
17
		$sql = 'SELECT status_id
18
			FROM ' . $this->table_prefix . "ideas_statuses
19
			WHERE status_name='New'";
20
		$result = $this->db->sql_query($sql);
21
		$row = $this->db->sql_fetchrow($result);
22
		$this->db->sql_freeresult($result);
23
24
		return $row === false;
25
	}
26
27
	static public function depends_on()
28
	{

textreparser/plugins/clean_old_ideas.php 1 location

@@ 56-64 (lines=9) @@
53
	/**
54
	 * {@inheritdoc}
55
	 */
56
	public function get_max_id()
57
	{
58
		$sql = 'SELECT MAX(idea_id) AS max_id FROM ' . $this->ideas_table;
59
		$result = $this->db->sql_query($sql);
60
		$max_id = (int) $this->db->sql_fetchfield('max_id');
61
		$this->db->sql_freeresult($result);
62
63
		return $max_id;
64
	}
65
66
	/**
67
	 * {@inheritdoc}