cvs: pear /MDB parser.php
| From: | Christian Dickmann | Date: | Fri, 23 Aug 2002 14:13:24 +0000 |
| Subject: | cvs: pear /MDB parser.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-5906@lists.php.net to get a copy of this message | ||
dickmann Fri Aug 23 10:13:24 2002 EDT
Modified files:
/pear/MDB parser.php
Log:
fix validation of empty fields
Index: pear/MDB/parser.php
diff -u pear/MDB/parser.php:1.16 pear/MDB/parser.php:1.17
--- pear/MDB/parser.php:1.16 Fri Aug 23 09:45:43 2002
+++ pear/MDB/parser.php Fri Aug 23 10:13:24 2002
@@ -42,7 +42,7 @@
// | Author: Christian Dickmann <dickmann@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: parser.php,v 1.16 2002/08/23 13:45:43 dickmann Exp $
+// $Id: parser.php,v 1.17 2002/08/23 14:13:24 dickmann Exp $
//
require_once "XML/Parser.php";
@@ -150,8 +150,8 @@
switch($this->element) {
/* Initialization */
case 'database-table-initialization-insert-field':
- if (!$this->init_name || !$this->init_value) {
- $this->raiseError($xp, 'not properly');
+ if (!$this->init_name) {
+ $this->raiseError($xp, 'field-name has to be specified');
};
if (isset($this->init['FIELDS'][$this->init_name])) {
$this->raiseError($xp, 'field "'.$this->init_name.'"
already filled');
@@ -188,6 +188,9 @@
if (!isset($this->table['FIELDS'][$field_name])) {
$this->raiseError($xp, 'index field
"'.$field_name.'" does not exist');
}
+ if
(!isset($this->table['FIELDS'][$field_name]['notnull'])) {
+ $this->raiseError($xp, 'index field
"'.$field_name.'" has to be "notnull"');
+ }
}
}
};
@@ -238,6 +241,9 @@
if (isset($this->field['notnull']) &&
!$this->is_boolean($this->field['notnull'])) {
$this->raiseError($xp, 'field "notnull" has to be 1 or 0');
};
+ if (isset($this->field['notnull']) &&
!isset($this->field['default'])) {
+ $this->raiseError($xp, 'if field is "notnull", it needs a default
value');
+ };
if (isset($this->field['unsigned']) &&
!$this->is_boolean($this->field['unsigned'])) {
$this->raiseError($xp, 'field "notnull" has to be 1 or 0');
};
@@ -336,6 +342,9 @@
{
if (!isset($this->table['FIELDS'][$field_name])) {
return;
+ };
+ if ($field_value === '') {
+ return true;
};
$field_def = $this->table['FIELDS'][$field_name];
switch($field_def['type']) {