Code Duplication    Length = 9-11 lines in 6 locations

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}

factory/ideas.php 3 locations

@@ 305-315 (lines=11) @@
302
	 *
303
	 * @return array|false The idea row set, or false if not found.
304
	 */
305
	public function get_idea($id)
306
	{
307
		$sql = 'SELECT *
308
			FROM ' . $this->table_ideas . '
309
			WHERE idea_id = ' . (int) $id;
310
		$result = $this->db->sql_query_limit($sql, 1);
311
		$row = $this->db->sql_fetchrow($result);
312
		$this->db->sql_freeresult($result);
313
314
		return $row;
315
	}
316
317
	/**
318
	 * Returns an idea specified by its topic ID.
@@ 324-334 (lines=11) @@
321
	 *
322
	 * @return array|false The idea row set, or false if not found.
323
	 */
324
	public function get_idea_by_topic_id($id)
325
	{
326
		$sql = 'SELECT idea_id
327
			FROM ' . $this->table_ideas . '
328
			WHERE topic_id = ' . (int) $id;
329
		$result = $this->db->sql_query_limit($sql, 1);
330
		$idea_id = (int) $this->db->sql_fetchfield('idea_id');
331
		$this->db->sql_freeresult($result);
332
333
		return $this->get_idea($idea_id);
334
	}
335
336
	/**
337
	 * Do a live search on idea titles. Return any matches based on a given search query.
@@ 523-533 (lines=11) @@
520
	 *
521
	 * @return string The idea's title
522
	 */
523
	public function get_title($id)
524
	{
525
		$sql = 'SELECT idea_title
526
			FROM ' . $this->table_ideas . '
527
			WHERE idea_id = ' . (int) $id;
528
		$result = $this->db->sql_query_limit($sql, 1);
529
		$idea_title = $this->db->sql_fetchfield('idea_title');
530
		$this->db->sql_freeresult($result);
531
532
		return $idea_title;
533
	}
534
535
	/**
536
	 * Submits a vote on an idea.