Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
// $Id$
/**
* Implementation of hook_install().
*/
function gmap_taxonomy_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {gmap_taxonomy_term} (
tid int(10) unsigned NOT NULL default '0',
marker varchar(32),
PRIMARY KEY tid(tid)
) /*!40100 DEFAULT CHARACTER SET utf8 */");
db_query("CREATE TABLE {gmap_taxonomy_node} (
nid int(10) unsigned NOT NULL default '0',
vid int(10) unsigned NOT NULL default '0',
tid int(10) unsigned NOT NULL default '0',
marker varchar(32),
PRIMARY KEY vid(vid),
INDEX nid(nid)
) /*!40100 DEFAULT CHARACTER SET utf8 */");
break;
case 'pgsql':
//@@@
break;
}
}
/**
* Implementation of hook_uninstall().
*/
function gmap_taxonomy_uninstall() {
db_query('DROP TABLE {gmap_taxonomy_node}');
db_query('DROP TABLE {gmap_taxonomy_term}');
}
/**
* Track the tid that caused the association, so we can
* do fixups faster.
*/
function gmap_taxonomy_update_5001() {
$ret = array();
// Add the new column.
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {gmap_taxonomy_node} ADD tid int(10) unsigned NOT NULL default '0' AFTER vid");
$ret[] = update_sql('TRUNCATE {gmap_taxonomy_node}');
// Useful for repopulating in bulk... Copy to hook_enable()?
$ret[] = update_sql("INSERT INTO {gmap_taxonomy_node} (nid, vid, tid, marker) (SELECT n.nid, n.vid, t.tid, g.marker FROM {node_revisions} n INNER JOIN {term_node} t ON n.nid = t.nid INNER JOIN {gmap_taxonomy_term} g ON t.tid = g.tid GROUP BY n.vid ORDER BY NULL)");
break;
case 'pgsql':
// This update will never be needed for pgsql, as it predates pgsql support.
break;
}
return $ret;
}