MDB2_Schema
[ class tree: MDB2_Schema ] [ index: MDB2_Schema ] [ all elements ]

Source for file Parser.php

Documentation is available at Parser.php

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP versions 4 and 5                                                 |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1998-2004 Manuel Lemos, Tomas V.V.Cox,                 |
  6. // | Stig. S. Bakken, Lukas Smith                                         |
  7. // | All rights reserved.                                                 |
  8. // +----------------------------------------------------------------------+
  9. // | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB  |
  10. // | API as well as database abstraction for PHP applications.            |
  11. // | This LICENSE is in the BSD license style.                            |
  12. // |                                                                      |
  13. // | Redistribution and use in source and binary forms, with or without   |
  14. // | modification, are permitted provided that the following conditions   |
  15. // | are met:                                                             |
  16. // |                                                                      |
  17. // | Redistributions of source code must retain the above copyright       |
  18. // | notice, this list of conditions and the following disclaimer.        |
  19. // |                                                                      |
  20. // | Redistributions in binary form must reproduce the above copyright    |
  21. // | notice, this list of conditions and the following disclaimer in the  |
  22. // | documentation and/or other materials provided with the distribution. |
  23. // |                                                                      |
  24. // | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken,    |
  25. // | Lukas Smith nor the names of his contributors may be used to endorse |
  26. // | or promote products derived from this software without specific prior|
  27. // | written permission.                                                  |
  28. // |                                                                      |
  29. // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  |
  30. // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT    |
  31. // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS    |
  32. // | FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE      |
  33. // | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,          |
  34. // | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
  35. // | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
  36. // |  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED  |
  37. // | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT          |
  38. // | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
  39. // | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE          |
  40. // | POSSIBILITY OF SUCH DAMAGE.                                          |
  41. // +----------------------------------------------------------------------+
  42. // | Author: Christian Dickmann <dickmann@php.net>                        |
  43. // +----------------------------------------------------------------------+
  44. //
  45. // $Id: Parser.php,v 1.17 2005/10/10 08:36:04 lsmith Exp $
  46. //
  47.  
  48. require_once 'XML/Parser.php';
  49.  
  50. /**
  51.  * Parses an XML schema file
  52.  *
  53.  * @package MDB2_Schema
  54.  * @category Database
  55.  * @access protected
  56.  * @author  Christian Dickmann <dickmann@php.net>
  57.  */
  58. class MDB2_Schema_Parser extends XML_Parser
  59. {
  60.     var $database_definition = array();
  61.     var $elements = array();
  62.     var $element = '';
  63.     var $count = 0;
  64.     var $table = array();
  65.     var $table_name = '';
  66.     var $field = array();
  67.     var $field_name = '';
  68.     var $init = array();
  69.     var $init_name = '';
  70.     var $init_value = '';
  71.     var $index = array();
  72.     var $index_name = '';
  73.     var $var_mode = false;
  74.     var $variables = array();
  75.     var $seq = array();
  76.     var $seq_name = '';
  77.     var $error;
  78.     var $invalid_names = array(
  79.         'user' => array(),
  80.         'is' => array(),
  81.         'file' => array(
  82.             'oci' => array(),
  83.             'oracle' => array()
  84.         ),
  85.         'notify' => array(
  86.             'pgsql' => array()
  87.         ),
  88.         'restrict' => array(
  89.             'mysql' => array()
  90.         ),
  91.         'password' => array(
  92.             'ibase' => array()
  93.         )
  94.     );
  95.     var $fail_on_invalid_names = true;
  96.     var $structure = false;
  97.  
  98.     function __construct($variables$fail_on_invalid_names = true$structure = false)
  99.     {
  100.         parent::XML_Parser();
  101.         $this->variables = $variables;
  102.         $this->fail_on_invalid_names = $fail_on_invalid_names;
  103.         $this->structure = $structure;
  104.     }
  105.  
  106.     function MDB2_Schema_Parser($variables$fail_on_invalid_names = true$structure = false)
  107.     {
  108.         $this->__construct($variables$fail_on_invalid_names$structure);
  109.     }
  110.  
  111.     function startHandler($xp$element$attribs)
  112.     {
  113.         if (strtolower($element== 'variable'{
  114.             $this->var_mode = true;
  115.             return;
  116.         }
  117.  
  118.         $this->elements[$this->count++strtolower($element);
  119.         $this->element = implode('-'$this->elements);
  120.  
  121.         switch ($this->element{
  122.         case 'database-table-initialization-insert':
  123.             $this->init = array('type' => 'insert');
  124.             break;
  125.         case 'database-table-initialization-insert-field':
  126.             $this->init_name = '';
  127.             $this->init_value = '';
  128.             break;
  129.         case 'database-table':
  130.             $this->table_name = '';
  131.             $this->table = array();
  132.             break;
  133.         case 'database-table-declaration-field':
  134.             $this->field_name = '';
  135.             $this->field = array();
  136.             break;
  137.         case 'database-table-declaration-field-default':
  138.             $this->field['default''';
  139.             break;
  140.         case 'database-table-declaration-index':
  141.             $this->index_name = '';
  142.             $this->index = array();
  143.             break;
  144.         case 'database-sequence':
  145.             $this->seq_name = '';
  146.             $this->seq = array();
  147.             break;
  148.         case 'database-table-declaration-index-field':
  149.             $this->field_name = '';
  150.             $this->field = array();
  151.             break;
  152.         }
  153.     }
  154.  
  155.     function endHandler($xp$element)
  156.     {
  157.         if (strtolower($element== 'variable'{
  158.             $this->var_mode = false;
  159.             return;
  160.         }
  161.  
  162.         switch ($this->element{
  163.         /* Initialization */
  164.         case 'database-table-initialization-insert-field':
  165.             if (!$this->init_name{
  166.                 $this->raiseError('field-name has to be specified'null$xp);
  167.             }
  168.             if (isset($this->init['fields'][$this->init_name])) {
  169.                 $this->raiseError('field "'.$this->init_name.'" already filled'null$xp);
  170.             }
  171.             if (!isset($this->table['fields'][$this->init_name])) {
  172.                 $this->raiseError('unknown field "'.$this->init_name.'"'null$xp);
  173.             }
  174.             if ($this->init_value !== ''
  175.                 && !$this->validateFieldValue($this->init_name$this->init_value$xp)
  176.             {
  177.                 $this->raiseError('field "'.$this->init_name.'" has wrong value'null$xp);
  178.             }
  179.             $this->init['fields'][$this->init_name$this->init_value;
  180.             break;
  181.         case 'database-table-initialization-insert':
  182.             $this->table['initialization'][$this->init;
  183.             break;
  184.  
  185.         /* Table definition */
  186.         case 'database-table':
  187.             if (!array_key_exists('was'$this->table)) {
  188.                 $this->table['was'$this->table_name;
  189.             }
  190.             if (!$this->table_name{
  191.                 $this->raiseError('tables need names'null$xp);
  192.             }
  193.             if (isset($this->database_definition['tables'][$this->table_name])) {
  194.                 $this->raiseError('table "'.$this->table_name.'" already exists'null$xp);
  195.             }
  196.             $primary = false;
  197.             if (!array_key_exists('fields'$this->table)) {
  198.                 $this->raiseError('tables need one or more fields'null$xp);
  199.             else {
  200.                 foreach ($this->table['fields'as $field_name => $field{
  201.                     if (array_key_exists('autoincrement'$field&& $field['autoincrement']{
  202.                         if ($primary{
  203.                             $this->raiseError('there was already an autoincrement field in "'.$this->table_name.'" before "'.$field_name.'"'null$xp);
  204.                         else {
  205.                             $primary = true;
  206.                         }
  207.  
  208.                         if (!$this->table['fields'][$field_name]['notnull']{
  209.                             $this->raiseError('all autoincrement fields must be defined notnull in "'.$this->table_name.'"'null$xp);
  210.                         }
  211.  
  212.                         if (!array_key_exists('default'$field)) {
  213.                             $this->table['fields'][$field_name]['default''0';
  214.                         elseif ($field['default'!== '0'{
  215.                             $this->raiseError('all autoincrement fields must be defined default "0" in "'.$this->table_name.'"'null$xp);
  216.                         }
  217.                     }
  218.                 }
  219.             }
  220.             if (array_key_exists('indexes'$this->table)) {
  221.                 foreach ($this->table['indexes'as $name => $index{
  222.                     if (array_key_exists('primary'$index&& $index['primary']{
  223.                         if ($primary{
  224.                             $this->raiseError('there was already an primary index or autoincrement field in "'.$this->table_name.'" before "'.$name.'"'null$xp);
  225.                         else {
  226.                             $primary = true;
  227.                         }
  228.                     }
  229.                     foreach ($index['fields'as $field_name => $field{
  230.                         if (!isset($this->table['fields'][$field_name])) {
  231.                             $this->raiseError('index field "'.$field_name.'" does not exist'null$xp);
  232.                         elseif (array_key_exists('primary'$index&& $index['primary']{
  233.                             if(!$this->table['fields'][$field_name]['notnull']{
  234.                                 $this->raiseError('all primary key fields must be defined notnull in "'.$this->table_name.'"'null$xp);
  235.                             }
  236.                         }
  237.                     }
  238.                 }
  239.             }
  240.             $this->database_definition['tables'][$this->table_name$this->table;
  241.             break;
  242.  
  243.         /* Field declaration */
  244.         case 'database-table-declaration-field':
  245.             if (!$this->field_name || !array_key_exists('type'$this->field)) {
  246.                 $this->raiseError('field "'.$this->field_name.'" was not properly specified'null$xp);
  247.             }
  248.             if (isset($this->table['fields'][$this->field_name])) {
  249.                 $this->raiseError('field "'.$this->field_name.'" already exists'null$xp);
  250.             }
  251.             /* Invalidname check */
  252.             if ($this->fail_on_invalid_names && isset($this->invalid_names[$this->field_name])) {
  253.                 $this->raiseError('fieldname "'.$this->field_name.'" not allowed'null$xp);
  254.             }
  255.             /* Type check */
  256.             switch ($this->field['type']{
  257.             case 'integer':
  258.                 if (array_key_exists('unsigned'$this->field&& !$this->isBoolean($this->field['unsigned'])) {
  259.                     $this->raiseError('unsigned has to be a boolean value'null$xp);
  260.                 }
  261.             case 'text':
  262.             case 'clob':
  263.             case 'blob':
  264.                 if (array_key_exists('length'$this->field&& ((int)$this->field['length']<= 0{
  265.                     $this->raiseError('length has to be an integer greater 0'null$xp);
  266.                 }
  267.                 break;
  268.             case 'boolean':
  269.             case 'date':
  270.             case 'timestamp':
  271.             case 'time':
  272.             case 'float':
  273.             case 'decimal':
  274.                 break;
  275.             default:
  276.                 $this->raiseError('no valid field type ("'.$this->field['type'].'") specified'null$xp);
  277.             }
  278.             if (!array_key_exists('was'$this->field)) {
  279.                 $this->field['was'$this->field_name;
  280.             }
  281.  
  282.             if (!array_key_exists('notnull'$this->field)) {
  283.                 $this->field['notnull'= true;
  284.             }
  285.  
  286.             if (!$this->isBoolean($this->field['notnull'])) {
  287.                 $this->raiseError('field "notnull" has to be a boolean value'null$xp);
  288.             }
  289.             if (!array_key_exists('default'$this->field)
  290.                 && $this->field['type'!= 'clob' && $this->field['type'!= 'blob'
  291.             {
  292.                 $this->field['default''';
  293.             }
  294.             if (array_key_exists('unsigned'$this->field&& !$this->isBoolean($this->field['unsigned'])) {
  295.                 $this->raiseError('field "unsigned" has to be a boolean value'null$xp);
  296.             }
  297.  
  298.             if (array_key_exists('default'$this->field)) {
  299.                 if ($this->field['type'== 'clob' || $this->field['type'== 'blob'{
  300.                     $this->raiseError('"'.$this->field['type'].
  301.                         '"-fields are not allowed to have a default value'null$xp);
  302.                 }
  303.                 if ($this->field['default'=== ''{
  304.                     if (!$this->field['notnull']{
  305.                         $this->field['default'= null;
  306.                     }
  307.                 }
  308.             }
  309.  
  310.             $this->table['fields'][$this->field_name$this->field;
  311.  
  312.             if (array_key_exists('default'$this->field&& !empty($this->field['default'])
  313.                 && !$this->validateFieldValue($this->field_name$this->field['default']$xp)
  314.             {
  315.                 $this->raiseError('default value of "'.$this->field_name.'" is of wrong type'null$xp);
  316.             }
  317.             break;
  318.  
  319.         /* Index declaration */
  320.         case 'database-table-declaration-index':
  321.             if (!$this->index_name{
  322.                 $this->raiseError('an index needs a name'null$xp);
  323.             }
  324.             if (isset($this->table['indexes'][$this->index_name])) {
  325.                 $this->raiseError('index "'.$this->index_name.'" already exists'null$xp);
  326.             }
  327.             if (array_key_exists('unique'$this->index&& !$this->isBoolean($this->index['unique'])) {
  328.                 $this->raiseError('field "unique" has to be a boolean value'null$xp);
  329.             }
  330.             if (array_key_exists('primary'$this->index&& !$this->isBoolean($this->index['primary'])) {
  331.                 $this->raiseError('field "primary" has to be a boolean value'null$xp);
  332.             }
  333.  
  334.             if (!array_key_exists('was'$this->index)) {
  335.                 $this->index['was'$this->index_name;
  336.             }
  337.             $this->table['indexes'][$this->index_name$this->index;
  338.             break;
  339.         case 'database-table-declaration-index-field':
  340.             if (!$this->field_name{
  341.                 $this->raiseError('the index-field-name is required'null$xp);
  342.             }
  343.             if (array_key_exists('sorting'$this->field)
  344.                 && $this->field['sorting'!== 'ascending' && $this->field['sorting'!== 'descending'{
  345.                 $this->raiseError('sorting type unknown'null$xp);
  346.             else {
  347.                 $this->field['sorting''ascending';
  348.             }
  349.             $this->index['fields'][$this->field_name$this->field;
  350.             break;
  351.         case 'database-table-name':
  352.             if (isset($this->structure['tables'][$this->table_name])) {
  353.                 $this->table = $this->structure['tables'][$this->table_name];
  354.             }
  355.             break;
  356.  
  357.         /* Sequence declaration */
  358.         case 'database-sequence':
  359.             if (!$this->seq_name{
  360.                 $this->raiseError('a sequence has to have a name'null$xp);
  361.             }
  362.             if (isset($this->database_definition['sequences'][$this->seq_name])) {
  363.                 $this->raiseError('sequence "'.$this->seq_name.'" already exists'null$xp);
  364.             }
  365.  
  366.             if (!array_key_exists('was'$this->seq)) {
  367.                 $this->seq['was'$this->seq_name;
  368.             }
  369.  
  370.             if (array_key_exists('on'$this->seq)) {
  371.                 if ((!isset($this->seq['on']['table']|| !$this->seq['on']['table'])
  372.                     || (!isset($this->seq['on']['field']|| !$this->seq['on']['field'])
  373.                 {
  374.                     $this->raiseError('sequence "'.$this->seq_name.
  375.                         '" was not properly defined'null$xp);
  376.                 }
  377.             }
  378.             $this->database_definition['sequences'][$this->seq_name$this->seq;
  379.             break;
  380.  
  381.         /* End of File */
  382.         case 'database':
  383.             if (isset($this->database_definition['create'])
  384.                 && !$this->isBoolean($this->database_definition['create'])
  385.             {
  386.                 $this->raiseError('field "create" has to be a boolean value'null$xp);
  387.             }
  388.             if (isset($this->database_definition['overwrite'])
  389.                 && !$this->isBoolean($this->database_definition['overwrite'])
  390.             {
  391.                 $this->raiseError('field "overwrite" has to be a boolean value'null$xp);
  392.             }
  393.             if (!isset($this->database_definition['name'])
  394.                 || !$this->database_definition['name']
  395.             {
  396.                 $this->raiseError('database needs a name'null$xp);
  397.             }
  398.             if (isset($this->database_definition['sequences'])) {
  399.                 foreach ($this->database_definition['sequences'as $seq_name => $seq{
  400.                     if (array_key_exists('on'$seq)
  401.                         && !isset($this->database_definition['tables'][$seq['on']['table']]['fields'][$seq['on']['field']])
  402.                     {
  403.                         $this->raiseError('sequence "'.$seq_name.
  404.                             '" was assigned on unexisting field/table'null$xp);
  405.                     }
  406.                 }
  407.             }
  408.             if (PEAR::isError($this->error)) {
  409.                 $this->database_definition = $this->error;
  410.             }
  411.             break;
  412.         }
  413.  
  414.         unset($this->elements[--$this->count]);
  415.         $this->element = implode('-'$this->elements);
  416.     }
  417.  
  418.     function validateFieldValue($field_name&$field_value&$xp)
  419.     {
  420.         if (!isset($this->table['fields'][$field_name])) {
  421.             return $this->raiseError('"'.$field_name.'" is not defined'null$xp);
  422.         }
  423.         $field_def $this->table['fields'][$field_name];
  424.         switch ($field_def['type']{
  425.         case 'text':
  426.         case 'clob':
  427.             if (array_key_exists('length'$field_def&& strlen($field_value$field_def['length']{
  428.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  429.                     $field_def['type'].'"'null$xp);
  430.             }
  431.             break;
  432.         case 'blob':
  433.             /*
  434.             if (!preg_match('/^([0-9a-f]{2})*$/i', $field_value)) {
  435.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  436.                     $field_def['type'].'"', null, $xp);
  437.             }
  438.             */
  439.             $field_value pack('H*'$field_value);
  440.             if (array_key_exists('length'$field_def&& strlen($field_value$field_def['length']{
  441.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  442.                     $field_def['type'].'"'null$xp);
  443.             }
  444.             break;
  445.         case 'integer':
  446.             if ($field_value != ((int)$field_value)) {
  447.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  448.                     $field_def['type'].'"'null$xp);
  449.             }
  450.             $field_value = (int) $field_value;
  451.             if (array_key_exists('unsigned'$field_def&& $field_def['unsigned'&& $field_value < 0{
  452.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  453.                     $field_def['type'].'"'null$xp);
  454.             }
  455.             break;
  456.         case 'boolean':
  457.             if (!$this->isBoolean($field_value)) {
  458.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  459.                     $field_def['type'].'"'null$xp);
  460.             }
  461.             break;
  462.         case 'date':
  463.             if (!preg_match('/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/'$field_value)) {
  464.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  465.                     $field_def['type'].'"'null$xp);
  466.             }
  467.             break;
  468.         case 'timestamp':
  469.             if (!preg_match('/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})/'$field_value)) {
  470.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  471.                     $field_def['type'].'"'null$xp);
  472.             }
  473.             break;
  474.         case 'time':
  475.             if (!preg_match("/([0-9]{2}):([0-9]{2}):([0-9]{2})/"$field_value)) {
  476.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  477.                     $field_def['type'].'"'null$xp);
  478.             }
  479.             break;
  480.         case 'float':
  481.         case 'double':
  482.             if ($field_value != (double) $field_value{
  483.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  484.                     $field_def['type'].'"'null$xp);
  485.             }
  486.             $field_value = (double) $field_value;
  487.             break;
  488.         }
  489.         return true;
  490.     }
  491.  
  492.     function &raiseError($msg = null$ecode = 0$xp = null)
  493.     {
  494.         if (is_null($this->error)) {
  495.             $error '';
  496.             if (is_resource($msg)) {
  497.                 $error .= 'Parser error: '.xml_error_string(xml_get_error_code($msg));
  498.                 $xp $msg;
  499.             else {
  500.                 $error .= 'Parser error: '.$msg;
  501.                 if (!is_resource($xp)) {
  502.                     $xp $this->parser;
  503.                 }
  504.             }
  505.             if ($error_string xml_error_string($ecode)) {
  506.                 $error .= ' - '.$error_string;
  507.             }
  508.             if (is_resource($xp)) {
  509.                 $byte @xml_get_current_byte_index($xp);
  510.                 $line @xml_get_current_line_number($xp);
  511.                 $column @xml_get_current_column_number($xp);
  512.                 $error .= " - Byte: $byte; Line: $line; Col: $column";
  513.             }
  514.             $error .= "\n";
  515.             $this->error =MDB2::raiseError(MDB2_SCHEMA_ERROR_PARSEnullnull$error);
  516.         }
  517.         return $this->error;
  518.     }
  519.  
  520.     function isBoolean(&$value)
  521.     {
  522.         if (is_int($value&& ($value == 0 || $value == 1)) {
  523.             return true;
  524.         }
  525.         if ($value === '1' || $value === '0'{
  526.             $value = (int) $value;
  527.             return true;
  528.         }
  529.         switch ($value{
  530.         case 'N':
  531.         case 'n':
  532.         case 'no':
  533.         case 'false':
  534.             $value = false;
  535.             break;
  536.         case 'Y':
  537.         case 'y':
  538.         case 'yes':
  539.         case 'true':
  540.             $value = true;
  541.             break;
  542.         default:
  543.             return false;
  544.         }
  545.         return true;
  546.     }
  547.  
  548.     function cdataHandler($xp$data)
  549.     {
  550.         if ($this->var_mode == true{
  551.             if (!isset($this->variables[$data])) {
  552.                 $this->raiseError('variable "'.$data.'" not found'null$xp);
  553.                 return;
  554.             }
  555.             $data $this->variables[$data];
  556.         }
  557.  
  558.         switch ($this->element{
  559.         /* Initialization */
  560.         case 'database-table-initialization-insert-field-name':
  561.             if (isset($this->init_name)) {
  562.                 $this->init_name .= $data;
  563.             else {
  564.                 $this->init_name = $data;
  565.             }
  566.             break;
  567.         case 'database-table-initialization-insert-field-value':
  568.             if (isset($this->init_value)) {
  569.                 $this->init_value .= $data;
  570.             else {
  571.                 $this->init_value = $data;
  572.             }
  573.             break;
  574.  
  575.         /* Database */
  576.         case 'database-name':
  577.             if (isset($this->database_definition['name'])) {
  578.                 $this->database_definition['name'.= $data;
  579.             else {
  580.                 $this->database_definition['name'$data;
  581.             }
  582.             break;
  583.         case 'database-create':
  584.             if (isset($this->database_definition['create'])) {
  585.                 $this->database_definition['create'.= $data;
  586.             else {
  587.                 $this->database_definition['create'$data;
  588.             }
  589.             break;
  590.         case 'database-overwrite':
  591.             if (isset($this->database_definition['overwrite'])) {
  592.                 $this->database_definition['overwrite'.= $data;
  593.             else {
  594.                 $this->database_definition['overwrite'$data;
  595.             }
  596.             break;
  597.         case 'database-table-name':
  598.             if (isset($this->table_name)) {
  599.                 $this->table_name .= $data;
  600.             else {
  601.                 $this->table_name = $data;
  602.             }
  603.             break;
  604.         case 'database-table-was':
  605.             if (array_key_exists('was'$this->table)) {
  606.                 $this->table['was'.= $data;
  607.             else {
  608.                 $this->table['was'$data;
  609.             }
  610.             break;
  611.  
  612.         /* Field declaration */
  613.         case 'database-table-declaration-field-name':
  614.             if (isset($this->field_name)) {
  615.                 $this->field_name .= $data;
  616.             else {
  617.                 $this->field_name = $data;
  618.             }
  619.             break;
  620.         case 'database-table-declaration-field-type':
  621.             if (array_key_exists('type'$this->field)) {
  622.                 $this->field['type'.= $data;
  623.             else {
  624.                 $this->field['type'$data;
  625.             }
  626.             break;
  627.         case 'database-table-declaration-field-was':
  628.             if (array_key_exists('was'$this->field)) {
  629.                 $this->field['was'.= $data;
  630.             else {
  631.                 $this->field['was'$data;
  632.             }
  633.             break;
  634.         case 'database-table-declaration-field-notnull':
  635.             if (array_key_exists('notnull'$this->field)) {
  636.                 $this->field['notnull'.= $data;
  637.             else {
  638.                 $this->field['notnull'$data;
  639.             }
  640.             break;
  641.         case 'database-table-declaration-field-unsigned':
  642.             if (array_key_exists('unsigned'$this->field)) {
  643.                 $this->field['unsigned'.= $data;
  644.             else {
  645.                 $this->field['unsigned'$data;
  646.             }
  647.             break;
  648.         case 'database-table-declaration-field-autoincrement':
  649.             if (array_key_exists('autoincrement'$this->field)) {
  650.                 $this->field['autoincrement'.= $data;
  651.             else {
  652.                 $this->field['autoincrement'$data;
  653.             }
  654.             break;
  655.         case 'database-table-declaration-field-default':
  656.             if (array_key_exists('default'$this->field)) {
  657.                 $this->field['default'.= $data;
  658.             else {
  659.                 $this->field['default'$data;
  660.             }
  661.             break;
  662.         case 'database-table-declaration-field-length':
  663.             if (array_key_exists('length'$this->field)) {
  664.                 $this->field['length'.= $data;
  665.             else {
  666.                 $this->field['length'$data;
  667.             }
  668.             break;
  669.  
  670.         /* Index declaration */
  671.         case 'database-table-declaration-index-name':
  672.             if (isset($this->index_name)) {
  673.                 $this->index_name .= $data;
  674.             else {
  675.                 $this->index_name = $data;
  676.             }
  677.             break;
  678.         case 'database-table-declaration-index-primary':
  679.             if (array_key_exists('primary'$this->index)) {
  680.                 $this->index['primary'.= $data;
  681.             else {
  682.                 $this->index['primary'$data;
  683.             }
  684.             break;
  685.         case 'database-table-declaration-index-unique':
  686.             if (array_key_exists('unique'$this->index)) {
  687.                 $this->index['unique'.= $data;
  688.             else {
  689.                 $this->index['unique'$data;
  690.             }
  691.             break;
  692.         case 'database-table-declaration-index-was':
  693.             if (array_key_exists('was'$this->index)) {
  694.                 $this->index['was'.= $data;
  695.             else {
  696.                 $this->index['was'$data;
  697.             }
  698.             break;
  699.         case 'database-table-declaration-index-field-name':
  700.             if (isset($this->field_name)) {
  701.                 $this->field_name .= $data;
  702.             else {
  703.                 $this->field_name = $data;
  704.             }
  705.             break;
  706.         case 'database-table-declaration-index-field-sorting':
  707.             if (array_key_exists('sorting'$this->field)) {
  708.                 $this->field['sorting'.= $data;
  709.             else {
  710.                 $this->field['sorting'$data;
  711.             }
  712.             break;
  713.  
  714.         /* Sequence declaration */
  715.         case 'database-sequence-name':
  716.             if (isset($this->seq_name)) {
  717.                 $this->seq_name .= $data;
  718.             else {
  719.                 $this->seq_name = $data;
  720.             }
  721.             break;
  722.         case 'database-sequence-was':
  723.             if (array_key_exists('was'$this->seq)) {
  724.                 $this->seq['was'.= $data;
  725.             else {
  726.                 $this->seq['was'$data;
  727.             }
  728.             break;
  729.         case 'database-sequence-start':
  730.             if (array_key_exists('start'$this->seq)) {
  731.                 $this->seq['start'.= $data;
  732.             else {
  733.                 $this->seq['start'$data;
  734.             }
  735.             break;
  736.         case 'database-sequence-on-table':
  737.             if (isset($this->seq['on']['table'])) {
  738.                 $this->seq['on']['table'.= $data;
  739.             else {
  740.                 $this->seq['on']['table'$data;
  741.             }
  742.             break;
  743.         case 'database-sequence-on-field':
  744.             if (isset($this->seq['on']['field'])) {
  745.                 $this->seq['on']['field'.= $data;
  746.             else {
  747.                 $this->seq['on']['field'$data;
  748.             }
  749.             break;
  750.         }
  751.     }
  752. }
  753.  
  754. ?>

Documentation generated on Mon, 11 Mar 2019 14:13:18 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.