Projet

Général

Profil

Paste
Télécharger (2,05 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / variable / variable_store / variable_store.install @ 7942932f

1
<?php
2
/**
3
 * @file
4
 * Variable API module install file
5
 */
6

    
7
/**
8
 * Implements hook_install()
9
 */
10
function variable_store_install() {
11
  // Set module weight for it to run before most modules and initialize variable realms
12
  db_query("UPDATE {system} SET weight = -1000 WHERE name = 'variable_store' AND type = 'module'");
13
}
14

    
15
/**
16
 * Implementation of hook_schema().
17
 */
18
function variable_store_schema() {
19
  $schema['variable_store'] = array(
20
    'description' => 'Named variable/value pairs created by modules using Variable API database storage. All variables are cached in memory at the start of every Drupal request so developers should not be careless about what is stored here.',
21
    'fields' => array(
22
      'realm' => array(
23
        'description' => 'The realm domain of this variable.',
24
        'type' => 'varchar',
25
        'length' => 50,
26
        'not null' => TRUE,
27
        'default' => ''),
28
      'realm_key' => array(
29
        'description' => 'The realm key of this variable.',
30
        'type' => 'varchar',
31
        'length' => 50,
32
        'not null' => TRUE,
33
        'default' => ''),
34
      'name' => array(
35
        'description' => 'The name of the variable.',
36
        'type' => 'varchar',
37
        'length' => 128,
38
        'not null' => TRUE,
39
        'default' => ''),
40
      'value' => array(
41
        'description' => 'The value of the variable.',
42
        'type' => 'text',
43
        'not null' => TRUE,
44
        'size' => 'big'),
45
      'serialized' => array(
46
        'description' => 'A flag to indicate whether content is serialized (1) or not (0).',
47
        'type' => 'int',
48
        'size' => 'small',
49
        'not null' => TRUE,
50
        'default' => 1),
51
    ),
52
    'primary key' => array('realm', 'realm_key', 'name'),
53
    'indexes' => array('realm_value' => array('realm', 'realm_key')),
54
  );
55
  return $schema;
56
}
57

    
58
/**
59
 * Reduce realm key field length so it can be used on the primary key
60
 */
61
function variable_store_update_7000() {
62
  $schema = variable_store_schema();
63
  db_change_field('variable_store', 'realm_key', 'realm_key', $schema['variable_store']['fields']['realm_key']);
64
}