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.25 2006/01/04 20:10: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' && $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'= false;
  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&& isset($this->field['default'])
  331.                 && !$this->validateFieldValue($this->field_name,
  332.                     $this->table['fields'][$this->field_name]['default']$xp
  333.                 )
  334.             {
  335.                 $this->raiseError('default value of "'.$this->field_name.'" is of wrong type'null$xp);
  336.             }
  337.             break;
  338.  
  339.         /* Index declaration */
  340.         case 'database-table-declaration-index':
  341.             if (!$this->index_name{
  342.                 $this->raiseError('an index needs a name'null$xp);
  343.             }
  344.             if (isset($this->table['indexes'][$this->index_name])) {
  345.                 $this->raiseError('index "'.$this->index_name.'" already exists'null$xp);
  346.             }
  347.             if (array_key_exists('unique'$this->index&& !$this->isBoolean($this->index['unique'])) {
  348.                 $this->raiseError('field "unique" has to be a boolean value'null$xp);
  349.             }
  350.             if (array_key_exists('primary'$this->index&& !$this->isBoolean($this->index['primary'])) {
  351.                 $this->raiseError('field "primary" has to be a boolean value'null$xp);
  352.             }
  353.  
  354.             if (!array_key_exists('was'$this->index)) {
  355.                 $this->index['was'$this->index_name;
  356.             }
  357.             $this->table['indexes'][$this->index_name$this->index;
  358.             break;
  359.         case 'database-table-declaration-index-field':
  360.             if (!$this->field_name{
  361.                 $this->raiseError('the index-field-name is required'null$xp);
  362.             }
  363.             if (array_key_exists('sorting'$this->field)
  364.                 && $this->field['sorting'!== 'ascending' && $this->field['sorting'!== 'descending'{
  365.                 $this->raiseError('sorting type unknown'null$xp);
  366.             else {
  367.                 $this->field['sorting''ascending';
  368.             }
  369.             $this->index['fields'][$this->field_name$this->field;
  370.             break;
  371.         case 'database-table-name':
  372.             if (isset($this->structure['tables'][$this->table_name])) {
  373.                 $this->table = $this->structure['tables'][$this->table_name];
  374.             }
  375.             break;
  376.  
  377.         /* Sequence declaration */
  378.         case 'database-sequence':
  379.             if (!$this->seq_name{
  380.                 $this->raiseError('a sequence has to have a name'null$xp);
  381.             }
  382.             if (isset($this->database_definition['sequences'][$this->seq_name])) {
  383.                 $this->raiseError('sequence "'.$this->seq_name.'" already exists'null$xp);
  384.             }
  385.  
  386.             if (!array_key_exists('was'$this->seq)) {
  387.                 $this->seq['was'$this->seq_name;
  388.             }
  389.  
  390.             if (array_key_exists('on'$this->seq)) {
  391.                 if ((!isset($this->seq['on']['table']|| !$this->seq['on']['table'])
  392.                     || (!isset($this->seq['on']['field']|| !$this->seq['on']['field'])
  393.                 {
  394.                     $this->raiseError('sequence "'.$this->seq_name.
  395.                         '" was not properly defined'null$xp);
  396.                 }
  397.             }
  398.             $this->database_definition['sequences'][$this->seq_name$this->seq;
  399.             break;
  400.  
  401.         /* End of File */
  402.         case 'database':
  403.             if (isset($this->database_definition['create'])
  404.                 && !$this->isBoolean($this->database_definition['create'])
  405.             {
  406.                 $this->raiseError('field "create" has to be a boolean value'null$xp);
  407.             }
  408.             if (isset($this->database_definition['overwrite'])
  409.                 && !$this->isBoolean($this->database_definition['overwrite'])
  410.             {
  411.                 $this->raiseError('field "overwrite" has to be a boolean value'null$xp);
  412.             }
  413.             if (!isset($this->database_definition['name'])
  414.                 || !$this->database_definition['name']
  415.             {
  416.                 $this->raiseError('database needs a name'null$xp);
  417.             }
  418.             if (isset($this->database_definition['sequences'])) {
  419.                 foreach ($this->database_definition['sequences'as $seq_name => $seq{
  420.                     if (array_key_exists('on'$seq)
  421.                         && !isset($this->database_definition['tables'][$seq['on']['table']]['fields'][$seq['on']['field']])
  422.                     {
  423.                         $this->raiseError('sequence "'.$seq_name.
  424.                             '" was assigned on unexisting field/table'null$xp);
  425.                     }
  426.                 }
  427.             }
  428.             if (PEAR::isError($this->error)) {
  429.                 $this->database_definition = $this->error;
  430.             }
  431.             break;
  432.         }
  433.  
  434.         unset($this->elements[--$this->count]);
  435.         $this->element = implode('-'$this->elements);
  436.     }
  437.  
  438.     function validateFieldValue($field_name&$field_value&$xp)
  439.     {
  440.         if (!isset($this->table['fields'][$field_name])) {
  441.             return $this->raiseError('"'.$field_name.'" is not defined'null$xp);
  442.         }
  443.         $field_def $this->table['fields'][$field_name];
  444.         switch ($field_def['type']{
  445.         case 'text':
  446.         case 'clob':
  447.             if (array_key_exists('length'$field_def&& strlen($field_value$field_def['length']{
  448.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  449.                     $field_def['type'].'"'null$xp);
  450.             }
  451.             break;
  452.         case 'blob':
  453.             /*
  454.             if (!preg_match('/^([0-9a-f]{2})*$/i', $field_value)) {
  455.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  456.                     $field_def['type'].'"', null, $xp);
  457.             }
  458.             */
  459.             $field_value pack('H*'$field_value);
  460.             if (array_key_exists('length'$field_def&& strlen($field_value$field_def['length']{
  461.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  462.                     $field_def['type'].'"'null$xp);
  463.             }
  464.             break;
  465.         case 'integer':
  466.             if ($field_value != ((int)$field_value)) {
  467.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  468.                     $field_def['type'].'"'null$xp);
  469.             }
  470.             $field_value = (int) $field_value;
  471.             if (array_key_exists('unsigned'$field_def&& $field_def['unsigned'&& $field_value < 0{
  472.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  473.                     $field_def['type'].'"'null$xp);
  474.             }
  475.             break;
  476.         case 'boolean':
  477.             if (!$this->isBoolean($field_value)) {
  478.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  479.                     $field_def['type'].'"'null$xp);
  480.             }
  481.             break;
  482.         case 'date':
  483.             if (!preg_match('/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/'$field_value)) {
  484.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  485.                     $field_def['type'].'"'null$xp);
  486.             }
  487.             break;
  488.         case 'timestamp':
  489.             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)) {
  490.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  491.                     $field_def['type'].'"'null$xp);
  492.             }
  493.             break;
  494.         case 'time':
  495.             if (!preg_match("/([0-9]{2}):([0-9]{2}):([0-9]{2})/"$field_value)) {
  496.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  497.                     $field_def['type'].'"'null$xp);
  498.             }
  499.             break;
  500.         case 'float':
  501.         case 'double':
  502.             if ($field_value != (double) $field_value{
  503.                 return $this->raiseError('"'.$field_value.'" is not of type "'.
  504.                     $field_def['type'].'"'null$xp);
  505.             }
  506.             $field_value = (double) $field_value;
  507.             break;
  508.         }
  509.         return true;
  510.     }
  511.  
  512.     function &raiseError($msg = null$ecode = 0$xp = null)
  513.     {
  514.         if (is_null($this->error)) {
  515.             $error '';
  516.             if (is_resource($msg)) {
  517.                 $error .= 'Parser error: '.xml_error_string(xml_get_error_code($msg));
  518.                 $xp $msg;
  519.             else {
  520.                 $error .= 'Parser error: '.$msg;
  521.                 if (!is_resource($xp)) {
  522.                     $xp $this->parser;
  523.                 }
  524.             }
  525.             if ($error_string xml_error_string($ecode)) {
  526.                 $error .= ' - '.$error_string;
  527.             }
  528.             if (is_resource($xp)) {
  529.                 $byte @xml_get_current_byte_index($xp);
  530.                 $line @xml_get_current_line_number($xp);
  531.                 $column @xml_get_current_column_number($xp);
  532.                 $error .= " - Byte: $byte; Line: $line; Col: $column";
  533.             }
  534.             $error .= "\n";
  535.             $this->error =MDB2::raiseError(MDB2_SCHEMA_ERROR_PARSEnullnull$error);
  536.         }
  537.         return $this->error;
  538.     }
  539.  
  540.     function isBoolean(&$value)
  541.     {
  542.         if (is_bool($value)) {
  543.             return true;
  544.         }
  545.         if ($value === 0 || $value === 1{
  546.             $value = (bool)$value;
  547.             return true;
  548.         }
  549.         if (!is_string($value)) {
  550.             return false;
  551.         }
  552.         switch ($value{
  553.         case '0':
  554.         case 'N':
  555.         case 'n':
  556.         case 'no':
  557.         case 'false':
  558.             $value = false;
  559.             break;
  560.         case '1':
  561.         case 'Y':
  562.         case 'y':
  563.         case 'yes':
  564.         case 'true':
  565.             $value = true;
  566.             break;
  567.         default:
  568.             return false;
  569.         }
  570.         return true;
  571.     }
  572.  
  573.     function cdataHandler($xp$data)
  574.     {
  575.         if ($this->var_mode == true{
  576.             if (!isset($this->variables[$data])) {
  577.                 $this->raiseError('variable "'.$data.'" not found'null$xp);
  578.                 return;
  579.             }
  580.             $data $this->variables[$data];
  581.         }
  582.  
  583.         switch ($this->element{
  584.         /* Initialization */
  585.         case 'database-table-initialization-insert-field-name':
  586.             if (isset($this->init_name)) {
  587.                 $this->init_name .= $data;
  588.             else {
  589.                 $this->init_name = $data;
  590.             }
  591.             break;
  592.         case 'database-table-initialization-insert-field-value':
  593.             if (isset($this->init_value)) {
  594.                 $this->init_value .= $data;
  595.             else {
  596.                 $this->init_value = $data;
  597.             }
  598.             break;
  599.  
  600.         /* Database */
  601.         case 'database-name':
  602.             if (isset($this->database_definition['name'])) {
  603.                 $this->database_definition['name'.= $data;
  604.             else {
  605.                 $this->database_definition['name'$data;
  606.             }
  607.             break;
  608.         case 'database-create':
  609.             if (isset($this->database_definition['create'])) {
  610.                 $this->database_definition['create'.= $data;
  611.             else {
  612.                 $this->database_definition['create'$data;
  613.             }
  614.             break;
  615.         case 'database-overwrite':
  616.             if (isset($this->database_definition['overwrite'])) {
  617.                 $this->database_definition['overwrite'.= $data;
  618.             else {
  619.                 $this->database_definition['overwrite'$data;
  620.             }
  621.             break;
  622.         case 'database-table-name':
  623.             if (isset($this->table_name)) {
  624.                 $this->table_name .= $data;
  625.             else {
  626.                 $this->table_name = $data;
  627.             }
  628.             break;
  629.         case 'database-table-was':
  630.             if (array_key_exists('was'$this->table)) {
  631.                 $this->table['was'.= $data;
  632.             else {
  633.                 $this->table['was'$data;
  634.             }
  635.             break;
  636.  
  637.         /* Field declaration */
  638.         case 'database-table-declaration-field-name':
  639.             if (isset($this->field_name)) {
  640.                 $this->field_name .= $data;
  641.             else {
  642.                 $this->field_name = $data;
  643.             }
  644.             break;
  645.         case 'database-table-declaration-field-type':
  646.             if (array_key_exists('type'$this->field)) {
  647.                 $this->field['type'.= $data;
  648.             else {
  649.                 $this->field['type'$data;
  650.             }
  651.             break;
  652.         case 'database-table-declaration-field-was':
  653.             if (array_key_exists('was'$this->field)) {
  654.                 $this->field['was'.= $data;
  655.             else {
  656.                 $this->field['was'$data;
  657.             }
  658.             break;
  659.         case 'database-table-declaration-field-notnull':
  660.             if (array_key_exists('notnull'$this->field)) {
  661.                 $this->field['notnull'.= $data;
  662.             else {
  663.                 $this->field['notnull'$data;
  664.             }
  665.             break;
  666.         case 'database-table-declaration-field-unsigned':
  667.             if (array_key_exists('unsigned'$this->field)) {
  668.                 $this->field['unsigned'.= $data;
  669.             else {
  670.                 $this->field['unsigned'$data;
  671.             }
  672.             break;
  673.         case 'database-table-declaration-field-autoincrement':
  674.             if (array_key_exists('autoincrement'$this->field)) {
  675.                 $this->field['autoincrement'.= $data;
  676.             else {
  677.                 $this->field['autoincrement'$data;
  678.             }
  679.             break;
  680.         case 'database-table-declaration-field-default':
  681.             if (array_key_exists('default'$this->field)) {
  682.                 $this->field['default'.= $data;
  683.             else {
  684.                 $this->field['default'$data;
  685.             }
  686.             break;
  687.         case 'database-table-declaration-field-length':
  688.             if (array_key_exists('length'$this->field)) {
  689.                 $this->field['length'.= $data;
  690.             else {
  691.                 $this->field['length'$data;
  692.             }
  693.             break;
  694.  
  695.         /* Index declaration */
  696.         case 'database-table-declaration-index-name':
  697.             if (isset($this->index_name)) {
  698.                 $this->index_name .= $data;
  699.             else {
  700.                 $this->index_name = $data;
  701.             }
  702.             break;
  703.         case 'database-table-declaration-index-primary':
  704.             if (array_key_exists('primary'$this->index)) {
  705.                 $this->index['primary'.= $data;
  706.             else {
  707.                 $this->index['primary'$data;
  708.             }
  709.             break;
  710.         case 'database-table-declaration-index-unique':
  711.             if (array_key_exists('unique'$this->index)) {
  712.                 $this->index['unique'.= $data;
  713.             else {
  714.                 $this->index['unique'$data;
  715.             }
  716.             break;
  717.         case 'database-table-declaration-index-was':
  718.             if (array_key_exists('was'$this->index)) {
  719.                 $this->index['was'.= $data;
  720.             else {
  721.                 $this->index['was'$data;
  722.             }
  723.             break;
  724.         case 'database-table-declaration-index-field-name':
  725.             if (isset($this->field_name)) {
  726.                 $this->field_name .= $data;
  727.             else {
  728.                 $this->field_name = $data;
  729.             }
  730.             break;
  731.         case 'database-table-declaration-index-field-sorting':
  732.             if (array_key_exists('sorting'$this->field)) {
  733.                 $this->field['sorting'.= $data;
  734.             else {
  735.                 $this->field['sorting'$data;
  736.             }
  737.             break;
  738.         /* Add by Leoncx */
  739.         case 'database-table-declaration-index-field-length':
  740.             if (array_key_exists('length'$this->field)) {
  741.                 $this->field['length'.= $data;
  742.             else {
  743.                 $this->field['length'$data;
  744.             }
  745.             break;
  746.  
  747.         /* Sequence declaration */
  748.         case 'database-sequence-name':
  749.             if (isset($this->seq_name)) {
  750.                 $this->seq_name .= $data;
  751.             else {
  752.                 $this->seq_name = $data;
  753.             }
  754.             break;
  755.         case 'database-sequence-was':
  756.             if (array_key_exists('was'$this->seq)) {
  757.                 $this->seq['was'.= $data;
  758.             else {
  759.                 $this->seq['was'$data;
  760.             }
  761.             break;
  762.         case 'database-sequence-start':
  763.             if (array_key_exists('start'$this->seq)) {
  764.                 $this->seq['start'.= $data;
  765.             else {
  766.                 $this->seq['start'$data;
  767.             }
  768.             break;
  769.         case 'database-sequence-on-table':
  770.             if (isset($this->seq['on']['table'])) {
  771.                 $this->seq['on']['table'.= $data;
  772.             else {
  773.                 $this->seq['on']['table'$data;
  774.             }
  775.             break;
  776.         case 'database-sequence-on-field':
  777.             if (isset($this->seq['on']['field'])) {
  778.                 $this->seq['on']['field'.= $data;
  779.             else {
  780.                 $this->seq['on']['field'$data;
  781.             }
  782.             break;
  783.         }
  784.     }
  785. }
  786.  
  787. ?>

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