Code Duplication    Length = 10-12 lines in 5 locations

migrations/v10x/m2_acp_module.php 1 location

@@ 18-29 (lines=12) @@
15
	/**
16
	* {@inheritDoc}
17
	*/
18
	public function effectively_installed()
19
	{
20
		$sql = 'SELECT module_id
21
			FROM ' . $this->table_prefix . "modules
22
			WHERE module_class = 'acp'
23
				AND module_langname = 'ACP_PHPBB_ADS_TITLE'";
24
		$result = $this->db->sql_query($sql);
25
		$module_id = (int) $this->db->sql_fetchfield('module_id');
26
		$this->db->sql_freeresult($result);
27
28
		return $module_id;
29
	}
30
31
	/**
32
	* {@inheritDoc}

ad/manager.php 4 locations

@@ 49-59 (lines=11) @@
46
	* @param	int		$ad_id	Advertisement ID
47
	* @return	mixed	Array with advertisement data, false if ad doesn't exist
48
	*/
49
	public function get_ad($ad_id)
50
	{
51
		$sql = 'SELECT *
52
			FROM ' . $this->ads_table . '
53
			WHERE ad_id = ' . (int) $ad_id;
54
		$result = $this->db->sql_query($sql);
55
		$data = $this->db->sql_fetchrow($result);
56
		$this->db->sql_freeresult($result);
57
58
		return $data;
59
	}
60
61
	/**
62
	* Get one ad per every location
@@ 106-115 (lines=10) @@
103
	 *
104
	 * @return	array	List of all ads
105
	 */
106
	public function get_all_ads()
107
	{
108
		$sql = 'SELECT ad_id, ad_name, ad_enabled, ad_end_date, ad_views, ad_clicks, ad_views_limit, ad_clicks_limit
109
			FROM ' . $this->ads_table;
110
		$result = $this->db->sql_query($sql);
111
		$data = $this->db->sql_fetchrowset($result);
112
		$this->db->sql_freeresult($result);
113
114
		return $data;
115
	}
116
117
	/**
118
	 * Get all owner's ads
@@ 123-133 (lines=11) @@
120
	 * @param	int	$user_id	Ad owner
121
	 * @return	array	List of owner's ads
122
	 */
123
	public function get_ads_by_owner($user_id)
124
	{
125
		$sql = 'SELECT ad_name, ad_views, ad_clicks
126
			FROM ' . $this->ads_table . '
127
			WHERE ad_owner = ' . (int) $user_id;
128
		$result = $this->db->sql_query($sql);
129
		$data = $this->db->sql_fetchrowset($result);
130
		$this->db->sql_freeresult($result);
131
132
		return $data;
133
	}
134
135
	/**
136
	* Increment views for specified ads
@@ 321-331 (lines=11) @@
318
	*
319
	* @return	array	List of groups
320
	*/
321
	public function load_groups()
322
	{
323
		$sql = 'SELECT group_id, group_name, group_type
324
			FROM ' . GROUPS_TABLE . '
325
			ORDER BY group_name ASC';
326
		$result = $this->db->sql_query($sql);
327
		$groups = $this->db->sql_fetchrowset($result);
328
		$this->db->sql_freeresult($result);
329
330
		return $groups;
331
	}
332
333
	/**
334
	* Make sure only necessary data make their way to SQL query