Permalink
Browse files

Added support to SQL generation of install INSERTs

  • Loading branch information...
1 parent 3655a6b commit efd1e2032d67849b448a99b309b9a2f65f6dc315 stronk7 committed Aug 27, 2006
Showing with 50 additions and 1 deletion.
  1. +50 −1 lib/xmldb/classes/XMLDBStatement.class.php
@@ -348,7 +348,7 @@ function getValuesFromInsertSentence($sentence) {
$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 @@ function getValuesFromInsertSentence($sentence) {
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;
+ }
+
}
?>

0 comments on commit efd1e20

Please sign in to comment.