API CHANGE: Allow use of temporary option in MSSQLDatabase::createTable()

This commit is contained in:
Sam Minnee 2009-05-21 05:10:46 +00:00
parent b39b915a2f
commit a7328a7316

View File

@ -239,10 +239,23 @@ class MSSQLDatabase extends Database {
return false;
}
/**
* Create a new table.
* @param $tableName The name of the table
* @param $fields A map of field names to field types
* @param $indexes A map of indexes
* @param $options An map of additional options. The available keys are as follows:
* - 'MSSQLDatabase'/'MySQLDatabase'/'PostgreSQLDatabase' - database-specific options such as "engine" for MySQL.
* - 'temporary' - If true, then a temporary table will be created
* @return The table name generated. This may be different from the table name, for example with temporary tables.
*/
public function createTable($tableName, $fields = null, $indexes = null, $options = null) {
$fieldSchemas = $indexSchemas = "";
if($fields) foreach($fields as $k => $v) $fieldSchemas .= "\"$k\" $v,\n";
// Temporary tables start with "#" in MSSQL-land
if(!empty($options['temporary'])) $tableName = "#$tableName";
$this->query("CREATE TABLE \"$tableName\" (
$fieldSchemas
primary key (\"ID\")
@ -255,6 +268,8 @@ class MSSQLDatabase extends Database {
}
if($indexSchemas) $this->query($indexSchemas);
return $tableName;
}
/**