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:
Sam Minnee 2008-12-11 22:51:11 +00:00
parent d10d8a5ba2
commit 63aa35092b
2 changed files with 4 additions and 2 deletions

View File

@ -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) {

View File

@ -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)