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

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