| 1 |
<?php |
<?php |
| 2 |
// $Id: audio_attach.install,v 1.2 2007/04/08 07:44:40 zirafa Exp $ |
// $Id: audio_attach.install,v 1.3 2007/05/29 18:15:58 zirafa Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_install(). |
* Implementation of hook_install(). |
| 6 |
*/ |
*/ |
| 7 |
function audio_attach_install() { |
function audio_attach_install() { |
| 8 |
switch ($GLOBALS['db_type']) { |
drupal_install_schema('audio_attach'); |
|
case 'mysqli': |
|
|
case 'mysql': |
|
|
db_query(" |
|
|
CREATE TABLE {audio_attach} ( |
|
|
nid int(10) unsigned NOT NULL default '0', |
|
|
aid int(10) unsigned NOT NULL default '0', |
|
|
weight int(10) unsigned NOT NULL default '0', |
|
|
PRIMARY KEY (nid, aid, weight) |
|
|
) /*!40100 DEFAULT CHARACTER SET utf8 */; |
|
|
"); |
|
|
break; |
|
|
case 'pgsql': |
|
|
db_query(" |
|
|
CREATE TABLE {audio_attach} ( |
|
|
nid INTEGER PRIMARY KEY, |
|
|
aid INTEGER NOT NULL DEFAULT 0 |
|
|
weight INTEGER NOT NULL DEFAULT 0 |
|
|
PRIMARY KEY (nid, aid, weight) |
|
|
) |
|
|
"); |
|
|
break; |
|
|
} |
|
| 9 |
} |
} |
| 10 |
|
|
| 11 |
/** |
/** |
| 12 |
* Add column for weight type |
* Implementation of hook_uninstall(). |
| 13 |
*/ |
*/ |
| 14 |
function audio_attach_update_1() { |
function audio_attach_uninstall() { |
| 15 |
$items = array(); |
drupal_uninstall_schema('audio_attach'); |
|
$items[] = update_sql("ALTER TABLE {audio_attach} ADD weight int(10) NOT NULL default '0'"); |
|
|
$items[] = update_sql("ALTER TABLE {audio_attach} DROP PRIMARY KEY, ADD PRIMARY KEY (nid, aid, weight)"); |
|
|
return $items; |
|
| 16 |
} |
} |
| 17 |
|
|
| 18 |
/** |
/** |
| 19 |
* Implementation of hook_uninstall(). |
* Implementation of hook_schema(). |
| 20 |
*/ |
*/ |
| 21 |
function audio_attach_uninstall() { |
function audio_attach_schema() { |
| 22 |
db_query('DROP TABLE {audio_attach}'); |
$schema['audio_attach'] = array( |
| 23 |
|
'description' => t('Attaches an audio node to another node.'), |
| 24 |
|
'fields' => array( |
| 25 |
|
'nid' => array( |
| 26 |
|
'type' => 'int', |
| 27 |
|
'size' => 'medium', |
| 28 |
|
'not null' => TRUE, |
| 29 |
|
), |
| 30 |
|
'aid' => array( |
| 31 |
|
'type' => 'int', |
| 32 |
|
'size' => 'medium', |
| 33 |
|
'not null' => TRUE, |
| 34 |
|
), |
| 35 |
|
'weight' => array( |
| 36 |
|
'type' => 'int', |
| 37 |
|
'size' => 'medium', |
| 38 |
|
'not null' => TRUE, |
| 39 |
|
'default' => 0, |
| 40 |
|
), |
| 41 |
|
), |
| 42 |
|
'primary key' => array('nid', 'aid', 'weight'), |
| 43 |
|
); |
| 44 |
|
return $schema; |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
/** |
| 48 |
|
* Add column for weight type |
| 49 |
|
*/ |
| 50 |
|
function audio_attach_update_1() { |
| 51 |
|
$ret = array(); |
| 52 |
|
db_add_field($ret, 'audio_attach', 'weight', |
| 53 |
|
array( |
| 54 |
|
'type' => 'int', |
| 55 |
|
'size' => 'medium', |
| 56 |
|
'not null' => TRUE, |
| 57 |
|
'default' => 0, |
| 58 |
|
) |
| 59 |
|
); |
| 60 |
|
db_drop_primary_key($ret, 'audio_attach'); |
| 61 |
|
db_add_primary_key($ret, 'audio_attach', array('nid', 'aid', 'weight')); |
| 62 |
|
return $ret; |
| 63 |
} |
} |