cvs: pear /MDB manager.php
| From: | Lukas Smith | Date: | Wed, 10 Jul 2002 11:19:43 +0000 |
| Subject: | cvs: pear /MDB manager.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-5016@lists.php.net to get a copy of this message | ||
lsmith Wed Jul 10 07:19:43 2002 EDT
Modified files:
/pear/MDB manager.php
Log:
fixed dumping sequences
Index: pear/MDB/manager.php
diff -u pear/MDB/manager.php:1.15 pear/MDB/manager.php:1.16
--- pear/MDB/manager.php:1.15 Thu Jul 4 15:10:03 2002
+++ pear/MDB/manager.php Wed Jul 10 07:19:42 2002
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@dybnet.de> |
// +----------------------------------------------------------------------+
//
-// $Id: manager.php,v 1.15 2002/07/04 19:10:03 lsmith Exp $
+// $Id: manager.php,v 1.16 2002/07/10 11:19:42 lsmith Exp $
//
// MDB XML Schema Manager
//
@@ -1235,13 +1235,13 @@
return($escaped);
}
- function dumpSequence($sequence_name, $output, $eol, $dump_definition)
+ function dumpSequence($sequence_name, $eol, $dump_definition)
{
$sequence_definition =
$this->database_definition["SEQUENCES"][$sequence_name];
if ($dump_definition) {
$start = $sequence_definition["start"];
} else {
- if ($this->database->support("currId")) {
+ if ($this->database->support("CurrId")) {
$result = $this->database->currId($sequence_name, $start);
if (MDB::isError($result)) {
return $result;
@@ -1256,12 +1256,12 @@
$this->warnings[] = "database does not support getting current sequence
value, the sequence value was incremented";
}
}
- $output("$eol <sequence>$eol <name>$sequence_name</name>$eol
<start>$start</start>$eol");
+ $buffer = "$eol <sequence>$eol <name>$sequence_name</name>$eol
<start>$start</start>$eol";
if (isset($sequence_definition["on"])) {
- $output(" <on>$eol
<table>".$sequence_definition["on"]["table"]."</table>$eol
<field>".$sequence_definition["on"]["field"]."</field>$eol
</on>$eol");
+ $buffer .= " <on>$eol
<table>".$sequence_definition["on"]["table"]."</table>$eol
<field>".$sequence_definition["on"]["field"]."</field>$eol
</on>$eol";
}
- $output(" </sequence>$eol");
- return(1);
+ $buffer .= " </sequence>$eol";
+ return ($buffer);
}
@@ -1290,7 +1290,6 @@
return PEAR::raiseError(NULL, DB_ERROR_MANAGER, NULL, NULL,
'no valid output function specified', 'MDB_Error', TRUE);
}
-
$output = $arguments["Output"];
$eol = (isset($arguments["EndOfLine"]) ? $arguments["EndOfLine"] :
"\n");
$dump_definition = isset($arguments["Definition"]);
@@ -1494,10 +1493,15 @@
$sequence < count($sequences[$table_name]);
$sequence++)
{
- $result = $this->dumpSequence($sequences[$table_name][$sequence], $output,
$eol, $dump_definition);
+ $result = $this->dumpSequence($sequences[$table_name][$sequence], $eol,
$dump_definition);
if (MDB::isError($result)) {
return $result;
}
+ if ($fp) {
+ fwrite($fp, $result);
+ } else {
+ $output($result);
+ }
}
}
}
@@ -1506,10 +1510,15 @@
$sequence < count($sequences[""]);
$sequence++)
{
- $result = $this->dumpSequence($sequences[""][$sequence], $output,
$eol, $dump_definition);
+ $result = $this->dumpSequence($sequences[""][$sequence], $eol,
$dump_definition);
if (MDB::isError($result)) {
return $result;
}
+ if ($fp) {
+ fwrite($fp, $result);
+ } else {
+ $output($result);
+ }
}
}
$buffer = ("$eol</database>$eol");
@@ -1868,6 +1877,28 @@
}
$this->database_definition["TABLES"][$table_name]["FIELDS"][$field_name] =
$definition[0];
}
+ }
+ if (!$this->database->listSequences($sequences)) {
+ return($this->database->error());
+ }
+ for($sequence = 0; $sequence < count($sequences); $sequence++) {
+ $sequence_name = $sequences[$sequence];
+ if ($this->database->support("CurrId")) {
+ $result = $this->database->currId($sequence_name, $start);
+ if (MDB::isError($result)) {
+ return $result;
+ }
+ $start++;
+ } else {
+ $result = $this->database->nextId($sequence_name, $start);
+ if (MDB::isError($result)) {
+ return $result;
+ }
+ // XXX needs more checking
+ $this->warnings[] = "database does not support getting current sequence
value, the sequence value was incremented";
+ }
+ $sequence_definition["start"] = $start;
+ $this->database_definition["SEQUENCES"][$sequence_name] =
$sequence_definition;
}
return("");
}