cvs: pear /MDB2_Schema/MDB2 Schema.php

From: Date: Tue, 21 Mar 2006 09:26:40 +0000
Subject: cvs: pear /MDB2_Schema/MDB2 Schema.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-39217@lists.php.net to get a copy of this message
lsmith Tue Mar 21 09:26:40 2006 UTC Modified files: /pear/MDB2_Schema/MDB2 Schema.php Log: - added option valid_types - added option to set parser and writer class - automatically let the installer set the API Version - make sure that the Datatype module is loaded http://cvs.php.net/viewcvs.cgi/pear/MDB2_Schema/MDB2/Schema.php?r1=1.60&r2=1.61&diff_format=u Index: pear/MDB2_Schema/MDB2/Schema.php diff -u pear/MDB2_Schema/MDB2/Schema.php:1.60 pear/MDB2_Schema/MDB2/Schema.php:1.61 --- pear/MDB2_Schema/MDB2/Schema.php:1.60 Wed Mar 1 12:16:41 2006 +++ pear/MDB2_Schema/MDB2/Schema.php Tue Mar 21 09:26:40 2006 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@pooteeweet.org> | // +----------------------------------------------------------------------+ // -// $Id: Schema.php,v 1.60 2006/03/01 12:16:41 lsmith Exp $ +// $Id: Schema.php,v 1.61 2006/03/21 09:26:40 lsmith Exp $ // require_once 'MDB2.php'; @@ -86,6 +86,9 @@ var $options = array( 'fail_on_invalid_names' => true, 'dtd_file' => false, + 'valid_types' => array(), + 'parser' => 'MDB2_Schema_Parser', + 'writer' => 'MDB2_Schema_Writer', ); var $database_definition = array( @@ -106,7 +109,7 @@ */ function apiVersion() { - return '0.4.0'; + return '@package_version@'; } // }}} @@ -254,8 +257,13 @@ } $this->db =& $db; + $this->db->loadModule('Datatype'); $this->db->loadModule('Manager'); $this->db->loadModule('Reverse'); + if (empty($this->options['valid_types'])) { + $this->options['valid_types'] = $this->db->datatype->valid_types; + } + return MDB2_OK; } @@ -303,8 +311,13 @@ } } - require_once 'MDB2/Schema/Parser.php'; - $parser =& new MDB2_Schema_Parser($variables, $fail_on_invalid_names, $structure); + $class_name = $this->getOption('parser'); + $result = MDB2::loadClass($class_name, $this->db->getOption('debug')); + if (PEAR::isError($result)) { + return $result; + } + + $parser =& new $class_name($variables, $fail_on_invalid_names, $structure, $this->getOption('valid_types')); $result = $parser->setInputFile($input_file); if (PEAR::isError($result)) { return $result; @@ -1770,6 +1783,12 @@ */ function dumpDatabase($arguments, $dump = MDB2_SCHEMA_DUMP_ALL) { + $class_name = $this->getOption('writer'); + $result = MDB2::loadClass($class_name, $this->db->getOption('debug')); + if (PEAR::isError($result)) { + return $result; + } + if (!array_key_exists('definition', $arguments) || !$arguments['definition']) { if (!$this->db) { return $this->raiseError(MDB2_SCHEMA_ERROR_NODBSELECTED, @@ -1816,8 +1835,7 @@ } } - require_once 'MDB2/Schema/Writer.php'; - $writer =& new MDB2_Schema_Writer(); + $writer =& new $class_name(); return $writer->dumpDatabase($this->database_definition, $arguments, $dump); }

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