| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @file 4 * Install hooks for Data module. 5 */ 6 7 /** 8 * Implementation of hook_schema(). 9 */ 10 function data_schema() { 11 $schema['data_tables'] = array( 12 'description' => 'Tables managed by Data module.', 13 'export' => array( 14 'key' => 'name', 15 'identifier' => 'data_table', 16 'default hook' => 'data_default', // Function hook name. 17 'api' => array( 18 'owner' => 'data', 19 'api' => 'data_default', // Base name for api include files. 20 'minimum_version' => 1, 21 'current_version' => 1, 22 ), 23 ), 24 'fields' => array( 25 'title' => array( 26 'type' => 'varchar', 27 'length' => '255', 28 'not null' => TRUE, 29 'default' => '', 30 'description' => 'Natural name of the table.', 31 ), 32 'name' => array( 33 'type' => 'varchar', 34 'length' => '128', 35 'not null' => TRUE, 36 'default' => '', 37 'description' => 'Table name.', 38 ), 39 'table_schema' => array( 40 'type' => 'text', 41 'not null' => FALSE, 42 'description' => 'Table schema.', 43 'serialize' => TRUE, 44 ), 45 'meta' => array( 46 'type' => 'text', 47 'not null' => FALSE, 48 'description' => 'Meta information about the table and its fields.', 49 'serialize' => TRUE, 50 ), 51 ), 52 'primary key' => array('name'), 53 ); 54 return $schema; 55 } 56 57 /** 58 * Implementation of hook_install(). 59 */ 60 function data_install() { 61 // Create tables. 62 drupal_install_schema('data'); 63 } 64 65 /** 66 * Implementation of hook_uninstall(). 67 */ 68 function data_uninstall() { 69 // Remove tables. 70 drupal_uninstall_schema('data'); 71 } 72 73 /** 74 * Move join information into meta fields. 75 */ 76 function data_update_6001() { 77 $ret = array(); 78 $result = db_query('SELECT * FROM {data_join}'); 79 while ($row = db_fetch_object($result)) { 80 if ($table = data_get_table($row->right_table)) { 81 $table->link($row->left_table, $row->left_field, $row->right_field, $row->inner_join ? TRUE : FALSE); 82 } 83 } 84 db_drop_table($ret, 'data_join'); 85 return $ret; 86 } 87 88 /** 89 * Add a primary key, required by CTools. Shorten name key to 128 char max. 90 */ 91 function data_update_6002() { 92 $ret = array(); 93 db_drop_index($ret, 'data_tables', 'name'); 94 $spec = array( 95 'type' => 'varchar', 96 'length' => '128', 97 'not null' => TRUE, 98 'default' => '', 99 'description' => 'Table name.', 100 ); 101 db_change_field($ret, 'data_tables', 'name', 'name', $spec); 102 db_add_primary_key($ret, 'data_tables', array('name')); 103 // reset cTools static cache of this table; otherwise it throws an error about 104 // lacking a primary key, which just adds insult to injury as we're trying to fix that! 105 drupal_get_schema('data_tables', TRUE); 106 if (function_exists('ctools_static_reset')) { 107 ctools_static_reset('ctools_export_get_schema'); 108 } 109 return $ret; 110 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |