Source for file Parser2.php
Documentation is available at Parser2.php
// +----------------------------------------------------------------------+
// | PHP versions 4 and 5 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox, |
// | Stig. S. Bakken, Lukas Smith |
// | All rights reserved. |
// +----------------------------------------------------------------------+
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
// | API as well as database abstraction for PHP applications. |
// | This LICENSE is in the BSD license style. |
// | Redistribution and use in source and binary forms, with or without |
// | modification, are permitted provided that the following conditions |
// | Redistributions of source code must retain the above copyright |
// | notice, this list of conditions and the following disclaimer. |
// | Redistributions in binary form must reproduce the above copyright |
// | notice, this list of conditions and the following disclaimer in the |
// | documentation and/or other materials provided with the distribution. |
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
// | Lukas Smith nor the names of his contributors may be used to endorse |
// | or promote products derived from this software without specific prior|
// | written permission. |
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
// | POSSIBILITY OF SUCH DAMAGE. |
// +----------------------------------------------------------------------+
// | Author: Igor Feghali <ifeghali@php.net> |
// +----------------------------------------------------------------------+
// $Id: Parser2.php,v 1.1 2007/02/07 19:03:01 ifeghali Exp $
require_once 'XML/Unserializer.php';
require_once 'MDB2/Schema/Validate.php';
if (empty ($GLOBALS['_MDB2_Schema_Reserved'])) {
$GLOBALS['_MDB2_Schema_Reserved'] = array ();
* Parses an XML schema file
* @author Igor Feghali <ifeghali@php.net>
function __construct($variables, $fail_on_invalid_names = true , $structure = false , $valid_types = array (), $force_defaults = true )
// force ISO-8859-1 due to different defaults for PHP4 and PHP5
// todo: this probably needs to be investigated some more and cleaned up
$this->options['encoding'] = 'ISO-8859-1';
$this->options['XML_UNSERIALIZER_OPTION_ATTRIBUTES_PARSE'] = true;
$this->options['XML_UNSERIALIZER_OPTION_ATTRIBUTES_ARRAYKEY'] = false;
$this->options['forceEnum'] = array ('table', 'field', 'index', 'insert', 'update', 'delete');
* todo: find a way to force the following items not to be parsed as arrays
* as it cause problems in functions with multiple arguments
//$this->options['forceNEnum'] = array('value', 'column');
parent ::XML_Unserializer ($this->options);
function MDB2_Schema_Parser2($variables, $fail_on_invalid_names = true , $structure = false , $valid_types = array (), $force_defaults = true )
$this->__construct($variables, $fail_on_invalid_names, $structure, $valid_types, $force_defaults);
$result = $this->unserialize ($this->filename, true );
if (PEAR ::isError ($result)) {
if (PEAR ::isError ($result)) {
$this->raiseError($result->getUserinfo (), 0 , $xp, $result->getCode ());
if (PEAR ::isError ($result)) {
$this->raiseError($result->getUserinfo (), 0 , $xp, $result->getCode ());
$this->filename = $filename;
$arr[$nKey] = &$arr[$oKey];
$dml = array ( 'insert', 'update', 'delete' );
foreach ($dml as $type) {
$init[] = array ( 'type' => $type, 'data' => $v);
if (!empty ($element['field']) && is_array($element['field'])) {
foreach ($element['field'] as $k => $v) {
$field = array ( 'name' => $name, 'group' => $v );
$element['field'][$k] = $field;
if (!empty ($element['where']) && is_array($element['where'])) {
$arr = array ( 'type' => $element['key'] );
$element = $element['value'];
$arr['data'] = array ( 'name' => $element['name'], 'arguments' => array () );
foreach ($element as $k => $v) {
$argument = array ( $k => $v );
$arr['data']['arguments'][] = $argument;
$arr['data'] = array ( 'operator' => $element['operator'], 'operants' => array () );
unset ($element['operator']);
foreach ($element as $k => $v) {
$argument = array ( $k => $v );
$arr['data']['operants'][] = $argument;
/* blindly copied from original parser. to be implemented yet. */
function &raiseError($msg = null , $xmlecode = 0 , $xp = null , $ecode = MDB2_SCHEMA_ERROR_PARSE )
$error.= 'Parser error: '. $msg;
$error.= ' - '. $error_string;
$error.= " - Byte: $byte; Line: $line; Col: $column";
Documentation generated on Mon, 11 Mar 2019 14:58:00 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|