From efd1e2032d67849b448a99b309b9a2f65f6dc315 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 27 Aug 2006 21:59:04 +0000 Subject: [PATCH] Added support to SQL generation of install INSERTs --- lib/xmldb/classes/XMLDBStatement.class.php | 51 +++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/lib/xmldb/classes/XMLDBStatement.class.php b/lib/xmldb/classes/XMLDBStatement.class.php index 7592803a79..4a254d441b 100644 --- a/lib/xmldb/classes/XMLDBStatement.class.php +++ b/lib/xmldb/classes/XMLDBStatement.class.php @@ -348,7 +348,7 @@ class XMLDBStatement extends XMLDBObject { $values = array(); /// Get second part from the sentence (after VALUES) - preg_match('/VALUES\s+\((.*)\)$/is', $sentence, $matches); + preg_match('/VALUES\s*\((.*)\)$/is', $sentence, $matches); if (isset($matches[1])) { $part = $matches[1]; /// Convert the comma separated string to an array @@ -360,6 +360,55 @@ class XMLDBStatement extends XMLDBObject { return $values; } + + /** + * This function will return the code needed to execute a collection + * of sentences present inside one statement for the specified BD + * and prefix. + * For now it only supports INSERT statements + */ + function getExecuteStatementSQL ($dbtype, $prefix, $statement_end=true) { + + $results = array(); + + /// Based on statement type + switch ($this->type) { + case XMLDB_STATEMENT_INSERT: + $results = $this->getExecuteInsertSQL($dbtype, $prefix, $statement_end); + break; + case XMLDB_STATEMENT_UPDATE: + break; + case XMLDB_STATEMENT_DELETE: + break; + case XMLDB_STATEMENT_CUSTOM: + break; + } + + if ($statement_end) { + $results = $generator->getEndedStatements($results); + } + + return $results; + } + + /** + * This function will return the code needed to execute a collection + * of insert sentences present inside the statement for the specified BD + * and prefix. Just one simple wrapper over generators. + */ + function getExecuteInsertSQL ($dbtype, $prefix, $statement_end=true) { + + $results = array(); + + $classname = 'XMLDB' . $dbtype; + $generator = new $classname(); + $generator->setPrefix($prefix); + + $results = $generator->getExecuteInsertSQL($this); + + return $results; + } + } ?> -- 2.39.5