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.20 2005/10/29 11:26:35 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.  
  191.             if (!$this->table_name{
  192.                 $this->raiseError('tables need names'null$xp);
  193.             }
  194.  
  195.             if (isset($this->database_definition['tables'][$this->table_name])) {
  196.                 $this->raiseError('table "'.$this->table_name.'" already exists'null$xp);
  197.             }
  198.  
  199.             $autoinc $primary = false;
  200.             if (!array_key_exists('fields'$this->table)) {
  201.                 $this->raiseError('tables need one or more fields'null$xp);
  202.             else {
  203.                 foreach ($this->table['fields'as $field_name => $field{
  204.                     if (array_key_exists('autoincrement'$field&& $field['autoincrement']{
  205.                         if ($primary{
  206.                             $this->raiseError('there was already an autoincrement field in "'.$this->table_name.'" before "'.$field_name.'"'null$xp);
  207.                         else {
  208.                             $autoinc $primary = true;
  209.                         }
  210.  
  211.                         if (!$this->table['fields'][$field_name]['notnull']{
  212.                             $this->raiseError('all autoincrement fields must be defined notnull in "'.$this->table_name.'"'null$xp);
  213.                         }
  214.  
  215.                         if (!array_key_exists('default'$field)) {
  216.                             $this->table['fields'][$field_name]['default''0';
  217.                         elseif ($field['default'!== '0'{
  218.                             $this->raiseError('all autoincrement fields must be defined default "0" in "'.$this->table_name.'"'null$xp);
  219.                         }
  220.                     }
  221.                 }
  222.             }
  223.             if (array_key_exists('indexes'$this->table)) {
  224.                 foreach ($this->table['indexes'as $name => $index{
  225.                     $skip_index = false;
  226.                     if (array_key_exists('primary'$index&& $index['primary']{
  227.                         /*
  228.                          * Lets see if we should skip this index since there is
  229.                          * already a auto increment on this field this implying
  230.                          * a primary key index.
  231.                          */
  232.                         if ($autoinc && count($index['fields']== '1'{
  233.                             $skip_index = true;
  234.                         else {
  235.                             if ($primary{
  236.                                 $this->raiseError('there was already an primary index or autoincrement field in "'.$this->table_name.'" before "'.$name.'"'null$xp);
  237.                             else {
  238.                                 $primary = true;
  239.                             }
  240.                         }
  241.                     }
  242.  
  243.                     if (!$skip_index{
  244.                         foreach ($index['fields'as $field_name => $field{
  245.                             if (!isset($this->table['fields'][$field_name])) {
  246.                                 $this->raiseError('index field "'.$field_name.'" does not exist'null$xp);
  247.                             elseif (array_key_exists('primary'$index&& $index['primary']{
  248.                                 if (!$this->table['fields'][$field_name]['notnull']{
  249.                                     $this->raiseError('all primary key fields must be defined notnull in "'.$this->table_name.'"'null$xp);
  250.                                 }
  251.                             }
  252.                         }
  253.                     else {
  254.                         unset($this->table['indexes'][$name]);
  255.                     }
  256.                 }
  257.             }
  258.             $this->database_definition['tables'][$this->table_name$this->table;
  259.             break;
  260.  
  261.         /* Field declaration */
  262.         case 'database-table-declaration-field':
  263.             if (!$this->field_name || !array_key_exists('type'$this->field)) {
  264.                 $this->raiseError('field "'.$this->field_name.'" was not properly specified'null$xp);
  265.             }
  266.             if (isset($this->table['fields'][$this->field_name])) {
  267.                 $this->raiseError('field "'.$this->field_name.'" already exists'null$xp);
  268.             }
  269.             /* Invalidname check */
  270.             if ($this->fail_on_invalid_names && isset($this->invalid_names[$this->field_name])) {
  271.                 $this->raiseError('fieldname "'.$this->field_name.'" not allowed'null$xp);
  272.             }
  273.             /* Type check */
  274.             switch ($this->field['type']{
  275.             case 'integer':
  276.                 if (array_key_exists('unsigned'$this->field&& !$this->isBoolean($this->field['unsigned'])) {
  277.                     $this->raiseError('unsigned has to be a boolean value'null$xp);
  278.                 }
  279.             case 'text':
  280.             case 'clob':
  281.             case 'blob':
  282.                 if (array_key_exists('length'$this->field&& ((int)$this->field['length']<= 0{
  283.                     $this->raiseError('length has to be an integer greater 0'null$xp);
  284.                 }
  285.                 break;
  286.             case 'boolean':
  287.             case 'date':
  288.             case 'timestamp':
  289.             case 'time':
  290.             case 'float':
  291.             case 'decimal':
  292.                 break;
  293.             default:
  294.                 $this->raiseError('no valid field type ("'.$this->field['type'].'") specified'null$xp);
  295.             }
  296.             if (!array_key_exists('was'$this->field)) {
  297.                 $this->field['was'$this->field_name;
  298.             }
  299.  
  300.             if (!array_key_exists('notnull'$this->field)) {
  301.                 $this->field['notnull'= true;
  302.             }
  303.  
  304.             if (!$this->isBoolean($this->field['notnull'])) {
  305.                 $this->raiseError('field "notnull" has to be a boolean value'null$xp);
  306.             }
  307.             if (!array_key_exists('default'$this->field)
  308.                 && $this->field['type'!= 'clob' && $this->field['type'!= 'blob'
  309.             {
  310.                 $this->field['default''';
  311.             }
  312.             if (array_key_exists('unsigned'$this->field&& !$this->isBoolean($this->field['unsigned'])) {
  313.                 $this->raiseError('field "unsigned" has to be a boolean value'null$xp);
  314.             }
  315.  
  316.             if (array_key_exists('default'$this->field)) {
  317.                 if ($this->field['type'== 'clob' || $this->field['type'== 'blob'{
  318.                     $this->raiseError('"'.$this->field['type'].
  319.                         '"-fields are not allowed to have a default value'null$xp);
  320.                 }
  321.                 if ($this->field['default'=== ''{
  322.                     if (!$this->field['notnull']{
  323.                         $this->field['default'= null;
  324.                     }
  325.                 }
  326.             }
  327.  
  328.             $this->table['fields'][$this->field_name$this->field;
  329.  
  330.             if (array_key_exists('default'$this->field&& !empty($this->field['default'])
  331.                 && !$this->validateFieldValue($this->field_name$this->field['default']$xp)
  332.             {
  333.                 $this->raiseError('default value of "'.$this->field_name.'" is of wrong type'null$xp);
  334.             }
  335.             break;
  336.  
  337.         /* Index declaration */
  338.         case 'database-table-declaration-index':
  339.             if (!$this->index_name{
  340.                 $this->raiseError('an index needs a name'null$xp);
  341.             }
  342.             if (isset($this->table['indexes'][$this->index_name])) {
  343.                 $this->raiseError('index "'.$this->index_name.'" already exists'null$xp);
  344.             }
  345.             if (array_key_exists('unique'$this->index&& !$this->isBoolean($this->index['unique'])) {
  346.                 $this->raiseError('field "unique" has to be a boolean value'null$xp);
  347.             }
  348.             if (array_key_exists('primary'$this->index&& !$this->isBoolean($this->index['primary'])) {
  349.                 $this->raiseError('field "primary" has to be a boolean value'null$xp);
  350.             }
  351.  
  352.             if (!array_key_exists('was'$this->index)) {
  353.                 $this->index['was'$this->index_name;
  354.             }
  355.             $this->table['indexes'][$this->index_name$this->index;
  356.             break;
  357.         case 'database-table-declaration-index-field':
  358.             if (!$this->field_name{
  359.                 $this->raiseError('the index-field-name is required'null$xp);
  360.             }
  361.             if (array_key_exists('sorting'$this->field)
  362.                 && $this->field['sorting'!== 'ascending' && $this->field['sorting'!== 'descending'{
  363.                 $this->raiseError('sorting type unknown'null$xp);
  364.             else {
  365.                 $this->field['sorting''ascending';
  366.             }
  367.             $this->index['fields'][$this->field_name$this->field;
  368.             break;
  369.         case 'database-table-name':
  370.             if (isset($this->structure['tables'][$this->table_name])) {
  371.                 $this->table = $this->structure['tables'][$this->table_name];
  372.             }
  373.             break;
  374.  
  375.         /* Sequence declaration */
  376.         case 'database-sequence':
  377.             if (!$this->seq_name{
  378.                 $this->raiseError('a sequence has to have a name'null$xp);
  379.             }
  380.             if (isset($this->database_definition['sequences'][$this->seq_name])) {
  381.                 $this->raiseError('sequence "'.$this->seq_name.'" already exists'null$xp);
  382.             }
  383.  
  384.             if (!array_key_exists('was'$this->seq)) {
  385.                 $this->seq['was'$this->seq_name;
  386.             }
  387.  
  388.             if (array_key_exists('on'$this->seq)) {
  389.                 if ((!isset($this->seq['on']['table']|| !$this->seq['on']['table'])
  390.                     || (!isset($this->seq['on']['field']|| !$this->seq['on']['field'])
  391.                 {
  392.                     $this->raiseError('sequence "'.$this->seq_name.
  393.                         '" was not properly defined'null$xp);
  394.                 }
  395.             }
  396.             $this->database_definition['sequences'][$this->seq_name$this->seq;
  397.             break;
  398.  
  399.         /* End of File */
  400.         case 'database':
  401.             if (isset($this->database_definition['create'])
  402.                 && !$this->isBoolean($this->database_definition['create'])
  403.             {
  404.                 $this->raiseError('field "create" has to be a boolean value'null$xp);
  405.             }
  406.             if (isset($this->database_definition['overwrite'])
  407.                 && !$this->isBoolean($this->database_definition['overwrite'])
  408.             {
  409.                 $this->raiseError('field "overwrite" has to be a boolean value'null$xp);
  410.             }
  411.             if (!isset($this->database_definition['name'])
  412.                 || !$this->database_definition['name']
  413.             {
  414.                 $this->raiseError('database needs a name'null$xp);
  415.             }
  416.             if (isset($this->database_definition['sequences'])) {
  417.                 foreach ($this->database_definition['sequences'as $seq_name => $seq{
  418.                     if (array_key_exists('on'$seq)
  419.                         && !isset($this->database_definition['tables'][$seq['on']['table']]['fields'][$seq['on']['field']])
  420.                     {
  421.                         $this->raiseError('sequence "'.$seq_name.
  422.                             '" was assigned on unexisting field/table'null$xp);
  423.                     }
  424.                 }
  425.             }
  426.             if (PEAR::isError($this->error)) {
  427.                 $this->database_definition = $this->error;
  428.             }
  429.             break;
  430.         }
  431.  
  432.         unset($this->elements[--$this->count]);
  433.         $this->element = implode('-'$this->elements);
  434.     }
  435.  
  436.     function validateFieldValue($field_name&$field_value&$xp)
  437.     {
  438.         if (!isset($this->table['fields'][$field_name])) {
  439.             return $this->raiseError('"'.$field_name.'" is not defined'null$xp);
  440.         }
  441.         $field_def $this->table['fields'][$field_name];
  442.         switch ($field_def['type']{
  443.         case 'text':
  444.         case 'clob':
  445.             if (array_key_exists('length'$field_def&& strlen($field_value$field_def['length']{
  446.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  447.                     $field_def['type'].'"'null$xp);
  448.             }
  449.             break;
  450.         case 'blob':
  451.             /*
  452.             if (!preg_match('/^([0-9a-f]{2})*$/i', $field_value)) {
  453.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  454.                     $field_def['type'].'"', null, $xp);
  455.             }
  456.             */
  457.             $field_value pack('H*'$field_value);
  458.             if (array_key_exists('length'$field_def&& strlen($field_value$field_def['length']{
  459.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  460.                     $field_def['type'].'"'null$xp);
  461.             }
  462.             break;
  463.         case 'integer':
  464.             if ($field_value != ((int)$field_value)) {
  465.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  466.                     $field_def['type'].'"'null$xp);
  467.             }
  468.             $field_value = (int) $field_value;
  469.             if (array_key_exists('unsigned'$field_def&& $field_def['unsigned'&& $field_value < 0{
  470.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  471.                     $field_def['type'].'"'null$xp);
  472.             }
  473.             break;
  474.         case 'boolean':
  475.             if (!$this->isBoolean($field_value)) {
  476.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  477.                     $field_def['type'].'"'null$xp);
  478.             }
  479.             break;
  480.         case 'date':
  481.             if (!preg_match('/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/'$field_value)) {
  482.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  483.                     $field_def['type'].'"'null$xp);
  484.             }
  485.             break;
  486.         case 'timestamp':
  487.             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)) {
  488.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  489.                     $field_def['type'].'"'null$xp);
  490.             }
  491.             break;
  492.         case 'time':
  493.             if (!preg_match("/([0-9]{2}):([0-9]{2}):([0-9]{2})/"$field_value)) {
  494.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  495.                     $field_def['type'].'"'null$xp);
  496.             }
  497.             break;
  498.         case 'float':
  499.         case 'double':
  500.             if ($field_value != (double) $field_value{
  501.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  502.                     $field_def['type'].'"'null$xp);
  503.             }
  504.             $field_value = (double) $field_value;
  505.             break;
  506.         }
  507.         return true;
  508.     }
  509.  
  510.     function &raiseError($msg = null$ecode = 0$xp = null)
  511.     {
  512.         if (is_null($this->error)) {
  513.             $error '';
  514.             if (is_resource($msg)) {
  515.                 $error .= 'Parser error: '.xml_error_string(xml_get_error_code($msg));
  516.                 $xp $msg;
  517.             else {
  518.                 $error .= 'Parser error: '.$msg;
  519.                 if (!is_resource($xp)) {
  520.                     $xp $this->parser;
  521.                 }
  522.             }
  523.             if ($error_string xml_error_string($ecode)) {
  524.                 $error .= ' - '.$error_string;
  525.             }
  526.             if (is_resource($xp)) {
  527.                 $byte @xml_get_current_byte_index($xp);
  528.                 $line @xml_get_current_line_number($xp);
  529.                 $column @xml_get_current_column_number($xp);
  530.                 $error .= " - Byte: $byte; Line: $line; Col: $column";
  531.             }
  532.             $error .= "\n";
  533.             $this->error =MDB2::raiseError(MDB2_SCHEMA_ERROR_PARSEnullnull$error);
  534.         }
  535.         return $this->error;
  536.     }
  537.  
  538.     function isBoolean(&$value)
  539.     {
  540.         if (is_int($value&& ($value == 0 || $value == 1)) {
  541.             return true;
  542.         }
  543.         if ($value === '1' || $value === '0'{
  544.             $value = (int) $value;
  545.             return true;
  546.         }
  547.         switch ($value{
  548.         case 'N':
  549.         case 'n':
  550.         case 'no':
  551.         case 'false':
  552.             $value = false;
  553.             break;
  554.         case 'Y':
  555.         case 'y':
  556.         case 'yes':
  557.         case 'true':
  558.             $value = true;
  559.             break;
  560.         default:
  561.             return false;
  562.         }
  563.         return true;
  564.     }
  565.  
  566.     function cdataHandler($xp$data)
  567.     {
  568.         if ($this->var_mode == true{
  569.             if (!isset($this->variables[$data])) {
  570.                 $this->raiseError('variable "'.$data.'" not found'null$xp);
  571.                 return;
  572.             }
  573.             $data $this->variables[$data];
  574.         }
  575.  
  576.         switch ($this->element{
  577.         /* Initialization */
  578.         case 'database-table-initialization-insert-field-name':
  579.             if (isset($this->init_name)) {
  580.                 $this->init_name .= $data;
  581.             else {
  582.                 $this->init_name = $data;
  583.             }
  584.             break;
  585.         case 'database-table-initialization-insert-field-value':
  586.             if (isset($this->init_value)) {
  587.                 $this->init_value .= $data;
  588.             else {
  589.                 $this->init_value = $data;
  590.             }
  591.             break;
  592.  
  593.         /* Database */
  594.         case 'database-name':
  595.             if (isset($this->database_definition['name'])) {
  596.                 $this->database_definition['name'.= $data;
  597.             else {
  598.                 $this->database_definition['name'$data;
  599.             }
  600.             break;
  601.         case 'database-create':
  602.             if (isset($this->database_definition['create'])) {
  603.                 $this->database_definition['create'.= $data;
  604.             else {
  605.                 $this->database_definition['create'$data;
  606.             }
  607.             break;
  608.         case 'database-overwrite':
  609.             if (isset($this->database_definition['overwrite'])) {
  610.                 $this->database_definition['overwrite'.= $data;
  611.             else {
  612.                 $this->database_definition['overwrite'$data;
  613.             }
  614.             break;
  615.         case 'database-table-name':
  616.             if (isset($this->table_name)) {
  617.                 $this->table_name .= $data;
  618.             else {
  619.                 $this->table_name = $data;
  620.             }
  621.             break;
  622.         case 'database-table-was':
  623.             if (array_key_exists('was'$this->table)) {
  624.                 $this->table['was'.= $data;
  625.             else {
  626.                 $this->table['was'$data;
  627.             }
  628.             break;
  629.  
  630.         /* Field declaration */
  631.         case 'database-table-declaration-field-name':
  632.             if (isset($this->field_name)) {
  633.                 $this->field_name .= $data;
  634.             else {
  635.                 $this->field_name = $data;
  636.             }
  637.             break;
  638.         case 'database-table-declaration-field-type':
  639.             if (array_key_exists('type'$this->field)) {
  640.                 $this->field['type'.= $data;
  641.             else {
  642.                 $this->field['type'$data;
  643.             }
  644.             break;
  645.         case 'database-table-declaration-field-was':
  646.             if (array_key_exists('was'$this->field)) {
  647.                 $this->field['was'.= $data;
  648.             else {
  649.                 $this->field['was'$data;
  650.             }
  651.             break;
  652.         case 'database-table-declaration-field-notnull':
  653.             if (array_key_exists('notnull'$this->field)) {
  654.                 $this->field['notnull'.= $data;
  655.             else {
  656.                 $this->field['notnull'$data;
  657.             }
  658.             break;
  659.         case 'database-table-declaration-field-unsigned':
  660.             if (array_key_exists('unsigned'$this->field)) {
  661.                 $this->field['unsigned'.= $data;
  662.             else {
  663.                 $this->field['unsigned'$data;
  664.             }
  665.             break;
  666.         case 'database-table-declaration-field-autoincrement':
  667.             if (array_key_exists('autoincrement'$this->field)) {
  668.                 $this->field['autoincrement'.= $data;
  669.             else {
  670.                 $this->field['autoincrement'$data;
  671.             }
  672.             break;
  673.         case 'database-table-declaration-field-default':
  674.             if (array_key_exists('default'$this->field)) {
  675.                 $this->field['default'.= $data;
  676.             else {
  677.                 $this->field['default'$data;
  678.             }
  679.             break;
  680.         case 'database-table-declaration-field-length':
  681.             if (array_key_exists('length'$this->field)) {
  682.                 $this->field['length'.= $data;
  683.             else {
  684.                 $this->field['length'$data;
  685.             }
  686.             break;
  687.  
  688.         /* Index declaration */
  689.         case 'database-table-declaration-index-name':
  690.             if (isset($this->index_name)) {
  691.                 $this->index_name .= $data;
  692.             else {
  693.                 $this->index_name = $data;
  694.             }
  695.             break;
  696.         case 'database-table-declaration-index-primary':
  697.             if (array_key_exists('primary'$this->index)) {
  698.                 $this->index['primary'.= $data;
  699.             else {
  700.                 $this->index['primary'$data;
  701.             }
  702.             break;
  703.         case 'database-table-declaration-index-unique':
  704.             if (array_key_exists('unique'$this->index)) {
  705.                 $this->index['unique'.= $data;
  706.             else {
  707.                 $this->index['unique'$data;
  708.             }
  709.             break;
  710.         case 'database-table-declaration-index-was':
  711.             if (array_key_exists('was'$this->index)) {
  712.                 $this->index['was'.= $data;
  713.             else {
  714.                 $this->index['was'$data;
  715.             }
  716.             break;
  717.         case 'database-table-declaration-index-field-name':
  718.             if (isset($this->field_name)) {
  719.                 $this->field_name .= $data;
  720.             else {
  721.                 $this->field_name = $data;
  722.             }
  723.             break;
  724.         case 'database-table-declaration-index-field-sorting':
  725.             if (array_key_exists('sorting'$this->field)) {
  726.                 $this->field['sorting'.= $data;
  727.             else {
  728.                 $this->field['sorting'$data;
  729.             }
  730.             break;
  731.         /* Add by Leoncx */
  732.         case 'database-table-declaration-index-field-length':
  733.             if (array_key_exists('length'$this->field)) {
  734.                 $this->field['length'.= $data;
  735.             else {
  736.                 $this->field['length'$data;
  737.             }
  738.             break;
  739.  
  740.         /* Sequence declaration */
  741.         case 'database-sequence-name':
  742.             if (isset($this->seq_name)) {
  743.                 $this->seq_name .= $data;
  744.             else {
  745.                 $this->seq_name = $data;
  746.             }
  747.             break;
  748.         case 'database-sequence-was':
  749.             if (array_key_exists('was'$this->seq)) {
  750.                 $this->seq['was'.= $data;
  751.             else {
  752.                 $this->seq['was'$data;
  753.             }
  754.             break;
  755.         case 'database-sequence-start':
  756.             if (array_key_exists('start'$this->seq)) {
  757.                 $this->seq['start'.= $data;
  758.             else {
  759.                 $this->seq['start'$data;
  760.             }
  761.             break;
  762.         case 'database-sequence-on-table':
  763.             if (isset($this->seq['on']['table'])) {
  764.                 $this->seq['on']['table'.= $data;
  765.             else {
  766.                 $this->seq['on']['table'$data;
  767.             }
  768.             break;
  769.         case 'database-sequence-on-field':
  770.             if (isset($this->seq['on']['field'])) {
  771.                 $this->seq['on']['field'.= $data;
  772.             else {
  773.                 $this->seq['on']['field'$data;
  774.             }
  775.             break;
  776.         }
  777.     }
  778. }
  779.  
  780. ?>

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