1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* @package phpBB Extension - RH Topic Tags |
5
|
|
|
* @copyright (c) 2014 Robet Heim |
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
7
|
|
|
* |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace robertheim\topictags\migrations; |
11
|
|
|
|
12
|
|
|
use robertheim\topictags\prefixes; |
13
|
|
|
use robertheim\topictags\tables; |
14
|
|
|
|
15
|
|
|
class release_0_0_13 extends \phpbb\db\migration\migration |
16
|
|
|
{ |
17
|
|
|
protected $version = '0.0.13-b1'; |
18
|
|
|
|
19
|
|
|
public function effectively_installed() |
20
|
|
|
{ |
21
|
|
|
return version_compare($this->config[prefixes::CONFIG.'_version'], $this->version, '>='); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public static function depends_on() |
25
|
|
|
{ |
26
|
|
|
return array( |
27
|
|
|
'\robertheim\topictags\migrations\release_0_0_12', |
28
|
|
|
); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function update_schema() |
32
|
|
|
{ |
33
|
|
|
return array( |
34
|
|
|
'add_columns' => array( |
35
|
|
|
$this->table_prefix . tables::TAGS => array( |
36
|
|
|
'tag_lowercase' => array('VCHAR:30', ''), |
37
|
|
|
), |
38
|
|
|
), |
39
|
|
|
); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function revert_schema() |
43
|
|
|
{ |
44
|
|
|
return array( |
45
|
|
|
'drop_columns' => array( |
46
|
|
|
$this->table_prefix . tables::TAGS => array( |
47
|
|
|
'tag_lowercase', |
48
|
|
|
), |
49
|
|
|
), |
50
|
|
|
); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
View Code Duplication |
public function update_data() |
54
|
|
|
{ |
55
|
|
|
return array( |
56
|
|
|
array('custom', array(array($this, 'calculate_lowercase_tags'))), |
57
|
|
|
array('config.update', array(prefixes::CONFIG.'_version', $this->version)), |
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function calculate_lowercase_tags() |
62
|
|
|
{ |
63
|
|
|
$sql = 'SELECT id, tag |
64
|
|
|
FROM ' . $this->table_prefix . tables::TAGS; |
65
|
|
|
$result = $this->db->sql_query($sql); |
66
|
|
|
|
67
|
|
|
while ($row = $this->db->sql_fetchrow($result)) |
68
|
|
|
{ |
69
|
|
|
$sql_ary = array( |
70
|
|
|
'tag_lowercase' =>utf8_strtolower($row['tag']), |
71
|
|
|
); |
72
|
|
|
$sql = 'UPDATE ' . $this->table_prefix . tables::TAGS . ' |
73
|
|
|
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' |
74
|
|
|
WHERE id = ' . $row['id']; |
75
|
|
|
$this->db->sql_query($sql); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
$this->db->sql_freeresult($result); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|