| @@ 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} |
|
| @@ 54-64 (lines=11) @@ | ||
| 51 | * |
|
| 52 | * @return array|false The idea row set, or false if not found. |
|
| 53 | */ |
|
| 54 | public function get_idea($id) |
|
| 55 | { |
|
| 56 | $sql = 'SELECT * |
|
| 57 | FROM ' . $this->table_ideas . ' |
|
| 58 | WHERE idea_id = ' . (int) $id; |
|
| 59 | $result = $this->db->sql_query_limit($sql, 1); |
|
| 60 | $row = $this->db->sql_fetchrow($result); |
|
| 61 | $this->db->sql_freeresult($result); |
|
| 62 | ||
| 63 | return $row; |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * Returns an idea specified by its topic ID. |
|
| @@ 73-83 (lines=11) @@ | ||
| 70 | * |
|
| 71 | * @return array|false The idea row set, or false if not found. |
|
| 72 | */ |
|
| 73 | public function get_idea_by_topic_id($id) |
|
| 74 | { |
|
| 75 | $sql = 'SELECT idea_id |
|
| 76 | FROM ' . $this->table_ideas . ' |
|
| 77 | WHERE topic_id = ' . (int) $id; |
|
| 78 | $result = $this->db->sql_query_limit($sql, 1); |
|
| 79 | $idea_id = (int) $this->db->sql_fetchfield('idea_id'); |
|
| 80 | $this->db->sql_freeresult($result); |
|
| 81 | ||
| 82 | return $this->get_idea($idea_id); |
|
| 83 | } |
|
| 84 | ||
| 85 | /** |
|
| 86 | * Returns the status name from the status ID specified. |
|