mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Added support to SQL generation of install INSERTs
This commit is contained in:
parent
3655a6b39f
commit
efd1e2032d
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user