| 1 |
<?php |
<?php |
| 2 |
// $Id: interests.install,v 1.3 2007/11/03 04:10:36 auriar Exp $ |
// $Id: $ |
| 3 |
|
|
| 4 |
|
/** |
| 5 |
|
* @file interests.install |
| 6 |
|
* Installation file for interests module |
| 7 |
|
*/ |
| 8 |
|
|
| 9 |
/** |
/** |
| 10 |
* Implementation of hook_install(). |
* Implementation of hook_install(). |
| 11 |
*/ |
*/ |
| 12 |
function interests_install() { |
function interests_install() { |
| 13 |
$status = array(); |
drupal_install_schema('interests'); |
| 14 |
switch ($GLOBALS['db_type']) { |
} |
|
case 'mysql': |
|
|
case 'mysqli': |
|
|
$status[] = db_query("CREATE TABLE {interests} ( |
|
|
uid int(10) unsigned NOT NULL DEFAULT '0', |
|
|
tid int(10) unsigned NOT NULL DEFAULT '0', |
|
|
counter int(10) unsigned NOT NULL DEFAULT '0', |
|
|
PRIMARY KEY (uid,tid) |
|
|
) /*!40100 DEFAULT CHARACTER SET utf8 */;"); |
|
|
$status[] = db_query("CREATE TABLE {interests_vocabs} ( |
|
|
vid int(10) unsigned NOT NULL DEFAULT '0', |
|
|
PRIMARY KEY (vid) |
|
|
) /*!40100 DEFAULT CHARACTER SET utf8 */;"); |
|
|
break; |
|
|
|
|
|
case 'pgsql': |
|
|
$status[] = db_query("CREATE TABLE {interests} ( |
|
|
uid integer NOT NULL DEFAULT '0', |
|
|
tid integer NOT NULL DEFAULT '0', |
|
|
counter integer NOT NULL DEFAULT '0', |
|
|
PRIMARY KEY (uid,tid) |
|
|
);"); |
|
|
$status[] = db_query("CREATE TABLE {interests_vocabs} ( |
|
|
id integer NOT NULL DEFAULT '0', |
|
|
vid integer NOT NULL DEFAULT '0', |
|
|
PRIMARY KEY (vid) |
|
|
);"); |
|
|
break; |
|
|
} |
|
| 15 |
|
|
| 16 |
// If there is one FALSE value in the status array, there was an error. |
/** |
| 17 |
if (array_search(FALSE, $status) !== FALSE) { |
* Implementation of hook_schema(). |
| 18 |
drupal_set_message(t('Table installation for the Interests module was unsuccessful. The tables may need to be installed by hand.'), 'error'); |
*/ |
| 19 |
} |
function interests_schema() { |
| 20 |
else { |
$schema['interests'] = array( |
| 21 |
drupal_set_message(t('Interests module installed successfully.')); |
'fields' => array( |
| 22 |
} |
'uid' => array( |
| 23 |
|
'type' => 'int', |
| 24 |
|
'unsigned' => TRUE, |
| 25 |
|
'not null' => TRUE, |
| 26 |
|
'default' => 0, |
| 27 |
|
), |
| 28 |
|
'tid' => array( |
| 29 |
|
'type' => 'int', |
| 30 |
|
'unsigned' => TRUE, |
| 31 |
|
'not null' => TRUE, |
| 32 |
|
'default' => 0, |
| 33 |
|
), |
| 34 |
|
'counter' => array( |
| 35 |
|
'type' => 'int', |
| 36 |
|
'unsigned' => TRUE, |
| 37 |
|
'not null' => TRUE, |
| 38 |
|
'default' => 0, |
| 39 |
|
), |
| 40 |
|
), |
| 41 |
|
'primary key' => array('uid', 'tid'), |
| 42 |
|
); |
| 43 |
|
|
| 44 |
|
$schema['interests_vocabs'] = array( |
| 45 |
|
'fields' => array( |
| 46 |
|
'vid' => array( |
| 47 |
|
'type' => 'int', |
| 48 |
|
'unsigned' => TRUE, |
| 49 |
|
'not null' => TRUE, |
| 50 |
|
'default' => 0, |
| 51 |
|
), |
| 52 |
|
), |
| 53 |
|
'primary key' => array('vid'), |
| 54 |
|
); |
| 55 |
|
|
| 56 |
|
return $schema; |
| 57 |
} |
} |
| 58 |
|
|
| 59 |
|
/** |
| 60 |
|
* Implementation of hook_update_N(). |
| 61 |
|
*/ |
| 62 |
|
function interests_update_6001() { |
| 63 |
|
$ret = array(); |
| 64 |
|
|
| 65 |
function interests_uninstall(){ |
$schema['interests_vocabs'] = array( |
| 66 |
if (db_table_exists('interests')) { |
'fields' => array( |
| 67 |
db_query("DROP TABLE {interests}"); |
'vid' => array( |
| 68 |
db_query("DROP TABLE {interests_vocabs}"); |
'type' => 'int', |
| 69 |
} |
'unsigned' => TRUE, |
| 70 |
|
'not null' => TRUE, |
| 71 |
|
'default' => 0, |
| 72 |
|
), |
| 73 |
|
), |
| 74 |
|
'primary key' => array('vid'), |
| 75 |
|
); |
| 76 |
|
|
| 77 |
|
if (!db_table_exists('interests_vocabs')) { |
| 78 |
|
db_create_table($ret, 'interests_vocabs', $schema['interests_vocabs']); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
return $ret; |
| 82 |
} |
} |
| 83 |
|
|
| 84 |
|
/** |
| 85 |
|
* Implementation of hook_uninstall(). |
| 86 |
|
*/ |
| 87 |
|
function interests_uninstall() { |
| 88 |
|
drupal_uninstall_schema('interests'); |
| 89 |
|
} |