Changeset 3070

Show
Ignore:
Timestamp:
03/31/07 11:57:07 (22 months ago)
Author:
crizin
Message:
  • plugin db config에 autoincrement를 지정하면 index 필드로 추가하도록 함
Location:
sandbox/lib
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • sandbox/lib/model/common.plugin.php

    r2929 r3070  
    8282        $query = "CREATE TABLE {$database['prefix']}{$name} (owner int(11) NOT NULL default '0',"; 
    8383        $isaiExists = false; 
     84        $index = ''; 
    8485        foreach($fields as $field) { 
    8586            $ai = ''; 
    8687            if( strtolower($field['attribute']) == 'int' || strtolower($field['attribute']) == 'mediumint'  ){ 
    87                 if( true == $field['autoincrement']  && ! $isaiExists){ 
     88                if($field['autoincrement'] == 1 && !$isaiExists){ 
    8889                    $ai = ' AUTO_INCREMENT '; 
    8990                    $isaiExists = true; 
     91                    if(!in_array($field['name'], $keys)) 
     92                        $index = ", KEY({$field['name']})"; 
    9093                } 
    9194            } 
     
    99102        array_unshift($keys, 'owner'); 
    100103        $query .= " PRIMARY KEY (" . implode(',',$keys) . ")"; 
     104        $query .= $index; 
    101105        $query .= ") TYPE=MyISAM "; 
    102106        $query .= ($database['utf8'] == true) ? 'DEFAULT CHARSET=utf8' : ''; 
  • sandbox/lib/plugins.php

    r3047 r3070  
    5252                            $fieldIsNull = isset($field['isnull']) ? $field['isnull'][0]['.value'] : 1; 
    5353                            $fieldDefault = isset($field['default']) ? $field['default'][0]['.value'] : null; 
    54                             $ai = isset($field['autoincrement']) ? $field['autoincrement'][0]['.value'] == '1' : false; 
     54                            $fieldAutoIncrement = isset($field['autoincrement']) ? $field['autoincrement'][0]['.value'] : 0; 
    5555                             
    56                             array_push($storageMappings, array('name' => $fieldName, 'attribute' => $fieldAttribute, 'length' => $fieldLength, 'isnull' => $fieldIsNull, 'default' => $fieldDefault , 'autoincrement' => $ai)); 
     56                            array_push($storageMappings, array('name' => $fieldName, 'attribute' => $fieldAttribute, 'length' => $fieldLength, 'isnull' => $fieldIsNull, 'default' => $fieldDefault, 'autoincrement' => $fieldAutoIncrement)); 
    5757                        } 
    5858                    }