- examples
- drupal
Functions & methods
| Name | Description |
|---|---|
| node_example_install | Implementation of hook_install(). |
| node_example_uninstall | Implementation of hook_uninstall(). |
File
developer/examples/node_example.installView source
- <?php
-
- /**
- * Implementation of hook_install().
- */
- function node_example_install() {
- switch ($GLOBALS['db_type']) {
- case 'mysql':
- case 'mysqli':
- db_query("
- CREATE TABLE {node_example} (
- vid int(10) unsigned NOT NULL default '0',
- nid int(10) unsigned NOT NULL default '0',
- color varchar(255) NOT NULL default '',
- quantity int(10) unsigned NOT NULL default '0',
- PRIMARY KEY (vid, nid),
- KEY node_example_nid (nid)
- ) /*!40100 DEFAULT CHARACTER SET utf8 */;
- ");
- break;
- case 'pgsql':
- db_query("
- CREATE TABLE {node_example} (
- vid int NOT NULL default '0',
- nid int NOT NULL default '0',
- color varchar(255) NOT NULL default '',
- quantity int(10) unsigned NOT NULL default '0',
- PRIMARY KEY (vid, nid));
- ");
- db_query("CREATE INDEX {node_example}_nid_idx ON {node_example} (nid)");
- break;
- }
- }
-
- /**
- * Implementation of hook_uninstall().
- */
- function node_example_uninstall() {
- if (db_table_exists('node_example')) {
- db_query("DROP TABLE {node_example}");
- }
- }
-