m2_initial_data::update_data()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 *
4
 * Ideas extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) phpBB Limited <https://www.phpbb.com>
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace phpbb\ideas\migrations;
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
	public static function depends_on()
26
	{
27
		return array('\phpbb\ideas\migrations\m1_initial_schema');
28
	}
29
30
	public function update_data()
31
	{
32
		return array(
33
			array('custom', array(array($this, 'statuses_data'))),
34
		);
35
	}
36
37
	public function statuses_data()
38
	{
39
		$statuses_data = array(
40
			array(
41
				'status_id'		=> 1,
42
				'status_name'	=> 'NEW',
43
			),
44
			array(
45
				'status_id'		=> 2,
46
				'status_name'	=> 'IN_PROGRESS',
47
			),
48
			array(
49
				'status_id'		=> 3,
50
				'status_name'	=> 'IMPLEMENTED',
51
			),
52
			array(
53
				'status_id'		=> 4,
54
				'status_name'	=> 'DUPLICATE',
55
			),
56
			array(
57
				'status_id'		=> 5,
58
				'status_name'	=> 'INVALID',
59
			),
60
		);
61
62
		$insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'ideas_statuses');
63
64
		foreach ($statuses_data as $row)
65
		{
66
			$insert_buffer->insert($row);
67
		}
68
69
		$insert_buffer->flush();
70
	}
71
}
72