mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merged r67482 to branches/2.3 - let db/build add auto_increment
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@68474 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
d10d8a5ba2
commit
63aa35092b
@ -224,7 +224,9 @@ abstract class Database extends Object {
|
||||
} else {
|
||||
$this->checkAndRepairTable($table);
|
||||
}
|
||||
|
||||
|
||||
$this->requireField($table, "ID", "int(11) not null auto_increment");
|
||||
|
||||
// Create custom fields
|
||||
if($fieldSchema) {
|
||||
foreach($fieldSchema as $fieldName => $fieldSpec) {
|
||||
|
@ -172,11 +172,11 @@ class MySQLDatabase extends Database {
|
||||
|
||||
public function createTable($tableName, $fields = null, $indexes = null) {
|
||||
$fieldSchemas = $indexSchemas = "";
|
||||
if(!isset($fields['ID'])) $fields['ID'] = "int(11) not null auto_increment";
|
||||
if($fields) foreach($fields as $k => $v) $fieldSchemas .= "`$k` $v,\n";
|
||||
if($indexes) foreach($indexes as $k => $v) $fieldSchemas .= $this->getIndexSqlDefinition($k, $v) . ",\n";
|
||||
|
||||
$this->query("CREATE TABLE `$tableName` (
|
||||
ID int(11) not null auto_increment,
|
||||
$fieldSchemas
|
||||
$indexSchemas
|
||||
primary key (ID)
|
||||
|
Loading…
x
Reference in New Issue
Block a user