/[drupal]/contributions/modules/node_style/node_style.install
ViewVC logotype

Contents of /contributions/modules/node_style/node_style.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.10 - (show annotations) (download) (as text)
Thu Feb 8 23:32:04 2007 UTC (2 years, 9 months ago) by karthik
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +5 -5 lines
File MIME type: text/x-php
#117319: Add missing table prefixes.
1 <?php
2 // $Id: node_style.install,v 1.9 2007/02/08 17:51:32 karthik Exp $
3
4 /**
5 * Implementation of hook_install().
6 */
7 function node_style_install() {
8 $ret = array();
9
10 switch ($GLOBALS['db_type']) {
11 case 'mysqli':
12 case 'mysql':
13 db_query("CREATE TABLE {node_style_schemes} (
14 sid int(11) unsigned NOT NULL auto_increment,
15 name varchar(64) NOT NULL default '',
16 variables text NOT NULL,
17 PRIMARY KEY (sid))
18 COMMENT='Node style module: style scheme settings'
19 /*!40100 default CHARACTER SET utf8 */"
20 );
21 db_query("CREATE TABLE {node_style_maps} (
22 nid int(11) unsigned NOT NULL default 0,
23 sid int(11) unsigned NOT NULL default 0,
24 PRIMARY KEY (nid))
25 COMMENT='Node style module: nid to scheme map'
26 /*!40100 default CHARACTER SET utf8 */"
27 );
28 break;
29 case 'pgsql':
30 db_query("CREATE TABLE {node_style_schemes} (
31 sid serial,
32 name varchar(64) NOT NULL default '',
33 variables text NOT NULL,
34 PRIMARY KEY (sid))"
35 );
36 db_query("CREATE TABLE {node_style_maps} (
37 nid integer NOT NULL default 0,
38 sid integer NOT NULL default 0,
39 PRIMARY KEY (nid))"
40 );
41 }
42
43 return $ret;
44 }
45
46 function node_style_update_2() {
47 $ret = array();
48
49 switch ($GLOBALS['db_type']) {
50 case 'mysqli':
51 case 'mysql':
52 $ret[] = update_sql("CREATE TABLE {node_style_schemes} (
53 sid int(11) unsigned NOT NULL auto_increment,
54 name varchar(64) NOT NULL default '',
55 variables text NOT NULL,
56 PRIMARY KEY (sid))
57 COMMENT='Node style module: style scheme settings'
58 /*!40100 default CHARACTER SET utf8 */"
59 );
60 $ret[] = update_sql("CREATE TABLE {node_style_maps} (
61 nid int(11) unsigned NOT NULL default 0,
62 sid int(11) unsigned NOT NULL default 0,
63 PRIMARY KEY (nid))
64 COMMENT='Node style module: nid to scheme map'
65 /*!40100 default CHARACTER SET utf8 */"
66 );
67 break;
68 case 'pgsql':
69 $ret[] = update_sql("CREATE TABLE {node_style_schemes} (
70 sid serial,
71 name varchar(64) NOT NULL default '',
72 variables text NOT NULL,
73 PRIMARY KEY (sid))"
74 );
75 $ret[] = update_sql("CREATE TABLE {node_style_maps} (
76 nid integer NOT NULL default 0,
77 sid integer NOT NULL default 0,
78 PRIMARY KEY (nid))"
79 );
80 break;
81 }
82
83 $result = db_query("SELECT * FROM {node_style}");
84 $sid = 1;
85 while ($style = db_fetch_array($result)) {
86 $name = 'Scheme '. $sid;
87 $ret[] = update_sql("INSERT INTO {node_style_schemes} (sid, name, variables) VALUES ($sid, '$name', '". $style['variables'] ."')");
88 $ret[] = update_sql("INSERT INTO {node_style_maps} (nid, sid) VALUES (". $style['nid'] .", $sid)");
89 $sid++;
90 }
91
92 $ret[] = update_sql("DROP TABLE {node_style}");
93
94 return $ret;
95 }
96
97 /**
98 * Implementation of hook_uninstall().
99 */
100 function node_style_uninstall() {
101 db_query('DROP TABLE {node_style_maps}, {node_style_schemes}');
102 variable_del('node_style_mode');
103 }

  ViewVC Help
Powered by ViewVC 1.1.2