@@ 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 | { |
@@ 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 | { |
@@ 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} |
@@ 27-37 (lines=11) @@ | ||
24 | * |
|
25 | * @return array|false The idea row set, or false if not found. |
|
26 | */ |
|
27 | public function get_idea($id) |
|
28 | { |
|
29 | $sql = 'SELECT * |
|
30 | FROM ' . $this->table_ideas . ' |
|
31 | WHERE idea_id = ' . (int) $id; |
|
32 | $result = $this->db->sql_query_limit($sql, 1); |
|
33 | $row = $this->db->sql_fetchrow($result); |
|
34 | $this->db->sql_freeresult($result); |
|
35 | ||
36 | return $row; |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * Returns an idea specified by its topic ID. |
|
@@ 46-56 (lines=11) @@ | ||
43 | * |
|
44 | * @return array|false The idea row set, or false if not found. |
|
45 | */ |
|
46 | public function get_idea_by_topic_id($id) |
|
47 | { |
|
48 | $sql = 'SELECT idea_id |
|
49 | FROM ' . $this->table_ideas . ' |
|
50 | WHERE topic_id = ' . (int) $id; |
|
51 | $result = $this->db->sql_query_limit($sql, 1); |
|
52 | $idea_id = (int) $this->db->sql_fetchfield('idea_id'); |
|
53 | $this->db->sql_freeresult($result); |
|
54 | ||
55 | return $this->get_idea($idea_id); |
|
56 | } |
|
57 | ||
58 | /** |
|
59 | * Returns the status name from the status ID specified. |