| 1 |
<?php |
<?php |
| 2 |
// $Id: nodevote.install,v 1.5.2.1 2007/05/08 01:56:18 kbahey Exp $ |
/** |
| 3 |
|
* Implementation of hook_install(). |
| 4 |
|
*/ |
| 5 |
function nodevote_install() { |
function nodevote_install() { |
| 6 |
switch ($GLOBALS['db_type']) { |
drupal_install_schema('nodevote'); |
|
case 'mysqli': |
|
|
case 'mysql': |
|
|
$query = db_query(" |
|
|
CREATE TABLE {nodevote} ( |
|
|
uid int(10) NOT NULL default '0', |
|
|
nid int(10) NOT NULL default '0', |
|
|
vote int(2) NOT NULL default '0', |
|
|
timestamp int(11) NOT NULL default '0', |
|
|
PRIMARY KEY (uid, nid), |
|
|
KEY node_id (nid), |
|
|
KEY user_id (uid) |
|
|
) /*!40100 DEFAULT CHARACTER SET utf8 */;"); |
|
|
|
|
|
break; |
|
|
|
|
|
case 'pgsql': |
|
|
$query = db_query("CREATE TABLE {nodevote} ( |
|
|
uid int NOT NULL default '0', |
|
|
nid int NOT NULL default '0', |
|
|
vote int NOT NULL default '0', |
|
|
timestamp int NOT NULL default '0', |
|
|
PRIMARY KEY (uid, nid) |
|
|
)"); |
|
|
db_query("CREATE INDEX {nodevote}_node_id_idx ON {nodevote} (nid)"); |
|
|
db_query("CREATE INDEX {nodevote}_user_id_idx ON {nodevote} (uid)"); |
|
|
break; |
|
|
} |
|
| 7 |
} |
} |
| 8 |
|
|
| 9 |
|
/** |
| 10 |
|
* Implementation of hook_schema(). |
| 11 |
|
*/ |
| 12 |
|
function nodevote_schema() { |
| 13 |
|
$schema = array(); |
| 14 |
|
$schema['nodevote'] = array( |
| 15 |
|
'description' => t('Stores the users\' votes about a node'), |
| 16 |
|
'fields' => array( |
| 17 |
|
'uid' => array( |
| 18 |
|
'description' => t('User ID'), |
| 19 |
|
'type' => 'int', |
| 20 |
|
'unsigned' => TRUE, |
| 21 |
|
'not null' => TRUE, |
| 22 |
|
), |
| 23 |
|
'nid' => array( |
| 24 |
|
'description' => t('Node ID'), |
| 25 |
|
'type' => 'int', |
| 26 |
|
'unsigned' => TRUE, |
| 27 |
|
'not null' => TRUE, |
| 28 |
|
), |
| 29 |
|
'vote' => array( |
| 30 |
|
'description' => t('Amount'), |
| 31 |
|
'type' => 'int', |
| 32 |
|
'unsigned' => TRUE, |
| 33 |
|
'not null' => TRUE, |
| 34 |
|
), |
| 35 |
|
'timestamp' => array( |
| 36 |
|
'description' => t('Timestamp'), |
| 37 |
|
'type' => 'int', |
| 38 |
|
'length' => 2, |
| 39 |
|
'unsigned' => TRUE, |
| 40 |
|
'not null' => TRUE, |
| 41 |
|
), |
| 42 |
|
), |
| 43 |
|
'primary key' => array('uid', 'nid'), |
| 44 |
|
'indexes' => array('node_nid' => array('nid'), 'user_id' => array('uid')), |
| 45 |
|
); |
| 46 |
|
return $schema; |
| 47 |
|
} |
| 48 |
|
|
| 49 |
function nodevote_update_1() { |
function nodevote_update_1() { |
| 50 |
return _system_update_utf8(array('nodevote')); |
return _system_update_utf8(array('nodevote')); |
| 52 |
|
|
| 53 |
function nodevote_update_2() { |
function nodevote_update_2() { |
| 54 |
$ret = array(); |
$ret = array(); |
| 55 |
switch ($GLOBALS['db_type']) { |
$ret[] = update_sql("ALTER TABLE {nodevote} ADD COLUMN timestamp int(11) NOT NULL default '0'"); |
|
case 'mysqli': |
|
|
case 'mysql': |
|
|
$ret = update_sql("ALTER TABLE {nodevote} ADD COLUMN timestamp int(11) NOT NULL default '0'"); |
|
|
break; |
|
|
} |
|
| 56 |
|
|
| 57 |
return $ret; |
return $ret; |
| 58 |
} |
} |
| 59 |
|
|
| 60 |
function nodevote_uninstall () { |
/** |
| 61 |
db_query('DROP TABLE {nodevote}'); |
* Implementation of hook_uninstall(). |
| 62 |
|
*/ |
| 63 |
|
function nodevote_uninstall() { |
| 64 |
|
drupal_uninstall_schema('nodevote'); |
| 65 |
} |
} |
| 66 |
|
|