cvs: pear /MDB2_Schema/MDB2/Schema Parser.php

From: Date: Tue, 21 Mar 2006 09:25:09 +0000
Subject: cvs: pear /MDB2_Schema/MDB2/Schema Parser.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-39216@lists.php.net to get a copy of this message
lsmith Tue Mar 21 09:25:09 2006 UTC Modified files: /pear/MDB2_Schema/MDB2/Schema Parser.php Log: - added valid_types property to determine valid_types and to set missing default values http://cvs.php.net/viewcvs.cgi/pear/MDB2_Schema/MDB2/Schema/Parser.php?r1=1.27&r2=1.28&diff_format=u Index: pear/MDB2_Schema/MDB2/Schema/Parser.php diff -u pear/MDB2_Schema/MDB2/Schema/Parser.php:1.27 pear/MDB2_Schema/MDB2/Schema/Parser.php:1.28 --- pear/MDB2_Schema/MDB2/Schema/Parser.php:1.27 Wed Mar 1 12:16:41 2006 +++ pear/MDB2_Schema/MDB2/Schema/Parser.php Tue Mar 21 09:25:09 2006 @@ -42,7 +42,7 @@ // | Author: Christian Dickmann <dickmann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Parser.php,v 1.27 2006/03/01 12:16:41 lsmith Exp $ +// $Id: Parser.php,v 1.28 2006/03/21 09:25:09 lsmith Exp $ // require_once 'XML/Parser.php'; @@ -81,8 +81,9 @@ var $error; var $fail_on_invalid_names = true; var $structure = false; + var $valid_types = array(); - function __construct($variables, $fail_on_invalid_names = true, $structure = false) + function __construct($variables, $fail_on_invalid_names = true, $structure = false, $valid_types = array()) { parent::XML_Parser(); $this->variables = $variables; @@ -95,11 +96,12 @@ $this->fail_on_invalid_names = false; } $this->structure = $structure; + $this->valid_types = $valid_types; } - function MDB2_Schema_Parser($variables, $fail_on_invalid_names = true, $structure = false) + function MDB2_Schema_Parser($variables, $fail_on_invalid_names = true, $structure = false, $valid_types = array()) { - $this->__construct($variables, $fail_on_invalid_names, $structure); + $this->__construct($variables, $fail_on_invalid_names, $structure, $valid_types); } function startHandler($xp, $element, $attribs) @@ -279,6 +281,9 @@ } } /* Type check */ + if (!array_key_exists('type', $this->field) || !array_key_exists($this->field['type'], $this->valid_types)) { + $this->raiseError('no valid field type ("'.$this->field['type'].'") specified', null, $xp); + } switch ($this->field['type']) { case 'integer': if (array_key_exists('unsigned', $this->field) && !$this->isBoolean($this->field['unsigned'])) { @@ -315,7 +320,7 @@ if (!array_key_exists('default', $this->field) && $this->field['type'] != 'clob' && $this->field['type'] != 'blob' ) { - $this->field['default'] = ''; + $this->field['default'] = $this->valid_types[$this->field['type']]; } if (array_key_exists('unsigned', $this->field) && !$this->isBoolean($this->field['unsigned'])) { $this->raiseError('field "unsigned" has to be a boolean value', null, $xp);

« previous php.pear.cvs (#39216) next »