aboutsummaryrefslogtreecommitdiff
path: root/classes/SchemaDb.php
blob: 2756026cb91eed278b032fddfeff0aeb5c1c90bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php

class SchemaDb {
  /**
   * Return the required database config.
   *
   * @return
   *   Array with required config.
   */
  public function required() {
    $schema = array(
      'db'             => array(
        'name'         => 'dbname',
      ),
      'fields'         => array(
      ),
    );

    return $schema;
  }

  /**
   * Return the optional database config.
   *
   * @return
   *   Array with optional config.
   */  
  public function optional() {
    $schema   = array(
      'db'             => array(
        'charset'      => 'charset',
      ),
    );

    return $schema;
  }

  /**
   * Return an example schema.
   *
   * @see IsisDb::example()
   */    
  public function example() {
    $required = SchemaDb::required();
    $optional = SchemaDb::optional();
    $schema   = array(
      'db'             => array(
        'charset'      => 'charset',
      ),
      'fields'         => array(
        1              => array(
          'name'       => 'field_name',
          'size'       => 1000,
          'format'     => 'numeric',
          'repeat'     => TRUE,
          'subfields'  => array(
            'a'        => 'test',
            'b'        => 'test2',
          ),
        ),
      ),
    );

    return array_merge_recursive($required, $optional, $schema);
  }

  /**
   * Check required fields.
   *
   * @todo
   */
  function check($schema = NULL) {
    return $schema;
  }
}