more MDB2 updates

This commit is contained in:
Robin Appelman 2012-05-13 20:49:39 +02:00
parent ddf0903ace
commit 77e2387d94
48 changed files with 22977 additions and 21917 deletions

View File

@ -577,7 +577,7 @@ class Archive_Tar extends PEAR
} }
// ----- Get the arguments // ----- Get the arguments
$v_att_list = &func_get_args(); $v_att_list = func_get_args();
// ----- Read the attributes // ----- Read the attributes
$i=0; $i=0;

603
3rdparty/MDB2.php vendored

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: Date.php 208329 2006-03-01 12:15:38Z lsmith $ // $Id$
// //
/** /**

View File

@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: Common.php 300551 2010-06-17 21:54:16Z quipo $ // $Id$
require_once 'MDB2/LOB.php'; require_once 'MDB2/LOB.php';
@ -263,7 +263,11 @@ class MDB2_Driver_Datatype_Common extends MDB2_Module_Common
*/ */
function convertResultRow($types, $row, $rtrim = true) function convertResultRow($types, $row, $rtrim = true)
{ {
$types = $this->_sortResultFieldTypes(array_keys($row), $types); //$types = $this->_sortResultFieldTypes(array_keys($row), $types);
$keys = array_keys($row);
if (is_int($keys[0])) {
$types = $this->_sortResultFieldTypes($keys, $types);
}
foreach ($row as $key => $value) { foreach ($row as $key => $value) {
if (empty($types[$key])) { if (empty($types[$key])) {
continue; continue;
@ -515,9 +519,6 @@ class MDB2_Driver_Datatype_Common extends MDB2_Module_Common
$default = ' DEFAULT ' . $this->quote($field['default'], $field['type']); $default = ' DEFAULT ' . $this->quote($field['default'], $field['type']);
} }
} }
if (empty($default) && empty($notnull)) {
$default = ' DEFAULT NULL';
}
$collation = empty($field['collation']) ? '' : $collation = empty($field['collation']) ? '' :
' '.$this->_getCollationFieldDeclaration($field['collation']); ' '.$this->_getCollationFieldDeclaration($field['collation']);
@ -1382,7 +1383,7 @@ class MDB2_Driver_Datatype_Common extends MDB2_Module_Common
if (PEAR::isError($db)) { if (PEAR::isError($db)) {
return $db; return $db;
} }
if (isset($db->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) { if (isset($db->function) && is_object($this->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) {
return $db->function->now('date'); return $db->function->now('date');
} }
return 'CURRENT_DATE'; return 'CURRENT_DATE';
@ -1411,7 +1412,7 @@ class MDB2_Driver_Datatype_Common extends MDB2_Module_Common
if (PEAR::isError($db)) { if (PEAR::isError($db)) {
return $db; return $db;
} }
if (isset($db->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) { if (isset($db->function) && is_object($this->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) {
return $db->function->now('timestamp'); return $db->function->now('timestamp');
} }
return 'CURRENT_TIMESTAMP'; return 'CURRENT_TIMESTAMP';
@ -1440,7 +1441,7 @@ class MDB2_Driver_Datatype_Common extends MDB2_Module_Common
if (PEAR::isError($db)) { if (PEAR::isError($db)) {
return $db; return $db;
} }
if (isset($db->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) { if (isset($db->function) && is_object($this->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) {
return $db->function->now('time'); return $db->function->now('time');
} }
return 'CURRENT_TIME'; return 'CURRENT_TIME';

View File

@ -43,7 +43,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: mysql.php 295587 2010-02-28 17:16:38Z quipo $ // $Id$
// //
require_once 'MDB2/Driver/Datatype/Common.php'; require_once 'MDB2/Driver/Datatype/Common.php';
@ -88,6 +88,35 @@ class MDB2_Driver_Datatype_mysql extends MDB2_Driver_Datatype_Common
return 'COLLATE '.$collation; return 'COLLATE '.$collation;
} }
// }}}
// {{{ getDeclaration()
/**
* Obtain DBMS specific SQL code portion needed to declare
* of the given type
*
* @param string $type type to which the value should be converted to
* @param string $name name the field to be declared.
* @param string $field definition of the field
*
* @return string DBMS-specific SQL code portion that should be used to
* declare the specified field.
* @access public
*/
function getDeclaration($type, $name, $field)
{
// MySQL DDL syntax forbids combining NOT NULL with DEFAULT NULL.
// To get a default of NULL for NOT NULL columns, omit it.
if ( isset($field['notnull'])
&& !empty($field['notnull'])
&& array_key_exists('default', $field) // do not use isset() here!
&& null === $field['default']
) {
unset($field['default']);
}
return parent::getDeclaration($type, $name, $field);
}
// }}} // }}}
// {{{ getTypeDeclaration() // {{{ getTypeDeclaration()
@ -179,7 +208,15 @@ class MDB2_Driver_Datatype_mysql extends MDB2_Driver_Datatype_Common
case 'timestamp': case 'timestamp':
return 'DATETIME'; return 'DATETIME';
case 'float': case 'float':
return 'DOUBLE'; $l = '';
if (!empty($field['length'])) {
$l = '(' . $field['length'];
if (!empty($field['scale'])) {
$l .= ',' . $field['scale'];
}
$l .= ')';
}
return 'DOUBLE' . $l;
case 'decimal': case 'decimal':
$length = !empty($field['length']) ? $field['length'] : 18; $length = !empty($field['length']) ? $field['length'] : 18;
$scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places']; $scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places'];
@ -513,6 +550,9 @@ class MDB2_Driver_Datatype_mysql extends MDB2_Driver_Datatype_Common
case 'real': case 'real':
$type[] = 'float'; $type[] = 'float';
$unsigned = preg_match('/ unsigned/i', $field['type']); $unsigned = preg_match('/ unsigned/i', $field['type']);
if ($decimal !== false) {
$length = $length.','.$decimal;
}
break; break;
case 'unknown': case 'unknown':
case 'decimal': case 'decimal':

View File

@ -42,7 +42,7 @@
// | Author: Paul Cooper <pgc@ucecom.com> | // | Author: Paul Cooper <pgc@ucecom.com> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: pgsql.php 298763 2010-04-29 08:49:41Z afz $ // $Id$
require_once 'MDB2/Driver/Datatype/Common.php'; require_once 'MDB2/Driver/Datatype/Common.php';
@ -246,10 +246,12 @@ class MDB2_Driver_Datatype_pgsql extends MDB2_Driver_Datatype_Common
if (PEAR::isError($db)) { if (PEAR::isError($db)) {
return $db; return $db;
} }
$value = $this->_readFile($value, $db->options['lob_allow_url_include']); if ($db->options['lob_allow_url_include']) {
$value = $this->_readFile($value);
if (PEAR::isError($value)) { if (PEAR::isError($value)) {
return $value; return $value;
} }
}
return $this->_quoteText($value, $quote, $escape_wildcards); return $this->_quoteText($value, $quote, $escape_wildcards);
} }
@ -276,10 +278,12 @@ class MDB2_Driver_Datatype_pgsql extends MDB2_Driver_Datatype_Common
if (PEAR::isError($db)) { if (PEAR::isError($db)) {
return $db; return $db;
} }
$value = $this->_readFile($value, $db->options['lob_allow_url_include']); if ($db->options['lob_allow_url_include']) {
$value = $this->_readFile($value);
if (PEAR::isError($value)) { if (PEAR::isError($value)) {
return $value; return $value;
} }
}
if (version_compare(PHP_VERSION, '5.2.0RC6', '>=')) { if (version_compare(PHP_VERSION, '5.2.0RC6', '>=')) {
$connection = $db->getConnection(); $connection = $db->getConnection();
if (PEAR::isError($connection)) { if (PEAR::isError($connection)) {

View File

@ -43,7 +43,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: sqlite.php 295587 2010-02-28 17:16:38Z quipo $ // $Id$
// //
require_once 'MDB2/Driver/Datatype/Common.php'; require_once 'MDB2/Driver/Datatype/Common.php';

View File

@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: Common.php 295587 2010-02-28 17:16:38Z quipo $ // $Id$
// //
/** /**

View File

@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: mysql.php 295587 2010-02-28 17:16:38Z quipo $ // $Id$
// //
require_once 'MDB2/Driver/Function/Common.php'; require_once 'MDB2/Driver/Function/Common.php';

View File

@ -42,7 +42,7 @@
// | Author: Paul Cooper <pgc@ucecom.com> | // | Author: Paul Cooper <pgc@ucecom.com> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: pgsql.php 296139 2010-03-13 04:15:22Z afz $ // $Id$
require_once 'MDB2/Driver/Function/Common.php'; require_once 'MDB2/Driver/Function/Common.php';

View File

@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: sqlite.php 295587 2010-02-28 17:16:38Z quipo $ // $Id$
// //
require_once 'MDB2/Driver/Function/Common.php'; require_once 'MDB2/Driver/Function/Common.php';

View File

@ -43,7 +43,7 @@
// | Lorenzo Alberton <l.alberton@quipo.it> | // | Lorenzo Alberton <l.alberton@quipo.it> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: Common.php 295587 2010-02-28 17:16:38Z quipo $ // $Id$
// //
/** /**
@ -385,7 +385,11 @@ class MDB2_Driver_Manager_Common extends MDB2_Module_Common
} }
$name = $db->quoteIdentifier($name, true); $name = $db->quoteIdentifier($name, true);
return $db->exec("DROP TABLE $name"); $result = $db->exec("DROP TABLE $name");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -407,7 +411,11 @@ class MDB2_Driver_Manager_Common extends MDB2_Module_Common
} }
$name = $db->quoteIdentifier($name, true); $name = $db->quoteIdentifier($name, true);
return $db->exec("DELETE FROM $name"); $result = $db->exec("DELETE FROM $name");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -761,7 +769,11 @@ class MDB2_Driver_Manager_Common extends MDB2_Module_Common
$fields[] = $db->quoteIdentifier($field, true); $fields[] = $db->quoteIdentifier($field, true);
} }
$query .= ' ('. implode(', ', $fields) . ')'; $query .= ' ('. implode(', ', $fields) . ')';
return $db->exec($query); $result = $db->exec($query);
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -783,7 +795,11 @@ class MDB2_Driver_Manager_Common extends MDB2_Module_Common
} }
$name = $db->quoteIdentifier($db->getIndexName($name), true); $name = $db->quoteIdentifier($db->getIndexName($name), true);
return $db->exec("DROP INDEX $name"); $result = $db->exec("DROP INDEX $name");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -895,7 +911,11 @@ class MDB2_Driver_Manager_Common extends MDB2_Module_Common
$query .= ' ('. implode(', ', $referenced_fields) . ')'; $query .= ' ('. implode(', ', $referenced_fields) . ')';
$query .= $this->_getAdvancedFKOptions($definition); $query .= $this->_getAdvancedFKOptions($definition);
} }
return $db->exec($query); $result = $db->exec($query);
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -919,7 +939,11 @@ class MDB2_Driver_Manager_Common extends MDB2_Module_Common
$table = $db->quoteIdentifier($table, true); $table = $db->quoteIdentifier($table, true);
$name = $db->quoteIdentifier($db->getIndexName($name), true); $name = $db->quoteIdentifier($db->getIndexName($name), true);
return $db->exec("ALTER TABLE $table DROP CONSTRAINT $name"); $result = $db->exec("ALTER TABLE $table DROP CONSTRAINT $name");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}

View File

@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: mysql.php 302865 2010-08-29 10:30:55Z quipo $ // $Id$
// //
require_once 'MDB2/Driver/Manager/Common.php'; require_once 'MDB2/Driver/Manager/Common.php';
@ -327,7 +327,11 @@ class MDB2_Driver_Manager_mysql extends MDB2_Driver_Manager_Common
} }
$name = $db->quoteIdentifier($name, true); $name = $db->quoteIdentifier($name, true);
return $db->exec("TRUNCATE TABLE $name"); $result = $db->exec("TRUNCATE TABLE $name");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -374,7 +378,10 @@ class MDB2_Driver_Manager_mysql extends MDB2_Driver_Manager_Common
return $result; return $result;
} }
if (!empty($options['analyze'])) { if (!empty($options['analyze'])) {
return $db->exec('ANALYZE TABLE '.$table); $result = $db->exec('ANALYZE TABLE '.$table);
if (MDB2::isError($result)) {
return $result;
}
} }
return MDB2_OK; return MDB2_OK;
} }
@ -561,7 +568,11 @@ class MDB2_Driver_Manager_mysql extends MDB2_Driver_Manager_Common
} }
$name = $db->quoteIdentifier($name, true); $name = $db->quoteIdentifier($name, true);
return $db->exec("ALTER TABLE $name $query"); $result = $db->exec("ALTER TABLE $name $query");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -832,7 +843,11 @@ class MDB2_Driver_Manager_mysql extends MDB2_Driver_Manager_Common
} }
} }
$query .= ' ('. implode(', ', $fields) . ')'; $query .= ' ('. implode(', ', $fields) . ')';
return $db->exec($query); $result = $db->exec($query);
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -855,7 +870,11 @@ class MDB2_Driver_Manager_mysql extends MDB2_Driver_Manager_Common
$table = $db->quoteIdentifier($table, true); $table = $db->quoteIdentifier($table, true);
$name = $db->quoteIdentifier($db->getIndexName($name), true); $name = $db->quoteIdentifier($db->getIndexName($name), true);
return $db->exec("DROP INDEX $name ON $table"); $result = $db->exec("DROP INDEX $name ON $table");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -1015,7 +1034,11 @@ class MDB2_Driver_Manager_mysql extends MDB2_Driver_Manager_Common
if ($primary || strtolower($name) == 'primary') { if ($primary || strtolower($name) == 'primary') {
$query = 'ALTER TABLE '. $db->quoteIdentifier($table, true) .' DROP PRIMARY KEY'; $query = 'ALTER TABLE '. $db->quoteIdentifier($table, true) .' DROP PRIMARY KEY';
return $db->exec($query); $result = $db->exec($query);
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
//is it a FK constraint? If so, also delete the associated triggers //is it a FK constraint? If so, also delete the associated triggers
@ -1031,13 +1054,21 @@ class MDB2_Driver_Manager_mysql extends MDB2_Driver_Manager_Common
$table = $db->quoteIdentifier($table, true); $table = $db->quoteIdentifier($table, true);
$name = $db->quoteIdentifier($db->getIndexName($name), true); $name = $db->quoteIdentifier($db->getIndexName($name), true);
$query = "ALTER TABLE $table DROP FOREIGN KEY $name"; $query = "ALTER TABLE $table DROP FOREIGN KEY $name";
return $db->exec($query); $result = $db->exec($query);
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
$table = $db->quoteIdentifier($table, true); $table = $db->quoteIdentifier($table, true);
$name = $db->quoteIdentifier($db->getIndexName($name), true); $name = $db->quoteIdentifier($db->getIndexName($name), true);
$query = "ALTER TABLE $table DROP INDEX $name"; $query = "ALTER TABLE $table DROP INDEX $name";
return $db->exec($query); $result = $db->exec($query);
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -1390,7 +1421,11 @@ class MDB2_Driver_Manager_mysql extends MDB2_Driver_Manager_Common
} }
$sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true); $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
return $db->exec("DROP TABLE $sequence_name"); $result = $db->exec("DROP TABLE $sequence_name");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}

View File

@ -42,7 +42,7 @@
// | Author: Paul Cooper <pgc@ucecom.com> | // | Author: Paul Cooper <pgc@ucecom.com> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: pgsql.php 299393 2010-05-14 17:49:49Z afz $ // $Id$
require_once 'MDB2/Driver/Manager/Common.php'; require_once 'MDB2/Driver/Manager/Common.php';
@ -193,7 +193,11 @@ class MDB2_Driver_Manager_pgsql extends MDB2_Driver_Manager_Common
} }
$name = $db->quoteIdentifier($name, true); $name = $db->quoteIdentifier($name, true);
return $db->exec("TRUNCATE TABLE $name"); $result = $db->exec("TRUNCATE TABLE $name");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -234,7 +238,11 @@ class MDB2_Driver_Manager_pgsql extends MDB2_Driver_Manager_Common
if (!empty($table)) { if (!empty($table)) {
$query .= ' '.$db->quoteIdentifier($table, true); $query .= ' '.$db->quoteIdentifier($table, true);
} }
return $db->exec($query); $result = $db->exec($query);
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -801,11 +809,19 @@ class MDB2_Driver_Manager_pgsql extends MDB2_Driver_Manager_Common
} }
if (in_array($name, $unique)) { if (in_array($name, $unique)) {
return $db->exec('DROP INDEX '.$db->quoteIdentifier($name, true)); $result = $db->exec('DROP INDEX '.$db->quoteIdentifier($name, true));
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
$idxname = $db->getIndexName($name); $idxname = $db->getIndexName($name);
if (in_array($idxname, $unique)) { if (in_array($idxname, $unique)) {
return $db->exec('DROP INDEX '.$db->quoteIdentifier($idxname, true)); $result = $db->exec('DROP INDEX '.$db->quoteIdentifier($idxname, true));
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
$name . ' is not an existing constraint for table ' . $table, __FUNCTION__); $name . ' is not an existing constraint for table ' . $table, __FUNCTION__);
@ -894,8 +910,12 @@ class MDB2_Driver_Manager_pgsql extends MDB2_Driver_Manager_Common
} }
$sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true); $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
return $db->exec("CREATE SEQUENCE $sequence_name INCREMENT 1". $result = $db->exec("CREATE SEQUENCE $sequence_name INCREMENT 1".
($start < 1 ? " MINVALUE $start" : '')." START $start"); ($start < 1 ? " MINVALUE $start" : '')." START $start");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -916,7 +936,11 @@ class MDB2_Driver_Manager_pgsql extends MDB2_Driver_Manager_Common
} }
$sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true); $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
return $db->exec("DROP SEQUENCE $sequence_name"); $result = $db->exec("DROP SEQUENCE $sequence_name");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}

View File

@ -43,7 +43,7 @@
// | Lorenzo Alberton <l.alberton@quipo.it> | // | Lorenzo Alberton <l.alberton@quipo.it> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: sqlite.php 295587 2010-02-28 17:16:38Z quipo $ // $Id$
// //
require_once 'MDB2/Driver/Manager/Common.php'; require_once 'MDB2/Driver/Manager/Common.php';
@ -405,7 +405,11 @@ class MDB2_Driver_Manager_sqlite extends MDB2_Driver_Manager_Common
} }
$name = $db->quoteIdentifier($name, true); $name = $db->quoteIdentifier($name, true);
return $db->exec("DROP TABLE $name"); $result = $db->exec("DROP TABLE $name");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -436,7 +440,11 @@ class MDB2_Driver_Manager_sqlite extends MDB2_Driver_Manager_Common
if (!empty($table)) { if (!empty($table)) {
$query .= ' '.$db->quoteIdentifier($table, true); $query .= ' '.$db->quoteIdentifier($table, true);
} }
return $db->exec($query); $result = $db->exec($query);
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -964,11 +972,11 @@ class MDB2_Driver_Manager_sqlite extends MDB2_Driver_Manager_Common
} }
$table = $db->quoteIdentifier($table, true); $table = $db->quoteIdentifier($table, true);
$name = $db->getIndexName($name); $name = $db->quoteIdentifier($db->getIndexName($name), true);
$query = "CREATE INDEX $name ON $table"; $query = "CREATE INDEX $name ON $table";
$fields = array(); $fields = array();
foreach ($definition['fields'] as $field_name => $field) { foreach ($definition['fields'] as $field_name => $field) {
$field_string = $field_name; $field_string = $db->quoteIdentifier($field_name, true);
if (!empty($field['sorting'])) { if (!empty($field['sorting'])) {
switch ($field['sorting']) { switch ($field['sorting']) {
case 'ascending': case 'ascending':
@ -982,7 +990,11 @@ class MDB2_Driver_Manager_sqlite extends MDB2_Driver_Manager_Common
$fields[] = $field_string; $fields[] = $field_string;
} }
$query .= ' ('.implode(', ', $fields) . ')'; $query .= ' ('.implode(', ', $fields) . ')';
return $db->exec($query); $result = $db->exec($query);
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -1004,7 +1016,11 @@ class MDB2_Driver_Manager_sqlite extends MDB2_Driver_Manager_Common
} }
$name = $db->getIndexName($name); $name = $db->getIndexName($name);
return $db->exec("DROP INDEX $name"); $result = $db->exec("DROP INDEX $name");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -1112,7 +1128,11 @@ class MDB2_Driver_Manager_sqlite extends MDB2_Driver_Manager_Common
$fields[] = $field_string; $fields[] = $field_string;
} }
$query .= ' ('.implode(', ', $fields) . ')'; $query .= ' ('.implode(', ', $fields) . ')';
return $db->exec($query); $result = $db->exec($query);
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -1152,7 +1172,11 @@ class MDB2_Driver_Manager_sqlite extends MDB2_Driver_Manager_Common
} }
$name = $db->getIndexName($name); $name = $db->getIndexName($name);
return $db->exec("DROP INDEX $name"); $result = $db->exec("DROP INDEX $name");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}
@ -1321,7 +1345,11 @@ class MDB2_Driver_Manager_sqlite extends MDB2_Driver_Manager_Common
} }
$sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true); $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true);
return $db->exec("DROP TABLE $sequence_name"); $result = $db->exec("DROP TABLE $sequence_name");
if (MDB2::isError($result)) {
return $result;
}
return MDB2_OK;
} }
// }}} // }}}

View File

@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: Common.php 242348 2007-09-09 13:47:36Z quipo $ // $Id$
// //
/** /**

View File

@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: mysql.php 215004 2006-06-18 21:59:05Z lsmith $ // $Id$
// //
require_once 'MDB2/Driver/Native/Common.php'; require_once 'MDB2/Driver/Native/Common.php';

View File

@ -42,7 +42,7 @@
// | Author: Paul Cooper <pgc@ucecom.com> | // | Author: Paul Cooper <pgc@ucecom.com> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: pgsql.php 295587 2010-02-28 17:16:38Z quipo $ // $Id$
require_once 'MDB2/Driver/Native/Common.php'; require_once 'MDB2/Driver/Native/Common.php';

View File

@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: sqlite.php 215004 2006-06-18 21:59:05Z lsmith $ // $Id$
// //
require_once 'MDB2/Driver/Native/Common.php'; require_once 'MDB2/Driver/Native/Common.php';

View File

@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: Common.php 295587 2010-02-28 17:16:38Z quipo $ // $Id$
// //
/** /**

View File

@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: mysql.php 295587 2010-02-28 17:16:38Z quipo $ // $Id$
// //
require_once 'MDB2/Driver/Reverse/Common.php'; require_once 'MDB2/Driver/Reverse/Common.php';

View File

@ -43,7 +43,7 @@
// | Lorenzo Alberton <l.alberton@quipo.it> | // | Lorenzo Alberton <l.alberton@quipo.it> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: pgsql.php 295587 2010-02-28 17:16:38Z quipo $ // $Id$
require_once 'MDB2/Driver/Reverse/Common.php'; require_once 'MDB2/Driver/Reverse/Common.php';

View File

@ -43,7 +43,7 @@
// | Lorenzo Alberton <l.alberton@quipo.it> | // | Lorenzo Alberton <l.alberton@quipo.it> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: sqlite.php 295587 2010-02-28 17:16:38Z quipo $ // $Id$
// //
require_once 'MDB2/Driver/Reverse/Common.php'; require_once 'MDB2/Driver/Reverse/Common.php';
@ -95,7 +95,7 @@ class MDB2_Driver_Reverse_sqlite extends MDB2_Driver_Reverse_Common
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'unexpected empty table column definition list', __FUNCTION__); 'unexpected empty table column definition list', __FUNCTION__);
} }
$regexp = '/^\s*([^\s]+) +(CHAR|VARCHAR|VARCHAR2|TEXT|BOOLEAN|SMALLINT|INT|INTEGER|DECIMAL|BIGINT|DOUBLE|FLOAT|DATETIME|DATE|TIME|LONGTEXT|LONGBLOB)( ?\(([1-9][0-9]*)(:([1-9][0-9]*))?\))?( NULL| NOT NULL)?( UNSIGNED)?( NULL| NOT NULL)?( PRIMARY KEY)?( DEFAULT (\'[^\']*\'|[^ ]+))?( NULL| NOT NULL)?( PRIMARY KEY)?(\s*\-\-.*)?$/i'; $regexp = '/^\s*([^\s]+) +(CHAR|VARCHAR|VARCHAR2|TEXT|BOOLEAN|SMALLINT|INT|INTEGER|DECIMAL|TINYINT|BIGINT|DOUBLE|FLOAT|DATETIME|DATE|TIME|LONGTEXT|LONGBLOB)( ?\(([1-9][0-9]*)(:([1-9][0-9]*))?\))?( NULL| NOT NULL)?( UNSIGNED)?( NULL| NOT NULL)?( PRIMARY KEY)?( DEFAULT (\'[^\']*\'|[^ ]+))?( NULL| NOT NULL)?( PRIMARY KEY)?(\s*\-\-.*)?$/i';
$regexp2 = '/^\s*([^ ]+) +(PRIMARY|UNIQUE|CHECK)$/i'; $regexp2 = '/^\s*([^ ]+) +(PRIMARY|UNIQUE|CHECK)$/i';
for ($i=0, $j=0; $i<$count; ++$i) { for ($i=0, $j=0; $i<$count; ++$i) {
if (!preg_match($regexp, trim($column_sql[$i]), $matches)) { if (!preg_match($regexp, trim($column_sql[$i]), $matches)) {
@ -128,6 +128,8 @@ class MDB2_Driver_Reverse_sqlite extends MDB2_Driver_Reverse_Common
$default = null; $default = null;
} }
$columns[$j]['default'] = $default; $columns[$j]['default'] = $default;
} else {
$columns[$j]['default'] = null;
} }
if (isset($matches[7]) && strlen($matches[7])) { if (isset($matches[7]) && strlen($matches[7])) {
$columns[$j]['notnull'] = ($matches[7] === ' NOT NULL'); $columns[$j]['notnull'] = ($matches[7] === ' NOT NULL');

View File

@ -43,7 +43,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: mysql.php 302867 2010-08-29 11:22:07Z quipo $ // $Id$
// //
/** /**
@ -57,21 +57,30 @@ class MDB2_Driver_mysql extends MDB2_Driver_Common
{ {
// {{{ properties // {{{ properties
var $string_quoting = array('start' => "'", 'end' => "'", 'escape' => '\\', 'escape_pattern' => '\\'); public $string_quoting = array(
'start' => "'",
'end' => "'",
'escape' => '\\',
'escape_pattern' => '\\',
);
var $identifier_quoting = array('start' => '`', 'end' => '`', 'escape' => '`'); public $identifier_quoting = array(
'start' => '`',
'end' => '`',
'escape' => '`',
);
var $sql_comments = array( public $sql_comments = array(
array('start' => '-- ', 'end' => "\n", 'escape' => false), array('start' => '-- ', 'end' => "\n", 'escape' => false),
array('start' => '#', 'end' => "\n", 'escape' => false), array('start' => '#', 'end' => "\n", 'escape' => false),
array('start' => '/*', 'end' => '*/', 'escape' => false), array('start' => '/*', 'end' => '*/', 'escape' => false),
); );
var $server_capabilities_checked = false; protected $server_capabilities_checked = false;
var $start_transaction = false; protected $start_transaction = false;
var $varchar_max_length = 255; protected $varchar_max_length = 255;
// }}} // }}}
// {{{ constructor // {{{ constructor
@ -1370,7 +1379,9 @@ class MDB2_Result_mysql extends MDB2_Result_Common
if ($fetchmode == MDB2_FETCHMODE_DEFAULT) { if ($fetchmode == MDB2_FETCHMODE_DEFAULT) {
$fetchmode = $this->db->fetchmode; $fetchmode = $this->db->fetchmode;
} }
if ($fetchmode & MDB2_FETCHMODE_ASSOC) { if ( $fetchmode == MDB2_FETCHMODE_ASSOC
|| $fetchmode == MDB2_FETCHMODE_OBJECT
) {
$row = @mysql_fetch_assoc($this->result); $row = @mysql_fetch_assoc($this->result);
if (is_array($row) if (is_array($row)
&& $this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE && $this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
@ -1401,8 +1412,16 @@ class MDB2_Result_mysql extends MDB2_Result_Common
if ($mode) { if ($mode) {
$this->db->_fixResultArrayValues($row, $mode); $this->db->_fixResultArrayValues($row, $mode);
} }
if (!empty($this->types)) { if ( ( $fetchmode != MDB2_FETCHMODE_ASSOC
&& $fetchmode != MDB2_FETCHMODE_OBJECT)
&& !empty($this->types)
) {
$row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim); $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim);
} elseif (($fetchmode == MDB2_FETCHMODE_ASSOC
|| $fetchmode == MDB2_FETCHMODE_OBJECT)
&& !empty($this->types_assoc)
) {
$row = $this->db->datatype->convertResultRow($this->types_assoc, $row, $rtrim);
} }
if (!empty($this->values)) { if (!empty($this->values)) {
$this->_assignBindColumns($row); $this->_assignBindColumns($row);
@ -1600,7 +1619,7 @@ class MDB2_Statement_mysql extends MDB2_Statement_Common
* a MDB2 error on failure * a MDB2 error on failure
* @access private * @access private
*/ */
function _execute($result_class = true, $result_wrap_class = false) function _execute($result_class = true, $result_wrap_class = true)
{ {
if (is_null($this->statement)) { if (is_null($this->statement)) {
$result = parent::_execute($result_class, $result_wrap_class); $result = parent::_execute($result_class, $result_wrap_class);

View File

@ -43,7 +43,7 @@
// | Author: Paul Cooper <pgc@ucecom.com> | // | Author: Paul Cooper <pgc@ucecom.com> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: pgsql.php 295587 2010-02-28 17:16:38Z quipo $ // $Id$
/** /**
* MDB2 PostGreSQL driver * MDB2 PostGreSQL driver
@ -652,7 +652,7 @@ class MDB2_Driver_pgsql extends MDB2_Driver_Common
if ($is_manip) { if ($is_manip) {
$result = $this->_affectedRows($connection, $result); $result = $this->_affectedRows($connection, $result);
} else { } else {
$result =& $this->_wrapResult($result, $types, true, false, $limit, $offset); $result = $this->_wrapResult($result, $types, true, true, $limit, $offset);
} }
} }
@ -959,17 +959,18 @@ class MDB2_Driver_pgsql extends MDB2_Driver_Common
$pgtypes[] = 'text'; $pgtypes[] = 'text';
} }
} }
if (($key_parameter = array_search($name, $positions))) { if (($key_parameter = array_search($name, $positions)) !== false) {
$next_parameter = 1; //$next_parameter = 1;
foreach ($positions as $key => $value) { $parameter = $key_parameter + 1;
if ($key_parameter == $key) { //foreach ($positions as $key => $value) {
break; // if ($key_parameter == $key) {
} // break;
++$next_parameter; // }
} // ++$next_parameter;
//}
} else { } else {
++$parameter; ++$parameter;
$next_parameter = $parameter; //$next_parameter = $parameter;
$positions[] = $name; $positions[] = $name;
} }
$query = substr_replace($query, '$'.$parameter, $position, $length); $query = substr_replace($query, '$'.$parameter, $position, $length);
@ -1178,7 +1179,9 @@ class MDB2_Result_pgsql extends MDB2_Result_Common
if ($fetchmode == MDB2_FETCHMODE_DEFAULT) { if ($fetchmode == MDB2_FETCHMODE_DEFAULT) {
$fetchmode = $this->db->fetchmode; $fetchmode = $this->db->fetchmode;
} }
if ($fetchmode & MDB2_FETCHMODE_ASSOC) { if ( $fetchmode == MDB2_FETCHMODE_ASSOC
|| $fetchmode == MDB2_FETCHMODE_OBJECT
) {
$row = @pg_fetch_array($this->result, null, PGSQL_ASSOC); $row = @pg_fetch_array($this->result, null, PGSQL_ASSOC);
if (is_array($row) if (is_array($row)
&& $this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE && $this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
@ -1208,8 +1211,16 @@ class MDB2_Result_pgsql extends MDB2_Result_Common
if ($mode) { if ($mode) {
$this->db->_fixResultArrayValues($row, $mode); $this->db->_fixResultArrayValues($row, $mode);
} }
if (!empty($this->types)) { if ( ( $fetchmode != MDB2_FETCHMODE_ASSOC
&& $fetchmode != MDB2_FETCHMODE_OBJECT)
&& !empty($this->types)
) {
$row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim); $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim);
} elseif (($fetchmode == MDB2_FETCHMODE_ASSOC
|| $fetchmode == MDB2_FETCHMODE_OBJECT)
&& !empty($this->types_assoc)
) {
$row = $this->db->datatype->convertResultRow($this->types_assoc, $row, $rtrim);
} }
if (!empty($this->values)) { if (!empty($this->values)) {
$this->_assignBindColumns($row); $this->_assignBindColumns($row);
@ -1429,7 +1440,7 @@ class MDB2_Statement_pgsql extends MDB2_Statement_Common
* a MDB2 error on failure * a MDB2 error on failure
* @access private * @access private
*/ */
function _execute($result_class = true, $result_wrap_class = false) function _execute($result_class = true, $result_wrap_class = true)
{ {
if (null === $this->statement) { if (null === $this->statement) {
return parent::_execute($result_class, $result_wrap_class); return parent::_execute($result_class, $result_wrap_class);
@ -1544,5 +1555,29 @@ class MDB2_Statement_pgsql extends MDB2_Statement_Common
parent::free(); parent::free();
return $result; return $result;
} }
/**
* drop an existing table
*
* @param string $name name of the table that should be dropped
* @return mixed MDB2_OK on success, a MDB2 error on failure
* @access public
*/
function dropTable($name)
{
$db = $this->getDBInstance();
if (PEAR::isError($db)) {
return $db;
}
$name = $db->quoteIdentifier($name, true);
$result = $db->exec("DROP TABLE $name");
if (PEAR::isError($result)) {
$result = $db->exec("DROP TABLE $name CASCADE");
}
return $result;
}
} }
?> ?>

View File

@ -43,7 +43,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: sqlite.php 295587 2010-02-28 17:16:38Z quipo $ // $Id$
// //
/** /**
@ -142,6 +142,7 @@ class MDB2_Driver_sqlite extends MDB2_Driver_Common
'/is not unique/' => MDB2_ERROR_CONSTRAINT, '/is not unique/' => MDB2_ERROR_CONSTRAINT,
'/columns .* are not unique/i' => MDB2_ERROR_CONSTRAINT, '/columns .* are not unique/i' => MDB2_ERROR_CONSTRAINT,
'/uniqueness constraint failed/' => MDB2_ERROR_CONSTRAINT, '/uniqueness constraint failed/' => MDB2_ERROR_CONSTRAINT,
'/violates .*constraint/' => MDB2_ERROR_CONSTRAINT,
'/may not be NULL/' => MDB2_ERROR_CONSTRAINT_NOT_NULL, '/may not be NULL/' => MDB2_ERROR_CONSTRAINT_NOT_NULL,
'/^no such column:/' => MDB2_ERROR_NOSUCHFIELD, '/^no such column:/' => MDB2_ERROR_NOSUCHFIELD,
'/no column named/' => MDB2_ERROR_NOSUCHFIELD, '/no column named/' => MDB2_ERROR_NOSUCHFIELD,
@ -893,7 +894,9 @@ class MDB2_Result_sqlite extends MDB2_Result_Common
if ($fetchmode == MDB2_FETCHMODE_DEFAULT) { if ($fetchmode == MDB2_FETCHMODE_DEFAULT) {
$fetchmode = $this->db->fetchmode; $fetchmode = $this->db->fetchmode;
} }
if ($fetchmode & MDB2_FETCHMODE_ASSOC) { if ( $fetchmode == MDB2_FETCHMODE_ASSOC
|| $fetchmode == MDB2_FETCHMODE_OBJECT
) {
$row = @sqlite_fetch_array($this->result, SQLITE_ASSOC); $row = @sqlite_fetch_array($this->result, SQLITE_ASSOC);
if (is_array($row) if (is_array($row)
&& $this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE && $this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE
@ -923,8 +926,16 @@ class MDB2_Result_sqlite extends MDB2_Result_Common
if ($mode) { if ($mode) {
$this->db->_fixResultArrayValues($row, $mode); $this->db->_fixResultArrayValues($row, $mode);
} }
if (!empty($this->types)) { if ( ( $fetchmode != MDB2_FETCHMODE_ASSOC
&& $fetchmode != MDB2_FETCHMODE_OBJECT)
&& !empty($this->types)
) {
$row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim); $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim);
} elseif (($fetchmode == MDB2_FETCHMODE_ASSOC
|| $fetchmode == MDB2_FETCHMODE_OBJECT)
&& !empty($this->types_assoc)
) {
$row = $this->db->datatype->convertResultRow($this->types_assoc, $row, $rtrim);
} }
if (!empty($this->values)) { if (!empty($this->values)) {
$this->_assignBindColumns($row); $this->_assignBindColumns($row);

View File

@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: Extended.php 302784 2010-08-25 23:29:16Z quipo $ // $Id$
/** /**
* @package MDB2 * @package MDB2
@ -645,6 +645,9 @@ class MDB2_Extended extends MDB2_Module_Common
*/ */
function executeMultiple($stmt, $params = null) function executeMultiple($stmt, $params = null)
{ {
if (MDB2::isError($stmt)) {
return $stmt;
}
for ($i = 0, $j = count($params); $i < $j; $i++) { for ($i = 0, $j = count($params); $i < $j; $i++) {
$result = $stmt->execute($params[$i]); $result = $stmt->execute($params[$i]);
if (PEAR::isError($result)) { if (PEAR::isError($result)) {

View File

@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: Iterator.php 295586 2010-02-28 17:04:17Z quipo $ // $Id$
/** /**
* PHP5 Iterator * PHP5 Iterator
@ -54,6 +54,9 @@
class MDB2_Iterator implements Iterator class MDB2_Iterator implements Iterator
{ {
protected $fetchmode; protected $fetchmode;
/**
* @var MDB2_Result_Common
*/
protected $result; protected $result;
protected $row; protected $row;
@ -62,7 +65,7 @@ class MDB2_Iterator implements Iterator
/** /**
* Constructor * Constructor
*/ */
public function __construct($result, $fetchmode = MDB2_FETCHMODE_DEFAULT) public function __construct(MDB2_Result_Common $result, $fetchmode = MDB2_FETCHMODE_DEFAULT)
{ {
$this->result = $result; $this->result = $result;
$this->fetchmode = $fetchmode; $this->fetchmode = $fetchmode;

View File

@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> | // | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: LOB.php 222350 2006-10-25 11:52:21Z lsmith $ // $Id$
/** /**
* @package MDB2 * @package MDB2

View File

@ -1,8 +1,6 @@
<?php <?php /* vim: se et ts=4 sw=4 sts=4 fdm=marker tw=80: */
/** /**
* PHP version 4, 5 * Copyright (c) 1998-2010 Manuel Lemos, Tomas V.V.Cox,
*
* Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox,
* Stig. S. Bakken, Lukas Smith, Igor Feghali * Stig. S. Bakken, Lukas Smith, Igor Feghali
* All rights reserved. * All rights reserved.
* *
@ -39,15 +37,14 @@
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Author: Lukas Smith <smith@pooteeweet.org> * PHP version 5
* Author: Igor Feghali <ifeghali@php.net>
* *
* @category Database * @category Database
* @package MDB2_Schema * @package MDB2_Schema
* @author Lukas Smith <smith@pooteeweet.org> * @author Lukas Smith <smith@pooteeweet.org>
* @author Igor Feghali <ifeghali@php.net> * @author Igor Feghali <ifeghali@php.net>
* @license BSD http://www.opensource.org/licenses/bsd-license.php * @license BSD http://www.opensource.org/licenses/bsd-license.php
* @version CVS: $Id: Schema.php,v 1.132 2009/02/22 21:43:22 ifeghali Exp $ * @version SVN: $Id$
* @link http://pear.php.net/packages/MDB2_Schema * @link http://pear.php.net/packages/MDB2_Schema
*/ */
@ -96,7 +93,7 @@ class MDB2_Schema extends PEAR
'parser' => 'MDB2_Schema_Parser', 'parser' => 'MDB2_Schema_Parser',
'writer' => 'MDB2_Schema_Writer', 'writer' => 'MDB2_Schema_Writer',
'validate' => 'MDB2_Schema_Validate', 'validate' => 'MDB2_Schema_Validate',
'drop_missing_tables' => false 'drop_obsolete_objects' => false
); );
// }}} // }}}
@ -237,9 +234,9 @@ class MDB2_Schema extends PEAR
* @access public * @access public
* @see MDB2::parseDSN * @see MDB2::parseDSN
*/ */
function &factory(&$db, $options = array()) static function &factory(&$db, $options = array())
{ {
$obj =& new MDB2_Schema(); $obj = new MDB2_Schema();
$result = $obj->connect($db, $options); $result = $obj->connect($db, $options);
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
@ -284,14 +281,14 @@ class MDB2_Schema extends PEAR
$this->disconnect(); $this->disconnect();
if (!MDB2::isConnection($db)) { if (!MDB2::isConnection($db)) {
$db =& MDB2::factory($db, $db_options); $db = MDB2::factory($db, $db_options);
} }
if (PEAR::isError($db)) { if (PEAR::isError($db)) {
return $db; return $db;
} }
$this->db =& $db; $this->db = $db;
$this->db->loadModule('Datatype'); $this->db->loadModule('Datatype');
$this->db->loadModule('Manager'); $this->db->loadModule('Manager');
$this->db->loadModule('Reverse'); $this->db->loadModule('Reverse');
@ -380,7 +377,7 @@ class MDB2_Schema extends PEAR
$dtd_file = $this->options['dtd_file']; $dtd_file = $this->options['dtd_file'];
if ($dtd_file) { if ($dtd_file) {
include_once 'XML/DTD/XmlValidator.php'; include_once 'XML/DTD/XmlValidator.php';
$dtd =& new XML_DTD_XmlValidator; $dtd = new XML_DTD_XmlValidator;
if (!$dtd->isValid($dtd_file, $input_file)) { if (!$dtd->isValid($dtd_file, $input_file)) {
return $this->raiseError(MDB2_SCHEMA_ERROR_PARSE, null, null, $dtd->getMessage()); return $this->raiseError(MDB2_SCHEMA_ERROR_PARSE, null, null, $dtd->getMessage());
} }
@ -393,7 +390,16 @@ class MDB2_Schema extends PEAR
return $result; return $result;
} }
$parser =& new $class_name($variables, $fail_on_invalid_names, $structure, $this->options['valid_types'], $this->options['force_defaults']); $max_identifiers_length = null;
if (isset($this->db->options['max_identifiers_length'])) {
$max_identifiers_length = $this->db->options['max_identifiers_length'];
}
$parser = new $class_name($variables, $fail_on_invalid_names, $structure,
$this->options['valid_types'], $this->options['force_defaults'],
$max_identifiers_length
);
$result = $parser->setInputFile($input_file); $result = $parser->setInputFile($input_file);
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
return $result; return $result;
@ -436,7 +442,17 @@ class MDB2_Schema extends PEAR
return $result; return $result;
} }
$val =& new $class_name($this->options['fail_on_invalid_names'], $this->options['valid_types'], $this->options['force_defaults']); $max_identifiers_length = null;
if (isset($this->db->options['max_identifiers_length'])) {
$max_identifiers_length = $this->db->options['max_identifiers_length'];
}
$val = new $class_name(
$this->options['fail_on_invalid_names'],
$this->options['valid_types'],
$this->options['force_defaults'],
$max_identifiers_length
);
$database_definition = array( $database_definition = array(
'name' => $database, 'name' => $database,
@ -470,7 +486,7 @@ class MDB2_Schema extends PEAR
'initialization' => array() 'initialization' => array()
); );
$table_definition =& $database_definition['tables'][$table_name]; $table_definition = $database_definition['tables'][$table_name];
foreach ($fields as $field_name) { foreach ($fields as $field_name) {
$definition = $this->db->reverse->getTableFieldDefinition($table_name, $field_name); $definition = $this->db->reverse->getTableFieldDefinition($table_name, $field_name);
if (PEAR::isError($definition)) { if (PEAR::isError($definition)) {
@ -1455,16 +1471,17 @@ class MDB2_Schema extends PEAR
$changes['tables'] = MDB2_Schema::arrayMergeClobber($changes['tables'], $change); $changes['tables'] = MDB2_Schema::arrayMergeClobber($changes['tables'], $change);
} }
} }
}
if (!empty($previous_definition['tables']) if (!empty($previous_definition['tables'])
&& is_array($previous_definition['tables'])) { && is_array($previous_definition['tables'])
) {
foreach ($previous_definition['tables'] as $table_name => $table) { foreach ($previous_definition['tables'] as $table_name => $table) {
if (empty($defined_tables[$table_name])) { if (empty($defined_tables[$table_name])) {
$changes['tables']['remove'][$table_name] = true; $changes['tables']['remove'][$table_name] = true;
} }
} }
} }
}
if (!empty($current_definition['sequences']) && is_array($current_definition['sequences'])) { if (!empty($current_definition['sequences']) && is_array($current_definition['sequences'])) {
$changes['sequences'] = $defined_sequences = array(); $changes['sequences'] = $defined_sequences = array();
foreach ($current_definition['sequences'] as $sequence_name => $sequence) { foreach ($current_definition['sequences'] as $sequence_name => $sequence) {
@ -1484,14 +1501,17 @@ class MDB2_Schema extends PEAR
$changes['sequences'] = MDB2_Schema::arrayMergeClobber($changes['sequences'], $change); $changes['sequences'] = MDB2_Schema::arrayMergeClobber($changes['sequences'], $change);
} }
} }
if (!empty($previous_definition['sequences']) && is_array($previous_definition['sequences'])) { }
if (!empty($previous_definition['sequences'])
&& is_array($previous_definition['sequences'])
) {
foreach ($previous_definition['sequences'] as $sequence_name => $sequence) { foreach ($previous_definition['sequences'] as $sequence_name => $sequence) {
if (empty($defined_sequences[$sequence_name])) { if (empty($defined_sequences[$sequence_name])) {
$changes['sequences']['remove'][$sequence_name] = true; $changes['sequences']['remove'][$sequence_name] = true;
} }
} }
} }
}
return $changes; return $changes;
} }
@ -2022,9 +2042,10 @@ class MDB2_Schema extends PEAR
} }
} }
if ($this->options['drop_missing_tables'] if ($this->options['drop_obsolete_objects']
&& !empty($changes['remove']) && !empty($changes['remove'])
&& is_array($changes['remove'])) { && is_array($changes['remove'])
) {
foreach ($changes['remove'] as $table_name => $table) { foreach ($changes['remove'] as $table_name => $table) {
$result = $this->db->manager->dropTable($table_name); $result = $this->db->manager->dropTable($table_name);
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
@ -2105,7 +2126,10 @@ class MDB2_Schema extends PEAR
} }
} }
if (!empty($changes['remove']) && is_array($changes['remove'])) { if ($this->options['drop_obsolete_objects']
&& !empty($changes['remove'])
&& is_array($changes['remove'])
) {
foreach ($changes['remove'] as $sequence_name => $sequence) { foreach ($changes['remove'] as $sequence_name => $sequence) {
$result = $this->db->manager->dropSequence($sequence_name); $result = $this->db->manager->dropSequence($sequence_name);
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
@ -2232,7 +2256,7 @@ class MDB2_Schema extends PEAR
} }
if (!empty($changes['tables']['remove']) && is_array($changes['tables']['remove'])) { if (!empty($changes['tables']['remove']) && is_array($changes['tables']['remove'])) {
if ($this->options['drop_missing_tables']) { if ($this->options['drop_obsolete_objects']) {
foreach ($changes['tables']['remove'] as $table_name => $table) { foreach ($changes['tables']['remove'] as $table_name => $table) {
$this->db->debug("$table_name:", __FUNCTION__); $this->db->debug("$table_name:", __FUNCTION__);
$this->db->debug("\tRemoved table '$table_name'", __FUNCTION__); $this->db->debug("\tRemoved table '$table_name'", __FUNCTION__);
@ -2338,9 +2362,15 @@ class MDB2_Schema extends PEAR
} }
} }
if (!empty($changes['sequences']['remove']) && is_array($changes['sequences']['remove'])) { if (!empty($changes['sequences']['remove']) && is_array($changes['sequences']['remove'])) {
if ($this->options['drop_obsolete_objects']) {
foreach ($changes['sequences']['remove'] as $sequence_name => $sequence) { foreach ($changes['sequences']['remove'] as $sequence_name => $sequence) {
$this->db->debug("$sequence_name:", __FUNCTION__); $this->db->debug("$sequence_name:", __FUNCTION__);
$this->db->debug("\tAdded sequence '$sequence_name'", __FUNCTION__); $this->db->debug("\tRemoved sequence '$sequence_name'", __FUNCTION__);
}
} else {
foreach ($changes['sequences']['remove'] as $sequence_name => $sequence) {
$this->db->debug("\tObsolete sequence '$sequence_name' left as is", __FUNCTION__);
}
} }
} }
if (!empty($changes['sequences']['change']) && is_array($changes['sequences']['change'])) { if (!empty($changes['sequences']['change']) && is_array($changes['sequences']['change'])) {
@ -2448,7 +2478,7 @@ class MDB2_Schema extends PEAR
} }
} }
$writer =& new $class_name($this->options['valid_types']); $writer = new $class_name($this->options['valid_types']);
return $writer->dumpDatabase($database_definition, $arguments, $dump); return $writer->dumpDatabase($database_definition, $arguments, $dump);
} }
@ -2696,9 +2726,9 @@ class MDB2_Schema extends PEAR
* @access public * @access public
* @see PEAR_Error * @see PEAR_Error
*/ */
function &raiseError($code = null, $mode = null, $options = null, $userinfo = null) static function &raiseError($code = null, $mode = null, $options = null, $userinfo = null, $dummy1 = null, $dummy2 = null, $dummy3 = false)
{ {
$err =& PEAR::raiseError(null, $code, $mode, $options, $err = PEAR::raiseError(null, $code, $mode, $options,
$userinfo, 'MDB2_Schema_Error', true); $userinfo, 'MDB2_Schema_Error', true);
return $err; return $err;
} }
@ -2717,7 +2747,7 @@ class MDB2_Schema extends PEAR
* @return bool true if parameter is an error * @return bool true if parameter is an error
* @access public * @access public
*/ */
function isError($data, $code = null) static function isError($data, $code = null)
{ {
if (is_a($data, 'MDB2_Schema_Error')) { if (is_a($data, 'MDB2_Schema_Error')) {
if (is_null($code)) { if (is_null($code)) {
@ -2764,4 +2794,3 @@ class MDB2_Schema_Error extends PEAR_Error
$mode, $level, $debuginfo); $mode, $level, $debuginfo);
} }
} }
?>

View File

@ -1,8 +1,6 @@
<?php <?php /* vim: se et ts=4 sw=4 sts=4 fdm=marker tw=80: */
/** /**
* PHP versions 4 and 5 * Copyright (c) 1998-2010 Manuel Lemos, Tomas V.V.Cox,
*
* Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox,
* Stig. S. Bakken, Lukas Smith, Igor Feghali * Stig. S. Bakken, Lukas Smith, Igor Feghali
* All rights reserved. * All rights reserved.
* *
@ -39,21 +37,17 @@
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Author: Christian Dickmann <dickmann@php.net> * PHP version 5
* Author: Igor Feghali <ifeghali@php.net>
*
* $Id: Parser.php,v 1.68 2008/11/30 03:34:00 clockwerx Exp $
* *
* @category Database * @category Database
* @package MDB2_Schema * @package MDB2_Schema
* @author Christian Dickmann <dickmann@php.net> * @author Christian Dickmann <dickmann@php.net>
* @author Igor Feghali <ifeghali@php.net> * @author Igor Feghali <ifeghali@php.net>
* @license BSD http://www.opensource.org/licenses/bsd-license.php * @license BSD http://www.opensource.org/licenses/bsd-license.php
* @version CVS: $Id: Parser.php,v 1.68 2008/11/30 03:34:00 clockwerx Exp $ * @version SVN: $Id$
* @link http://pear.php.net/packages/MDB2_Schema * @link http://pear.php.net/packages/MDB2_Schema
*/ */
require_once 'XML/Parser.php'; require_once 'XML/Parser.php';
require_once 'MDB2/Schema/Validate.php'; require_once 'MDB2/Schema/Validate.php';
@ -114,27 +108,83 @@ class MDB2_Schema_Parser extends XML_Parser
var $val; var $val;
/**
* PHP 5 constructor
*
* @param array $variables mixed array with user defined schema
* variables
* @param bool $fail_on_invalid_names array with reserved words per RDBMS
* @param array $structure multi dimensional array with
* database schema and data
* @param array $valid_types information of all valid fields
* types
* @param bool $force_defaults if true sets a default value to
* field when not explicit
* @param int $max_identifiers_length maximum allowed size for entities
* name
*
* @return void
*
* @access public
* @static
*/
function __construct($variables, $fail_on_invalid_names = true, function __construct($variables, $fail_on_invalid_names = true,
$structure = false, $valid_types = array(), $structure = false, $valid_types = array(), $force_defaults = true,
$force_defaults = true) $max_identifiers_length = null
{ ) {
// force ISO-8859-1 due to different defaults for PHP4 and PHP5 // force ISO-8859-1 due to different defaults for PHP4 and PHP5
// todo: this probably needs to be investigated some more andcleaned up // todo: this probably needs to be investigated some more andcleaned up
parent::XML_Parser('ISO-8859-1'); parent::__construct('ISO-8859-1');
$this->variables = $variables; $this->variables = $variables;
$this->structure = $structure; $this->structure = $structure;
$this->val =& new MDB2_Schema_Validate($fail_on_invalid_names, $valid_types, $force_defaults); $this->val = new MDB2_Schema_Validate(
$fail_on_invalid_names,
$valid_types,
$force_defaults,
$max_identifiers_length
);
} }
/**
* PHP 4 compatible constructor
*
* @param array $variables mixed array with user defined schema
* variables
* @param bool $fail_on_invalid_names array with reserved words per RDBMS
* @param array $structure multi dimensional array with
* database schema and data
* @param array $valid_types information of all valid fields
* types
* @param bool $force_defaults if true sets a default value to
* field when not explicit
* @param int $max_identifiers_length maximum allowed size for entities
* name
*
* @return void
*
* @access public
* @static
*/
function MDB2_Schema_Parser($variables, $fail_on_invalid_names = true, function MDB2_Schema_Parser($variables, $fail_on_invalid_names = true,
$structure = false, $valid_types = array(), $structure = false, $valid_types = array(), $force_defaults = true,
$force_defaults = true) $max_identifiers_length = null
{ ) {
$this->__construct($variables, $fail_on_invalid_names, $structure, $valid_types, $force_defaults); $this->__construct($variables, $fail_on_invalid_names, $structure, $valid_types, $force_defaults);
} }
function startHandler($xp, $element, $attribs) /**
* Triggered when reading a XML open tag <element>
*
* @param resource $xp xml parser resource
* @param string $element element name
* @param array $attribs attributes
*
* @return void
* @access private
* @static
*/
function startHandler($xp, $element, &$attribs)
{ {
if (strtolower($element) == 'variable') { if (strtolower($element) == 'variable') {
$this->var_mode = true; $this->var_mode = true;
@ -335,12 +385,21 @@ class MDB2_Schema_Parser extends XML_Parser
'start' => '', 'start' => '',
'description' => '', 'description' => '',
'comments' => '', 'comments' => '',
'on' => array('table' => '', 'field' => '')
); );
break; break;
} }
} }
/**
* Triggered when reading a XML close tag </element>
*
* @param resource $xp xml parser resource
* @param string $element element name
*
* @return void
* @access private
* @static
*/
function endHandler($xp, $element) function endHandler($xp, $element)
{ {
if (strtolower($element) == 'variable') { if (strtolower($element) == 'variable') {
@ -503,7 +562,21 @@ class MDB2_Schema_Parser extends XML_Parser
$this->element = implode('-', $this->elements); $this->element = implode('-', $this->elements);
} }
function &raiseError($msg = null, $xmlecode = 0, $xp = null, $ecode = MDB2_SCHEMA_ERROR_PARSE) /**
* Pushes a MDB2_Schema_Error into stack and returns it
*
* @param string $msg textual message
* @param int $xmlecode PHP's XML parser error code
* @param resource $xp xml parser resource
* @param int $ecode MDB2_Schema's error code
*
* @return object
* @access private
* @static
*/
static function &raiseError($msg = null, $xmlecode = 0, $xp = null, $ecode = MDB2_SCHEMA_ERROR_PARSE, $userinfo = null,
$error_class = null,
$skipmsg = false)
{ {
if (is_null($this->error)) { if (is_null($this->error)) {
$error = ''; $error = '';
@ -530,11 +603,21 @@ class MDB2_Schema_Parser extends XML_Parser
$error .= "\n"; $error .= "\n";
$this->error =& MDB2_Schema::raiseError($ecode, null, null, $error); $this->error = MDB2_Schema::raiseError($ecode, null, null, $error);
} }
return $this->error; return $this->error;
} }
/**
* Triggered when reading data in a XML element (text between tags)
*
* @param resource $xp xml parser resource
* @param string $data text
*
* @return void
* @access private
* @static
*/
function cdataHandler($xp, $data) function cdataHandler($xp, $data)
{ {
if ($this->var_mode == true) { if ($this->var_mode == true) {
@ -806,6 +889,9 @@ class MDB2_Schema_Parser extends XML_Parser
case 'database-sequence-comments': case 'database-sequence-comments':
$this->sequence['comments'] .= $data; $this->sequence['comments'] .= $data;
break; break;
case 'database-sequence-on':
$this->sequence['on'] = array('table' => '', 'field' => '');
break;
case 'database-sequence-on-table': case 'database-sequence-on-table':
$this->sequence['on']['table'] .= $data; $this->sequence['on']['table'] .= $data;
break; break;
@ -815,5 +901,3 @@ class MDB2_Schema_Parser extends XML_Parser
} }
} }
} }
?>

View File

@ -1,8 +1,6 @@
<?php <?php /* vim: se et ts=4 sw=4 sts=4 fdm=marker tw=80: */
/** /**
* PHP versions 4 and 5 * Copyright (c) 1998-2010 Manuel Lemos, Tomas V.V.Cox,
*
* Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox,
* Stig. S. Bakken, Lukas Smith, Igor Feghali * Stig. S. Bakken, Lukas Smith, Igor Feghali
* All rights reserved. * All rights reserved.
* *
@ -39,13 +37,13 @@
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Author: Igor Feghali <ifeghali@php.net> * PHP version 5
* *
* @category Database * @category Database
* @package MDB2_Schema * @package MDB2_Schema
* @author Igor Feghali <ifeghali@php.net> * @author Igor Feghali <ifeghali@php.net>
* @license BSD http://www.opensource.org/licenses/bsd-license.php * @license BSD http://www.opensource.org/licenses/bsd-license.php
* @version CVS: $Id: Parser2.php,v 1.12 2008/11/30 03:34:00 clockwerx Exp $ * @version SVN: $Id$
* @link http://pear.php.net/packages/MDB2_Schema * @link http://pear.php.net/packages/MDB2_Schema
*/ */
@ -100,8 +98,30 @@ class MDB2_Schema_Parser2 extends XML_Unserializer
var $init = array(); var $init = array();
function __construct($variables, $fail_on_invalid_names = true, $structure = false, $valid_types = array(), $force_defaults = true) /**
{ * PHP 5 constructor
*
* @param array $variables mixed array with user defined schema
* variables
* @param bool $fail_on_invalid_names array with reserved words per RDBMS
* @param array $structure multi dimensional array with
* database schema and data
* @param array $valid_types information of all valid fields
* types
* @param bool $force_defaults if true sets a default value to
* field when not explicit
* @param int $max_identifiers_length maximum allowed size for entities
* name
*
* @return void
*
* @access public
* @static
*/
function __construct($variables, $fail_on_invalid_names = true,
$structure = false, $valid_types = array(), $force_defaults = true,
$max_identifiers_length = null
) {
// force ISO-8859-1 due to different defaults for PHP4 and PHP5 // force ISO-8859-1 due to different defaults for PHP4 and PHP5
// todo: this probably needs to be investigated some more and cleaned up // todo: this probably needs to be investigated some more and cleaned up
$this->options['encoding'] = 'ISO-8859-1'; $this->options['encoding'] = 'ISO-8859-1';
@ -119,15 +139,44 @@ class MDB2_Schema_Parser2 extends XML_Unserializer
$this->variables = $variables; $this->variables = $variables;
$this->structure = $structure; $this->structure = $structure;
$this->val =& new MDB2_Schema_Validate($fail_on_invalid_names, $valid_types, $force_defaults); $this->val = new MDB2_Schema_Validate($fail_on_invalid_names, $valid_types, $force_defaults);
parent::XML_Unserializer($this->options); parent::XML_Unserializer($this->options);
} }
function MDB2_Schema_Parser2($variables, $fail_on_invalid_names = true, $structure = false, $valid_types = array(), $force_defaults = true) /**
{ * PHP 4 compatible constructor
*
* @param array $variables mixed array with user defined schema
* variables
* @param bool $fail_on_invalid_names array with reserved words per RDBMS
* @param array $structure multi dimensional array with
* database schema and data
* @param array $valid_types information of all valid fields
* types
* @param bool $force_defaults if true sets a default value to
* field when not explicit
* @param int $max_identifiers_length maximum allowed size for entities
* name
*
* @return void
*
* @access public
* @static
*/
function MDB2_Schema_Parser2($variables, $fail_on_invalid_names = true,
$structure = false, $valid_types = array(), $force_defaults = true,
$max_identifiers_length = null
) {
$this->__construct($variables, $fail_on_invalid_names, $structure, $valid_types, $force_defaults); $this->__construct($variables, $fail_on_invalid_names, $structure, $valid_types, $force_defaults);
} }
/**
* Main method. Parses XML Schema File.
*
* @return bool|error object
*
* @access public
*/
function parse() function parse()
{ {
$result = $this->unserialize($this->filename, true); $result = $this->unserialize($this->filename, true);
@ -140,18 +189,33 @@ class MDB2_Schema_Parser2 extends XML_Unserializer
} }
} }
/**
* Do the necessary stuff to set the input XML schema file
*
* @param string $filename full path to schema file
*
* @return boolean MDB2_OK on success
*
* @access public
*/
function setInputFile($filename) function setInputFile($filename)
{ {
$this->filename = $filename; $this->filename = $filename;
return MDB2_OK; return MDB2_OK;
} }
function renameKey(&$arr, $oKey, $nKey) /**
{ * Enforce the default values for mandatory keys and ensure everything goes
$arr[$nKey] = &$arr[$oKey]; * always in the same order (simulates the behaviour of the original
unset($arr[$oKey]); * parser). Works at database level.
} *
* @param array $database multi dimensional array with database definition
* and data.
*
* @return bool|error MDB2_OK on success or error object
*
* @access private
*/
function fixDatabaseKeys($database) function fixDatabaseKeys($database)
{ {
$this->database_definition = array( $this->database_definition = array(
@ -204,6 +268,18 @@ class MDB2_Schema_Parser2 extends XML_Unserializer
return MDB2_OK; return MDB2_OK;
} }
/**
* Enforce the default values for mandatory keys and ensure everything goes
* always in the same order (simulates the behaviour of the original
* parser). Works at table level.
*
* @param array $table multi dimensional array with table definition
* and data.
*
* @return bool|error MDB2_OK on success or error object
*
* @access private
*/
function fixTableKeys($table) function fixTableKeys($table)
{ {
$this->table = array( $this->table = array(
@ -279,6 +355,17 @@ class MDB2_Schema_Parser2 extends XML_Unserializer
return MDB2_OK; return MDB2_OK;
} }
/**
* Enforce the default values for mandatory keys and ensure everything goes
* always in the same order (simulates the behaviour of the original
* parser). Works at table field level.
*
* @param array $field array with table field definition
*
* @return bool|error MDB2_OK on success or error object
*
* @access private
*/
function fixTableFieldKeys($field) function fixTableFieldKeys($field)
{ {
$this->field = array(); $this->field = array();
@ -328,6 +415,17 @@ class MDB2_Schema_Parser2 extends XML_Unserializer
return MDB2_OK; return MDB2_OK;
} }
/**
* Enforce the default values for mandatory keys and ensure everything goes
* always in the same order (simulates the behaviour of the original
* parser). Works at table index level.
*
* @param array $index array with table index definition
*
* @return bool|error MDB2_OK on success or error object
*
* @access private
*/
function fixTableIndexKeys($index) function fixTableIndexKeys($index)
{ {
$this->index = array( $this->index = array(
@ -389,6 +487,17 @@ class MDB2_Schema_Parser2 extends XML_Unserializer
return MDB2_OK; return MDB2_OK;
} }
/**
* Enforce the default values for mandatory keys and ensure everything goes
* always in the same order (simulates the behaviour of the original
* parser). Works at table constraint level.
*
* @param array $constraint array with table index definition
*
* @return bool|error MDB2_OK on success or error object
*
* @access private
*/
function fixTableConstraintKeys($constraint) function fixTableConstraintKeys($constraint)
{ {
$this->constraint = array( $this->constraint = array(
@ -468,6 +577,18 @@ class MDB2_Schema_Parser2 extends XML_Unserializer
return MDB2_OK; return MDB2_OK;
} }
/**
* Enforce the default values for mandatory keys and ensure everything goes
* always in the same order (simulates the behaviour of the original
* parser). Works at table data level.
*
* @param array $element multi dimensional array with query definition
* @param string $type whether its a insert|update|delete query
*
* @return bool|error MDB2_OK on success or error object
*
* @access private
*/
function fixTableInitializationKeys($element, $type = '') function fixTableInitializationKeys($element, $type = '')
{ {
if (!empty($element['select']) && is_array($element['select'])) { if (!empty($element['select']) && is_array($element['select'])) {
@ -480,6 +601,43 @@ class MDB2_Schema_Parser2 extends XML_Unserializer
$this->table['initialization'][] = array( 'type' => $type, 'data' => $this->init ); $this->table['initialization'][] = array( 'type' => $type, 'data' => $this->init );
} }
/**
* Enforce the default values for mandatory keys and ensure everything goes
* always in the same order (simulates the behaviour of the original
* parser). Works deeper at the table initialization level (data). At this
* point we are look at one of the below:
*
* <insert>
* {field}+
* </insert>
*
* <select> (this is a select extracted off a insert-select query)
* <table/>
* {field}+
* <where>
* {expression}
* </where>?
* </select>
*
* <update>
* {field}+
* <where>
* {expression}
* </where>?
* </update>
*
* <delete>
* <where>
* {expression}
* </where>
* </delete>
*
* @param array $element multi dimensional array with query definition
*
* @return bool|error MDB2_OK on success or error object
*
* @access private
*/
function fixTableInitializationDataKeys($element) function fixTableInitializationDataKeys($element)
{ {
$this->init = array(); $this->init = array();
@ -505,6 +663,22 @@ class MDB2_Schema_Parser2 extends XML_Unserializer
} }
} }
/**
* Recursively diggs into an "expression" element. According to our
* documentation an "expression" element is of the kind:
*
* <expression>
* <null/> or <value/> or <column/> or {function} or {expression}
* <operator/>
* <null/> or <value/> or <column/> or {function} or {expression}
* </expression>
*
* @param array &$arr reference to current element definition
*
* @return void
*
* @access private
*/
function setExpression(&$arr) function setExpression(&$arr)
{ {
$element = each($arr); $element = each($arr);
@ -555,6 +729,30 @@ class MDB2_Schema_Parser2 extends XML_Unserializer
} }
} }
/**
* Enforce the default values for mandatory keys and ensure everything goes
* always in the same order (simulates the behaviour of the original
* parser). Works at database sequences level. A "sequence" element looks
* like:
*
* <sequence>
* <name/>
* <was/>?
* <start/>?
* <description/>?
* <comments/>?
* <on>
* <table/>
* <field/>
* </on>?
* </sequence>
*
* @param array $sequence multi dimensional array with sequence definition
*
* @return bool|error MDB2_OK on success or error object
*
* @access private
*/
function fixSequenceKeys($sequence) function fixSequenceKeys($sequence)
{ {
$this->sequence = array( $this->sequence = array(
@ -562,7 +760,6 @@ class MDB2_Schema_Parser2 extends XML_Unserializer
'start' => '', 'start' => '',
'description' => '', 'description' => '',
'comments' => '', 'comments' => '',
'on' => array('table' => '', 'field' => '')
); );
if (!empty($sequence['name'])) { if (!empty($sequence['name'])) {
@ -610,15 +807,23 @@ class MDB2_Schema_Parser2 extends XML_Unserializer
return MDB2_OK; return MDB2_OK;
} }
/**
* Pushes a MDB2_Schema_Error into stack and returns it
*
* @param string $msg textual message
* @param int $ecode MDB2_Schema's error code
*
* @return object
* @access private
* @static
*/
function &raiseError($msg = null, $ecode = MDB2_SCHEMA_ERROR_PARSE) function &raiseError($msg = null, $ecode = MDB2_SCHEMA_ERROR_PARSE)
{ {
if (is_null($this->error)) { if (is_null($this->error)) {
$error = 'Parser error: '.$msg."\n"; $error = 'Parser error: '.$msg."\n";
$this->error =& MDB2_Schema::raiseError($ecode, null, null, $error); $this->error = MDB2_Schema::raiseError($ecode, null, null, $error);
} }
return $this->error; return $this->error;
} }
} }
?>

View File

@ -1,49 +1,51 @@
<?php <?php /* vim: se et ts=4 sw=4 sts=4 fdm=marker tw=80: */
// {{{ Disclaimer, Licence, copyrights /**
// +----------------------------------------------------------------------+ * Copyright (c) 1998-2010 Manuel Lemos, Tomas V.V.Cox,
// | PHP versions 4 and 5 | * Stig. S. Bakken, Lukas Smith, Igor Feghali
// +----------------------------------------------------------------------+ * All rights reserved.
// | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox, | *
// | Stig. S. Bakken, Lukas Smith | * MDB2_Schema enables users to maintain RDBMS independant schema files
// | All rights reserved. | * in XML that can be used to manipulate both data and database schemas
// +----------------------------------------------------------------------+ * This LICENSE is in the BSD license style.
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB | *
// | API as well as database abstraction for PHP applications. | * Redistribution and use in source and binary forms, with or without
// | This LICENSE is in the BSD license style. | * modification, are permitted provided that the following conditions
// | | * are met:
// | 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
// | are met: | * notice, this list of conditions and the following disclaimer.
// | | *
// | Redistributions of source code must retain the above copyright | * Redistributions in binary form must reproduce the above copyright
// | notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer in the
// | | * documentation and/or other materials provided with the distribution.
// | Redistributions in binary form must reproduce the above copyright | *
// | notice, this list of conditions and the following disclaimer in the | * Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken,
// | documentation and/or other materials provided with the distribution. | * Lukas Smith, Igor Feghali nor the names of his contributors may be
// | | * used to endorse or promote products derived from this software
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, | * without specific prior written permission.
// | Lukas Smith nor the names of his contributors may be used to endorse | *
// | or promote products derived from this software without specific prior| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// | written permission. | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// | | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * POSSIBILITY OF SUCH DAMAGE.
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY| *
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | * PHP version 5
// | POSSIBILITY OF SUCH DAMAGE. | *
// +----------------------------------------------------------------------+ * @category Database
// | Author: Lorenzo Alberton <l.alberton@quipo.it> | * @package MDB2_Schema
// +----------------------------------------------------------------------+ * @author Lorenzo Alberton <l.alberton@quipo.it>
// * @license BSD http://www.opensource.org/licenses/bsd-license.php
// }}} * @version SVN: $Id$
* @link http://pear.php.net/packages/MDB2_Schema
*/
// {{{ $GLOBALS['_MDB2_Schema_Reserved']['ibase'] // {{{ $GLOBALS['_MDB2_Schema_Reserved']['ibase']
/** /**
* Has a list of reserved words of Interbase/Firebird * Has a list of reserved words of Interbase/Firebird
@ -433,4 +435,3 @@ $GLOBALS['_MDB2_Schema_Reserved']['ibase'] = array(
'ZONE', 'ZONE',
); );
// }}} // }}}
?>

View File

@ -1,48 +1,52 @@
<?php <?php /* vim: se et ts=4 sw=4 sts=4 fdm=marker tw=80: */
// {{{ Disclaimer, Licence, copyrights /**
// +----------------------------------------------------------------------+ * Copyright (c) 1998-2010 Manuel Lemos, Tomas V.V.Cox,
// | PHP versions 4 and 5 | * Stig. S. Bakken, Lukas Smith, Igor Feghali
// +----------------------------------------------------------------------+ * All rights reserved.
// | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox, | *
// | Stig. S. Bakken, Lukas Smith | * MDB2_Schema enables users to maintain RDBMS independant schema files
// | All rights reserved. | * in XML that can be used to manipulate both data and database schemas
// +----------------------------------------------------------------------+ * This LICENSE is in the BSD license style.
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB | *
// | API as well as database abstraction for PHP applications. | * Redistribution and use in source and binary forms, with or without
// | This LICENSE is in the BSD license style. | * modification, are permitted provided that the following conditions
// | | * are met:
// | 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
// | are met: | * notice, this list of conditions and the following disclaimer.
// | | *
// | Redistributions of source code must retain the above copyright | * Redistributions in binary form must reproduce the above copyright
// | notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer in the
// | | * documentation and/or other materials provided with the distribution.
// | Redistributions in binary form must reproduce the above copyright | *
// | notice, this list of conditions and the following disclaimer in the | * Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken,
// | documentation and/or other materials provided with the distribution. | * Lukas Smith, Igor Feghali nor the names of his contributors may be
// | | * used to endorse or promote products derived from this software
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, | * without specific prior written permission.
// | Lukas Smith nor the names of his contributors may be used to endorse | *
// | or promote products derived from this software without specific prior| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// | written permission. | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// | | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * POSSIBILITY OF SUCH DAMAGE.
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY| *
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | * PHP version 5
// | POSSIBILITY OF SUCH DAMAGE. | *
// +----------------------------------------------------------------------+ * @category Database
// | Author: David Coallier <davidc@php.net> | * @package MDB2_Schema
// +----------------------------------------------------------------------+ * @author David Coallier <davidc@php.net>
// }}} * @license BSD http://www.opensource.org/licenses/bsd-license.php
* @version SVN: $Id$
* @link http://pear.php.net/packages/MDB2_Schema
*/
// {{{ $GLOBALS['_MDB2_Schema_Reserved']['mssql'] // {{{ $GLOBALS['_MDB2_Schema_Reserved']['mssql']
/** /**
* Has a list of all the reserved words for mssql. * Has a list of all the reserved words for mssql.
@ -254,5 +258,3 @@ $GLOBALS['_MDB2_Schema_Reserved']['mssql'] = array(
'SELECT', 'SELECT',
); );
//}}} //}}}
?>

View File

@ -1,50 +1,52 @@
<?php <?php /* vim: se et ts=4 sw=4 sts=4 fdm=marker tw=80: */
// {{{ Disclaimer, Licence, copyrights /**
// +----------------------------------------------------------------------+ * Copyright (c) 1998-2010 Manuel Lemos, Tomas V.V.Cox,
// | PHP versions 4 and 5 | * Stig. S. Bakken, Lukas Smith, Igor Feghali
// +----------------------------------------------------------------------+ * All rights reserved.
// | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox, | *
// | Stig. S. Bakken, Lukas Smith | * MDB2_Schema enables users to maintain RDBMS independant schema files
// | All rights reserved. | * in XML that can be used to manipulate both data and database schemas
// +----------------------------------------------------------------------+ * This LICENSE is in the BSD license style.
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB | *
// | API as well as database abstraction for PHP applications. | * Redistribution and use in source and binary forms, with or without
// | This LICENSE is in the BSD license style. | * modification, are permitted provided that the following conditions
// | | * are met:
// | 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
// | are met: | * notice, this list of conditions and the following disclaimer.
// | | *
// | Redistributions of source code must retain the above copyright | * Redistributions in binary form must reproduce the above copyright
// | notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer in the
// | | * documentation and/or other materials provided with the distribution.
// | Redistributions in binary form must reproduce the above copyright | *
// | notice, this list of conditions and the following disclaimer in the | * Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken,
// | documentation and/or other materials provided with the distribution. | * Lukas Smith, Igor Feghali nor the names of his contributors may be
// | | * used to endorse or promote products derived from this software
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, | * without specific prior written permission.
// | Lukas Smith nor the names of his contributors may be used to endorse | *
// | or promote products derived from this software without specific prior| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// | written permission. | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// | | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * POSSIBILITY OF SUCH DAMAGE.
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY| *
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | * PHP version 5
// | POSSIBILITY OF SUCH DAMAGE. | *
// +----------------------------------------------------------------------+ * @category Database
// | Author: David Coallier <davidc@php.net> | * @package MDB2_Schema
// +----------------------------------------------------------------------+ * @author David Coallier <davidc@php.net>
// * @license BSD http://www.opensource.org/licenses/bsd-license.php
// $Id: mysql.php,v 1.3 2006/03/01 12:16:40 lsmith Exp $ * @version SVN: $Id$
// }}} * @link http://pear.php.net/packages/MDB2_Schema
*/
// {{{ $GLOBALS['_MDB2_Schema_Reserved']['mysql'] // {{{ $GLOBALS['_MDB2_Schema_Reserved']['mysql']
/** /**
* Has a list of reserved words of mysql * Has a list of reserved words of mysql
@ -281,4 +283,3 @@ $GLOBALS['_MDB2_Schema_Reserved']['mysql'] = array(
'ZEROFILL', 'ZEROFILL',
); );
// }}} // }}}
?>

View File

@ -1,48 +1,52 @@
<?php <?php /* vim: se et ts=4 sw=4 sts=4 fdm=marker tw=80: */
// {{{ Disclaimer, Licence, copyrights /**
// +----------------------------------------------------------------------+ * Copyright (c) 1998-2010 Manuel Lemos, Tomas V.V.Cox,
// | PHP versions 4 and 5 | * Stig. S. Bakken, Lukas Smith, Igor Feghali
// +----------------------------------------------------------------------+ * All rights reserved.
// | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox, | *
// | Stig. S. Bakken, Lukas Smith | * MDB2_Schema enables users to maintain RDBMS independant schema files
// | All rights reserved. | * in XML that can be used to manipulate both data and database schemas
// +----------------------------------------------------------------------+ * This LICENSE is in the BSD license style.
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB | *
// | API as well as database abstraction for PHP applications. | * Redistribution and use in source and binary forms, with or without
// | This LICENSE is in the BSD license style. | * modification, are permitted provided that the following conditions
// | | * are met:
// | 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
// | are met: | * notice, this list of conditions and the following disclaimer.
// | | *
// | Redistributions of source code must retain the above copyright | * Redistributions in binary form must reproduce the above copyright
// | notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer in the
// | | * documentation and/or other materials provided with the distribution.
// | Redistributions in binary form must reproduce the above copyright | *
// | notice, this list of conditions and the following disclaimer in the | * Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken,
// | documentation and/or other materials provided with the distribution. | * Lukas Smith, Igor Feghali nor the names of his contributors may be
// | | * used to endorse or promote products derived from this software
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, | * without specific prior written permission.
// | Lukas Smith nor the names of his contributors may be used to endorse | *
// | or promote products derived from this software without specific prior| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// | written permission. | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// | | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * POSSIBILITY OF SUCH DAMAGE.
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY| *
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | * PHP version 5
// | POSSIBILITY OF SUCH DAMAGE. | *
// +----------------------------------------------------------------------+ * @category Database
// | Author: David Coallier <davidc@php.net> | * @package MDB2_Schema
// +----------------------------------------------------------------------+ * @author David Coallier <davidc@php.net>
// }}} * @license BSD http://www.opensource.org/licenses/bsd-license.php
* @version SVN: $Id$
* @link http://pear.php.net/packages/MDB2_Schema
*/
// {{{ $GLOBALS['_MDB2_Schema_Reserved']['oci8'] // {{{ $GLOBALS['_MDB2_Schema_Reserved']['oci8']
/** /**
* Has a list of all the reserved words for oracle. * Has a list of all the reserved words for oracle.
@ -167,5 +171,3 @@ $GLOBALS['_MDB2_Schema_Reserved']['oci8'] = array(
'WITH', 'WITH',
); );
// }}} // }}}
?>

View File

@ -1,49 +1,52 @@
<?php <?php /* vim: se et ts=4 sw=4 sts=4 fdm=marker tw=80: */
// {{{ Disclaimer, Licence, copyrights /**
// +----------------------------------------------------------------------+ * Copyright (c) 1998-2010 Manuel Lemos, Tomas V.V.Cox,
// | PHP versions 4 and 5 | * Stig. S. Bakken, Lukas Smith, Igor Feghali
// +----------------------------------------------------------------------+ * All rights reserved.
// | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox, | *
// | Stig. S. Bakken, Lukas Smith | * MDB2_Schema enables users to maintain RDBMS independant schema files
// | All rights reserved. | * in XML that can be used to manipulate both data and database schemas
// +----------------------------------------------------------------------+ * This LICENSE is in the BSD license style.
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB | *
// | API as well as database abstraction for PHP applications. | * Redistribution and use in source and binary forms, with or without
// | This LICENSE is in the BSD license style. | * modification, are permitted provided that the following conditions
// | | * are met:
// | 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
// | are met: | * notice, this list of conditions and the following disclaimer.
// | | *
// | Redistributions of source code must retain the above copyright | * Redistributions in binary form must reproduce the above copyright
// | notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer in the
// | | * documentation and/or other materials provided with the distribution.
// | Redistributions in binary form must reproduce the above copyright | *
// | notice, this list of conditions and the following disclaimer in the | * Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken,
// | documentation and/or other materials provided with the distribution. | * Lukas Smith, Igor Feghali nor the names of his contributors may be
// | | * used to endorse or promote products derived from this software
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, | * without specific prior written permission.
// | Lukas Smith nor the names of his contributors may be used to endorse | *
// | or promote products derived from this software without specific prior| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// | written permission. | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// | | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS| * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * POSSIBILITY OF SUCH DAMAGE.
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY| *
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | * PHP version 5
// | POSSIBILITY OF SUCH DAMAGE. | *
// +----------------------------------------------------------------------+ * @category Database
// | Author: Marcelo Santos Araujo <msaraujo@php.net> | * @package MDB2_Schema
// +----------------------------------------------------------------------+ * @author Marcelo Santos Araujo <msaraujo@php.net>
// * @license BSD http://www.opensource.org/licenses/bsd-license.php
// }}} * @version SVN: $Id$
* @link http://pear.php.net/packages/MDB2_Schema
*/
// {{{ $GLOBALS['_MDB2_Schema_Reserved']['pgsql'] // {{{ $GLOBALS['_MDB2_Schema_Reserved']['pgsql']
/** /**
* Has a list of reserved words of pgsql * Has a list of reserved words of pgsql
@ -143,5 +146,3 @@ $GLOBALS['_MDB2_Schema_Reserved']['pgsql'] = array(
'WHERE' 'WHERE'
); );
// }}} // }}}
?>

View File

@ -1,8 +1,6 @@
<?php <?php /* vim: se et ts=4 sw=4 sts=4 fdm=marker tw=80: */
/** /**
* PHP versions 4 and 5 * Copyright (c) 1998-2010 Manuel Lemos, Tomas V.V.Cox,
*
* Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox,
* Stig. S. Bakken, Lukas Smith, Igor Feghali * Stig. S. Bakken, Lukas Smith, Igor Feghali
* All rights reserved. * All rights reserved.
* *
@ -39,14 +37,13 @@
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Author: Christian Weiske <cweiske@php.net> * PHP version 5
* $Id: Tool.php,v 1.6 2008/12/13 00:26:07 clockwerx Exp $
* *
* @category Database * @category Database
* @package MDB2_Schema * @package MDB2_Schema
* @author Christian Weiske <cweiske@php.net> * @author Christian Weiske <cweiske@php.net>
* @license BSD http://www.opensource.org/licenses/bsd-license.php * @license BSD http://www.opensource.org/licenses/bsd-license.php
* @version CVS: $Id: Tool.php,v 1.6 2008/12/13 00:26:07 clockwerx Exp $ * @version SVN: $Id$
* @link http://pear.php.net/packages/MDB2_Schema * @link http://pear.php.net/packages/MDB2_Schema
*/ */
@ -152,7 +149,9 @@ class MDB2_Schema_Tool
case '--init': case '--init':
return 'init'; return 'init';
default: default:
throw new MDB2_Schema_Tool_ParameterException("Unknown mode \"$arg\""); throw new MDB2_Schema_Tool_ParameterException(
"Unknown mode \"$arg\""
);
} }
}//protected function getAction(&$args) }//protected function getAction(&$args)
@ -179,7 +178,8 @@ class MDB2_Schema_Tool
*/ */
protected function doHelp() protected function doHelp()
{ {
self::toStdErr(<<<EOH self::toStdErr(
<<<EOH
Usage: mdb2_schematool mode parameters Usage: mdb2_schematool mode parameters
Works with database schemas Works with database schemas
@ -205,7 +205,8 @@ EOH
*/ */
protected function doHelpDump() protected function doHelpDump()
{ {
self::toStdErr( <<<EOH self::toStdErr(
<<<EOH
Usage: mdb2_schematool dump [all|data|schema] [-p] DSN Usage: mdb2_schematool dump [all|data|schema] [-p] DSN
Dumps a database schema to stdout Dumps a database schema to stdout
@ -216,7 +217,8 @@ DSN: Data source name in the form of
driver://user:password@host/database driver://user:password@host/database
User and password may be omitted. User and password may be omitted.
Using -p reads password from stdin which is more secure than passing it in the parameter. Using -p reads password from stdin which is more secure than passing it in the
parameter.
EOH EOH
); );
@ -231,7 +233,8 @@ EOH
*/ */
protected function doHelpInit() protected function doHelpInit()
{ {
self::toStdErr( <<<EOH self::toStdErr(
<<<EOH
Usage: mdb2_schematool init source [-p] destination Usage: mdb2_schematool init source [-p] destination
Initializes a database with data Initializes a database with data
@ -244,7 +247,8 @@ DSN: Data source name in the form of
driver://user:password@host/database driver://user:password@host/database
User and password may be omitted. User and password may be omitted.
Using -p reads password from stdin which is more secure than passing it in the parameter. Using -p reads password from stdin which is more secure than passing it in the
parameter.
EOH EOH
); );
@ -259,7 +263,8 @@ EOH
*/ */
protected function doHelpLoad() protected function doHelpLoad()
{ {
self::toStdErr( <<<EOH self::toStdErr(
<<<EOH
Usage: mdb2_schematool load [-p] source [-p] destination Usage: mdb2_schematool load [-p] source [-p] destination
Loads a database schema from source to destination Loads a database schema from source to destination
@ -272,7 +277,8 @@ DSN: Data source name in the form of
driver://user:password@host/database driver://user:password@host/database
User and password may be omitted. User and password may be omitted.
Using -p reads password from stdin which is more secure than passing it in the parameter. Using -p reads password from stdin which is more secure than passing it in the
parameter.
EOH EOH
); );
@ -334,7 +340,9 @@ EOH
protected function getFileOrDsn(&$args) protected function getFileOrDsn(&$args)
{ {
if (count($args) == 0) { if (count($args) == 0) {
throw new MDB2_Schema_Tool_ParameterException('File or DSN expected'); throw new MDB2_Schema_Tool_ParameterException(
'File or DSN expected'
);
} }
$arg = array_shift($args); $arg = array_shift($args);
@ -450,7 +458,8 @@ EOH
list($type, $dsn) = $this->getFileOrDsn($args); list($type, $dsn) = $this->getFileOrDsn($args);
if ($type == 'file') { if ($type == 'file') {
throw new MDB2_Schema_Tool_ParameterException( throw new MDB2_Schema_Tool_ParameterException(
'Dumping a schema file as a schema file does not make much sense' 'Dumping a schema file as a schema file does not make much ' .
'sense'
); );
} }
@ -503,8 +512,14 @@ EOH
$definition = $schemaDest->parseDatabaseDefinitionFile($dsnSource); $definition = $schemaDest->parseDatabaseDefinitionFile($dsnSource);
$where = 'loading schema file'; $where = 'loading schema file';
} else { } else {
$schemaSource = MDB2_Schema::factory($dsnSource, $this->getSchemaOptions()); $schemaSource = MDB2_Schema::factory(
$this->throwExceptionOnError($schemaSource, 'connecting to source database'); $dsnSource,
$this->getSchemaOptions()
);
$this->throwExceptionOnError(
$schemaSource,
'connecting to source database'
);
$definition = $schemaSource->getDefinitionFromDatabase(); $definition = $schemaSource->getDefinitionFromDatabase();
$where = 'loading definition from database'; $where = 'loading definition from database';
@ -514,7 +529,11 @@ EOH
//create destination database from definition //create destination database from definition
$simulate = false; $simulate = false;
$op = $schemaDest->createDatabase($definition, array(), $simulate); $op = $schemaDest->createDatabase(
$definition,
array(),
$simulate
);
$this->throwExceptionOnError($op, 'creating the database'); $this->throwExceptionOnError($op, 'creating the database');
}//protected function doLoad($args) }//protected function doLoad($args)
@ -545,10 +564,16 @@ EOH
} }
$schemaDest = MDB2_Schema::factory($dsnDest, $this->getSchemaOptions()); $schemaDest = MDB2_Schema::factory($dsnDest, $this->getSchemaOptions());
$this->throwExceptionOnError($schemaDest, 'connecting to destination database'); $this->throwExceptionOnError(
$schemaDest,
'connecting to destination database'
);
$definition = $schemaDest->getDefinitionFromDatabase(); $definition = $schemaDest->getDefinitionFromDatabase();
$this->throwExceptionOnError($definition, 'loading definition from database'); $this->throwExceptionOnError(
$definition,
'loading definition from database'
);
$op = $schemaDest->writeInitialization($dsnSource, $definition); $op = $schemaDest->writeInitialization($dsnSource, $definition);
$this->throwExceptionOnError($op, 'initializing database'); $this->throwExceptionOnError($op, 'initializing database');
@ -556,5 +581,3 @@ EOH
}//class MDB2_Schema_Tool }//class MDB2_Schema_Tool
?>

View File

@ -1,6 +1,61 @@
<?php <?php /* vim: se et ts=4 sw=4 sts=4 fdm=marker tw=80: */
/**
* Copyright (c) 1998-2010 Manuel Lemos, Tomas V.V.Cox,
* Stig. S. Bakken, Lukas Smith, Igor Feghali
* All rights reserved.
*
* MDB2_Schema enables users to maintain RDBMS independant schema files
* in XML that can be used to manipulate both data and database schemas
* 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
* are met:
*
* 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, Igor Feghali 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.
*
* PHP version 5
*
* @category Database
* @package MDB2_Schema
* @author Christian Weiske <cweiske@php.net>
* @license BSD http://www.opensource.org/licenses/bsd-license.php
* @version SVN: $Id$
* @link http://pear.php.net/packages/MDB2_Schema
*/
/**
* To be implemented yet
*
* @category Database
* @package MDB2_Schema
* @author Christian Weiske <cweiske@php.net>
* @license BSD http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/packages/MDB2_Schema
*/
class MDB2_Schema_Tool_ParameterException extends Exception class MDB2_Schema_Tool_ParameterException extends Exception
{} {
}
?>

View File

@ -1,8 +1,6 @@
<?php <?php /* vim: se et ts=4 sw=4 sts=4 fdm=marker tw=80: */
/** /**
* PHP versions 4 and 5 * Copyright (c) 1998-2010 Manuel Lemos, Tomas V.V.Cox,
*
* Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox,
* Stig. S. Bakken, Lukas Smith, Igor Feghali * Stig. S. Bakken, Lukas Smith, Igor Feghali
* All rights reserved. * All rights reserved.
* *
@ -39,15 +37,14 @@
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Author: Christian Dickmann <dickmann@php.net> * PHP version 5
* Author: Igor Feghali <ifeghali@php.net>
* *
* @category Database * @category Database
* @package MDB2_Schema * @package MDB2_Schema
* @author Christian Dickmann <dickmann@php.net> * @author Christian Dickmann <dickmann@php.net>
* @author Igor Feghali <ifeghali@php.net> * @author Igor Feghali <ifeghali@php.net>
* @license BSD http://www.opensource.org/licenses/bsd-license.php * @license BSD http://www.opensource.org/licenses/bsd-license.php
* @version CVS: $Id: Validate.php,v 1.42 2008/11/30 03:34:00 clockwerx Exp $ * @version SVN: $Id$
* @link http://pear.php.net/packages/MDB2_Schema * @link http://pear.php.net/packages/MDB2_Schema
*/ */
@ -70,11 +67,30 @@ class MDB2_Schema_Validate
var $force_defaults = true; var $force_defaults = true;
var $max_identifiers_length = null;
// }}} // }}}
// {{{ constructor // {{{ constructor
function __construct($fail_on_invalid_names = true, $valid_types = array(), $force_defaults = true) /**
{ * PHP 5 constructor
*
* @param bool $fail_on_invalid_names array with reserved words per RDBMS
* @param array $valid_types information of all valid fields
* types
* @param bool $force_defaults if true sets a default value to
* field when not explicit
* @param int $max_identifiers_length maximum allowed size for entities
* name
*
* @return void
*
* @access public
* @static
*/
function __construct($fail_on_invalid_names = true, $valid_types = array(),
$force_defaults = true, $max_identifiers_length = null
) {
if (empty($GLOBALS['_MDB2_Schema_Reserved'])) { if (empty($GLOBALS['_MDB2_Schema_Reserved'])) {
$GLOBALS['_MDB2_Schema_Reserved'] = array(); $GLOBALS['_MDB2_Schema_Reserved'] = array();
} }
@ -89,19 +105,47 @@ class MDB2_Schema_Validate
} }
$this->valid_types = $valid_types; $this->valid_types = $valid_types;
$this->force_defaults = $force_defaults; $this->force_defaults = $force_defaults;
$this->max_identifiers_length = $max_identifiers_length;
} }
function MDB2_Schema_Validate($fail_on_invalid_names = true, $valid_types = array(), $force_defaults = true) /**
{ * PHP 4 compatible constructor
*
* @param bool $fail_on_invalid_names array with reserved words per RDBMS
* @param array $valid_types information of all valid fields
* types
* @param bool $force_defaults if true sets a default value to
* field when not explicit
* @param int $max_identifiers_length maximum allowed size for entities
* name
*
* @return void
*
* @access public
* @static
*/
function MDB2_Schema_Validate($fail_on_invalid_names = true, $valid_types = array(),
$force_defaults = true, $max_identifiers_length = null
) {
$this->__construct($fail_on_invalid_names, $valid_types, $force_defaults); $this->__construct($fail_on_invalid_names, $valid_types, $force_defaults);
} }
// }}} // }}}
// {{{ raiseError() // {{{ raiseError()
/**
* Pushes a MDB2_Schema_Error into stack and returns it
*
* @param int $ecode MDB2_Schema's error code
* @param string $msg textual message
*
* @return object
* @access private
* @static
*/
function &raiseError($ecode, $msg = null) function &raiseError($ecode, $msg = null)
{ {
$error =& MDB2_Schema::raiseError($ecode, null, null, $msg); $error = MDB2_Schema::raiseError($ecode, null, null, $msg);
return $error; return $error;
} }
@ -176,27 +220,18 @@ class MDB2_Schema_Validate
*/ */
function validateTable($tables, &$table, $table_name) function validateTable($tables, &$table, $table_name)
{ {
/* Have we got a name? */
if (!$table_name) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
'a table has to have a name');
}
/* Table name duplicated? */ /* Table name duplicated? */
if (is_array($tables) && isset($tables[$table_name])) { if (is_array($tables) && isset($tables[$table_name])) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
'table "'.$table_name.'" already exists'); 'table "'.$table_name.'" already exists');
} }
/* Table name reserved? */ /**
if (is_array($this->fail_on_invalid_names)) { * Valid name ?
$name = strtoupper($table_name); */
foreach ($this->fail_on_invalid_names as $rdbms) { $result = $this->validateIdentifier($table_name, 'table');
if (in_array($name, $GLOBALS['_MDB2_Schema_Reserved'][$rdbms])) { if (PEAR::isError($result)) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, return $result;
'table name "'.$table_name.'" is a reserved word in: '.$rdbms);
}
}
} }
/* Was */ /* Was */
@ -289,10 +324,12 @@ class MDB2_Schema_Validate
*/ */
function validateField($fields, &$field, $field_name) function validateField($fields, &$field, $field_name)
{ {
/* Have we got a name? */ /**
if (!$field_name) { * Valid name ?
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, */
'field name missing'); $result = $this->validateIdentifier($field_name, 'field');
if (PEAR::isError($result)) {
return $result;
} }
/* Field name duplicated? */ /* Field name duplicated? */
@ -301,17 +338,6 @@ class MDB2_Schema_Validate
'field "'.$field_name.'" already exists'); 'field "'.$field_name.'" already exists');
} }
/* Field name reserverd? */
if (is_array($this->fail_on_invalid_names)) {
$name = strtoupper($field_name);
foreach ($this->fail_on_invalid_names as $rdbms) {
if (in_array($name, $GLOBALS['_MDB2_Schema_Reserved'][$rdbms])) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
'field name "'.$field_name.'" is a reserved word in: '.$rdbms);
}
}
}
/* Type check */ /* Type check */
if (empty($field['type'])) { if (empty($field['type'])) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
@ -422,10 +448,14 @@ class MDB2_Schema_Validate
*/ */
function validateIndex($table_indexes, &$index, $index_name) function validateIndex($table_indexes, &$index, $index_name)
{ {
if (!$index_name) { /**
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, * Valid name ?
'an index has to have a name'); */
$result = $this->validateIdentifier($index_name, 'index');
if (PEAR::isError($result)) {
return $result;
} }
if (is_array($table_indexes) && isset($table_indexes[$index_name])) { if (is_array($table_indexes) && isset($table_indexes[$index_name])) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
'index "'.$index_name.'" already exists'); 'index "'.$index_name.'" already exists');
@ -470,14 +500,18 @@ class MDB2_Schema_Validate
*/ */
function validateIndexField($index_fields, &$field, $field_name) function validateIndexField($index_fields, &$field, $field_name)
{ {
/**
* Valid name ?
*/
$result = $this->validateIdentifier($field_name, 'index field');
if (PEAR::isError($result)) {
return $result;
}
if (is_array($index_fields) && isset($index_fields[$field_name])) { if (is_array($index_fields) && isset($index_fields[$field_name])) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
'index field "'.$field_name.'" already exists'); 'index field "'.$field_name.'" already exists');
} }
if (!$field_name) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
'the index-field-name is required');
}
if (empty($field['sorting'])) { if (empty($field['sorting'])) {
$field['sorting'] = 'ascending'; $field['sorting'] = 'ascending';
} elseif ($field['sorting'] !== 'ascending' && $field['sorting'] !== 'descending') { } elseif ($field['sorting'] !== 'ascending' && $field['sorting'] !== 'descending') {
@ -506,10 +540,14 @@ class MDB2_Schema_Validate
*/ */
function validateConstraint($table_constraints, &$constraint, $constraint_name) function validateConstraint($table_constraints, &$constraint, $constraint_name)
{ {
if (!$constraint_name) { /**
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, * Valid name ?
'a foreign key has to have a name'); */
$result = $this->validateIdentifier($constraint_name, 'foreign key');
if (PEAR::isError($result)) {
return $result;
} }
if (is_array($table_constraints) && isset($table_constraints[$constraint_name])) { if (is_array($table_constraints) && isset($table_constraints[$constraint_name])) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
'foreign key "'.$constraint_name.'" already exists'); 'foreign key "'.$constraint_name.'" already exists');
@ -555,10 +593,14 @@ class MDB2_Schema_Validate
*/ */
function validateConstraintField($constraint_fields, $field_name) function validateConstraintField($constraint_fields, $field_name)
{ {
if (!$field_name) { /**
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, * Valid name ?
'empty value for foreign-field'); */
$result = $this->validateIdentifier($field_name, 'foreign key field');
if (PEAR::isError($result)) {
return $result;
} }
if (is_array($constraint_fields) && isset($constraint_fields[$field_name])) { if (is_array($constraint_fields) && isset($constraint_fields[$field_name])) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
'foreign field "'.$field_name.'" already exists'); 'foreign field "'.$field_name.'" already exists');
@ -582,10 +624,14 @@ class MDB2_Schema_Validate
*/ */
function validateConstraintReferencedField($referenced_fields, $field_name) function validateConstraintReferencedField($referenced_fields, $field_name)
{ {
if (!$field_name) { /**
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, * Valid name ?
'empty value for referenced foreign-field'); */
$result = $this->validateIdentifier($field_name, 'referenced foreign field');
if (PEAR::isError($result)) {
return $result;
} }
if (is_array($referenced_fields) && isset($referenced_fields[$field_name])) { if (is_array($referenced_fields) && isset($referenced_fields[$field_name])) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
'foreign field "'.$field_name.'" already referenced'); 'foreign field "'.$field_name.'" already referenced');
@ -612,9 +658,12 @@ class MDB2_Schema_Validate
*/ */
function validateSequence($sequences, &$sequence, $sequence_name) function validateSequence($sequences, &$sequence, $sequence_name)
{ {
if (!$sequence_name) { /**
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, * Valid name ?
'a sequence has to have a name'); */
$result = $this->validateIdentifier($sequence_name, 'sequence');
if (PEAR::isError($result)) {
return $result;
} }
if (is_array($sequences) && isset($sequences[$sequence_name])) { if (is_array($sequences) && isset($sequences[$sequence_name])) {
@ -661,21 +710,17 @@ class MDB2_Schema_Validate
*/ */
function validateDatabase(&$database) function validateDatabase(&$database)
{ {
/* Have we got a name? */ if (!is_array($database)) {
if (!is_array($database) || !isset($database['name']) || !$database['name']) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
'a database has to have a name'); 'something wrong went with database definition');
} }
/* Database name reserved? */ /**
if (is_array($this->fail_on_invalid_names)) { * Valid name ?
$name = strtoupper($database['name']); */
foreach ($this->fail_on_invalid_names as $rdbms) { $result = $this->validateIdentifier($database['name'], 'database');
if (in_array($name, $GLOBALS['_MDB2_Schema_Reserved'][$rdbms])) { if (PEAR::isError($result)) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, return $result;
'database name "'.$database['name'].'" is a reserved word in: '.$rdbms);
}
}
} }
/* Create */ /* Create */
@ -798,9 +843,12 @@ class MDB2_Schema_Validate
*/ */
function validateDataField($table_fields, $instruction_fields, &$field) function validateDataField($table_fields, $instruction_fields, &$field)
{ {
if (!$field['name']) { /**
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE, * Valid name ?
'field-name has to be specified'); */
$result = $this->validateIdentifier($field['name'], 'field');
if (PEAR::isError($result)) {
return $result;
} }
if (is_array($instruction_fields) && isset($instruction_fields[$field['name']])) { if (is_array($instruction_fields) && isset($instruction_fields[$field['name']])) {
@ -917,6 +965,62 @@ class MDB2_Schema_Validate
} }
return MDB2_OK; return MDB2_OK;
} }
// }}}
// {{{ validateIdentifier()
/**
* Checks whether a given identifier is valid for current driver.
*
* @param string $id identifier to check
* @param string $type whether identifier represents a table name, index, etc.
*
* @return bool|error object
*
* @access public
*/
function validateIdentifier($id, $type)
{
$max_length = $this->max_identifiers_length;
$cur_length = strlen($id);
/**
* Have we got a name?
*/
if (!$id) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
"a $type has to have a name");
} }
?> /**
* Supported length ?
*/
if ($max_length !== null
&& $cur_length > $max_length
) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
"$type name '$id' is too long for current driver");
} elseif ($cur_length > 30) {
// FIXME: find a way to issue a warning in MDB2_Schema object
/* $this->warnings[] = "$type name '$id' might not be
portable to other drivers"; */
}
/**
* Reserved ?
*/
if (is_array($this->fail_on_invalid_names)) {
$name = strtoupper($id);
foreach ($this->fail_on_invalid_names as $rdbms) {
if (in_array($name, $GLOBALS['_MDB2_Schema_Reserved'][$rdbms])) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
"$type name '$id' is a reserved word in: $rdbms");
}
}
}
return MDB2_OK;
}
// }}}
}

View File

@ -1,8 +1,6 @@
<?php <?php /* vim: se et ts=4 sw=4 sts=4 fdm=marker tw=80: */
/** /**
* PHP versions 4 and 5 * Copyright (c) 1998-2010 Manuel Lemos, Tomas V.V.Cox,
*
* Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox,
* Stig. S. Bakken, Lukas Smith, Igor Feghali * Stig. S. Bakken, Lukas Smith, Igor Feghali
* All rights reserved. * All rights reserved.
* *
@ -39,15 +37,14 @@
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* Author: Lukas Smith <smith@pooteeweet.org> * PHP version 5
* Author: Igor Feghali <ifeghali@php.net>
* *
* @category Database * @category Database
* @package MDB2_Schema * @package MDB2_Schema
* @author Lukas Smith <smith@pooteeweet.org> * @author Lukas Smith <smith@pooteeweet.org>
* @author Igor Feghali <ifeghali@php.net> * @author Igor Feghali <ifeghali@php.net>
* @license BSD http://www.opensource.org/licenses/bsd-license.php * @license BSD http://www.opensource.org/licenses/bsd-license.php
* @version CVS: $Id: Writer.php,v 1.40 2008/11/30 03:34:00 clockwerx Exp $ * @version SVN: $Id$
* @link http://pear.php.net/packages/MDB2_Schema * @link http://pear.php.net/packages/MDB2_Schema
*/ */
@ -69,11 +66,33 @@ class MDB2_Schema_Writer
// }}} // }}}
// {{{ constructor // {{{ constructor
/**
* PHP 5 constructor
*
* @param array $valid_types information of all valid fields
* types
*
* @return void
*
* @access public
* @static
*/
function __construct($valid_types = array()) function __construct($valid_types = array())
{ {
$this->valid_types = $valid_types; $this->valid_types = $valid_types;
} }
/**
* PHP 4 compatible constructor
*
* @param array $valid_types information of all valid fields
* types
*
* @return void
*
* @access public
* @static
*/
function MDB2_Schema_Writer($valid_types = array()) function MDB2_Schema_Writer($valid_types = array())
{ {
$this->__construct($valid_types); $this->__construct($valid_types);
@ -87,15 +106,18 @@ class MDB2_Schema_Writer
* callbacks etc. Basically a wrapper for PEAR::raiseError * callbacks etc. Basically a wrapper for PEAR::raiseError
* without the message string. * without the message string.
* *
* @param int|PEAR_Error $code integer error code or and PEAR_Error instance * @param int|PEAR_Error $code integer error code or and PEAR_Error
* @param int $mode error mode, see PEAR_Error docs * instance
* error level (E_USER_NOTICE etc). If error mode is * @param int $mode error mode, see PEAR_Error docs error
* PEAR_ERROR_CALLBACK, this is the callback function, * level (E_USER_NOTICE etc). If error mode
* either as a function name, or as an array of an * is PEAR_ERROR_CALLBACK, this is the
* object and method name. For other error modes this * callback function, either as a function
* name, or as an array of an object and
* method name. For other error modes this
* parameter is ignored. * parameter is ignored.
* @param string $options Extra debug information. Defaults to the last * @param string $options Extra debug information. Defaults to the
* query and native error code. * last query and native error code.
* @param string $userinfo User-friendly error message
* *
* @return object a PEAR error object * @return object a PEAR error object
* @access public * @access public
@ -103,7 +125,7 @@ class MDB2_Schema_Writer
*/ */
function &raiseError($code = null, $mode = null, $options = null, $userinfo = null) function &raiseError($code = null, $mode = null, $options = null, $userinfo = null)
{ {
$error =& MDB2_Schema::raiseError($code, $mode, $options, $userinfo); $error = MDB2_Schema::raiseError($code, $mode, $options, $userinfo);
return $error; return $error;
} }
@ -578,4 +600,3 @@ class MDB2_Schema_Writer
// }}} // }}}
} }
?>

10
3rdparty/PEAR.php vendored
View File

@ -247,7 +247,7 @@ class PEAR
* @access public * @access public
* @return bool true if parameter is an error * @return bool true if parameter is an error
*/ */
function isError($data, $code = null) static function isError($data, $code = null)
{ {
if (!is_a($data, 'PEAR_Error')) { if (!is_a($data, 'PEAR_Error')) {
return false; return false;
@ -469,7 +469,7 @@ class PEAR
* @see PEAR::setErrorHandling * @see PEAR::setErrorHandling
* @since PHP 4.0.5 * @since PHP 4.0.5
*/ */
function &raiseError($message = null, static function &raiseError($message = null,
$code = null, $code = null,
$mode = null, $mode = null,
$options = null, $options = null,
@ -555,11 +555,11 @@ class PEAR
function &throwError($message = null, $code = null, $userinfo = null) function &throwError($message = null, $code = null, $userinfo = null)
{ {
if (isset($this) && is_a($this, 'PEAR')) { if (isset($this) && is_a($this, 'PEAR')) {
$a = &$this->raiseError($message, $code, null, null, $userinfo); $a = $this->raiseError($message, $code, null, null, $userinfo);
return $a; return $a;
} }
$a = &PEAR::raiseError($message, $code, null, null, $userinfo); $a = PEAR::raiseError($message, $code, null, null, $userinfo);
return $a; return $a;
} }
@ -695,7 +695,7 @@ class PEAR
* @param string $ext The extension name * @param string $ext The extension name
* @return bool Success or not on the dl() call * @return bool Success or not on the dl() call
*/ */
function loadExtension($ext) static function loadExtension($ext)
{ {
if (extension_loaded($ext)) { if (extension_loaded($ext)) {
return true; return true;

View File

@ -144,7 +144,7 @@ class PEAR_Autoloader extends PEAR
$include_file = preg_replace('/[^a-z0-9]/i', '_', $classname); $include_file = preg_replace('/[^a-z0-9]/i', '_', $classname);
include_once $include_file; include_once $include_file;
} }
$obj =& new $classname; $obj = new $classname;
$methods = get_class_methods($classname); $methods = get_class_methods($classname);
foreach ($methods as $method) { foreach ($methods as $method) {
// don't import priviate methods and constructors // don't import priviate methods and constructors

View File

@ -133,8 +133,8 @@ class PEAR_Command
$a = PEAR::raiseError("unknown command `$command'"); $a = PEAR::raiseError("unknown command `$command'");
return $a; return $a;
} }
$ui =& PEAR_Command::getFrontendObject(); $ui = PEAR_Command::getFrontendObject();
$obj = &new $class($ui, $config); $obj = new $class($ui, $config);
return $obj; return $obj;
} }
@ -149,7 +149,7 @@ class PEAR_Command
if (!class_exists($class)) { if (!class_exists($class)) {
return PEAR::raiseError("unknown command `$command'"); return PEAR::raiseError("unknown command `$command'");
} }
$ui =& PEAR_Command::getFrontendObject(); $ui = PEAR_Command::getFrontendObject();
$config = &PEAR_Config::singleton(); $config = &PEAR_Config::singleton();
$obj = &new $class($ui, $config); $obj = &new $class($ui, $config);
return $obj; return $obj;

View File

@ -168,7 +168,7 @@ class PEAR_Common extends PEAR
function PEAR_Common() function PEAR_Common()
{ {
parent::PEAR(); parent::PEAR();
$this->config = &PEAR_Config::singleton(); $this->config = PEAR_Config::singleton();
$this->debug = $this->config->get('verbose'); $this->debug = $this->config->get('verbose');
} }

View File

@ -109,7 +109,7 @@ class PEAR_PackageFile_Generator_v1
// }}} // }}}
$packagexml = $this->toPackageFile($where, PEAR_VALIDATE_PACKAGING, 'package.xml', true); $packagexml = $this->toPackageFile($where, PEAR_VALIDATE_PACKAGING, 'package.xml', true);
if ($packagexml) { if ($packagexml) {
$tar =& new Archive_Tar($dest_package, $compress); $tar = new Archive_Tar($dest_package, $compress);
$tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors $tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors
// ----- Creates with the package.xml file // ----- Creates with the package.xml file
$ok = $tar->createModify(array($packagexml), '', $where); $ok = $tar->createModify(array($packagexml), '', $where);

View File

@ -269,7 +269,7 @@ http://pear.php.net/dtd/package-2.0.xsd',
$name = $pf1 !== null ? 'package2.xml' : 'package.xml'; $name = $pf1 !== null ? 'package2.xml' : 'package.xml';
$packagexml = $this->toPackageFile($where, PEAR_VALIDATE_PACKAGING, $name); $packagexml = $this->toPackageFile($where, PEAR_VALIDATE_PACKAGING, $name);
if ($packagexml) { if ($packagexml) {
$tar =& new Archive_Tar($dest_package, $compress); $tar = new Archive_Tar($dest_package, $compress);
$tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors $tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors
// ----- Creates with the package.xml file // ----- Creates with the package.xml file
$ok = $tar->createModify(array($packagexml), '', $where); $ok = $tar->createModify(array($packagexml), '', $where);

View File

@ -191,26 +191,6 @@ class XML_Parser extends PEAR
*/ */
var $_validEncodings = array('ISO-8859-1', 'UTF-8', 'US-ASCII'); var $_validEncodings = array('ISO-8859-1', 'UTF-8', 'US-ASCII');
// }}}
// {{{ php4 constructor
/**
* Creates an XML parser.
*
* This is needed for PHP4 compatibility, it will
* call the constructor, when a new instance is created.
*
* @param string $srcenc source charset encoding, use NULL (default) to use
* whatever the document specifies
* @param string $mode how this parser object should work, "event" for
* startelement/endelement-type events, "func"
* to have it call functions named after elements
* @param string $tgtenc a valid target encoding
*/
function XML_Parser($srcenc = null, $mode = 'event', $tgtenc = null)
{
XML_Parser::__construct($srcenc, $mode, $tgtenc);
}
// }}} // }}}
// {{{ php5 constructor // {{{ php5 constructor
@ -364,7 +344,7 @@ class XML_Parser extends PEAR
} }
$this->parser = $xp; $this->parser = $xp;
$result = $this->_initHandlers($this->mode); $result = $this->_initHandlers($this->mode);
if ($this->isError($result)) { if (PEAR::isError($result)) {
return $result; return $result;
} }
xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, $this->folding); xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, $this->folding);
@ -393,7 +373,7 @@ class XML_Parser extends PEAR
function reset() function reset()
{ {
$result = $this->_create(); $result = $this->_create();
if ($this->isError($result)) { if (PEAR::isError($result)) {
return $result; return $result;
} }
return true; return true;
@ -505,7 +485,7 @@ class XML_Parser extends PEAR
* reset the parser * reset the parser
*/ */
$result = $this->reset(); $result = $this->reset();
if ($this->isError($result)) { if (PEAR::isError($result)) {
return $result; return $result;
} }
// if $this->fp was fopened previously // if $this->fp was fopened previously
@ -610,10 +590,16 @@ class XML_Parser extends PEAR
* *
* @return XML_Parser_Error reference to the error object * @return XML_Parser_Error reference to the error object
**/ **/
function &raiseError($msg = null, $ecode = 0) static function &raiseError($message = null,
$code = 0,
$mode = null,
$options = null,
$userinfo = null,
$error_class = null,
$skipmsg = false)
{ {
$msg = !is_null($msg) ? $msg : $this->parser; $msg = !is_null($msg) ? $msg : $this->parser;
$err = &new XML_Parser_Error($msg, $ecode); $err = new XML_Parser_Error($msg, $ecode);
return parent::raiseError($err); return parent::raiseError($err);
} }