Added support to SQL generation of install INSERTs

This commit is contained in:
stronk7 2006-08-27 21:59:04 +00:00
parent 3655a6b39f
commit efd1e2032d

View File

@ -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;
}
}
?>