Changeset 2864

Show
Ignore:
Timestamp:
01/20/07 15:10:13 (2 years ago)
Author:
sihwp
Message:
  • 플러그인 storage 기능중 auto increment 기능 추가
Location:
sandbox/lib
Files:
2 modified

Legend:

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

    r2777 r2864  
    8181    } else { 
    8282        $query = "CREATE TABLE {$database['prefix']}{$name} (owner int(11) NOT NULL default '0',"; 
    83  
     83        $isaiExists = false; 
    8484        foreach($fields as $field) { 
     85            $ai = ''; 
     86            if( strtolower($field['attribute']) == 'int' || strtolower($field['attribute']) == 'mediumint'  ){ 
     87                if( true == $field['autoincrement']  && ! $isaiExists){ 
     88                    $ai = ' AUTO_INCREMENT '; 
     89                    $isaiExists = true; 
     90                } 
     91            } 
    8592            $isNull = ($field['isnull'] == 0) ? ' NOT NULL ' : ' NULL '; 
    8693            $defaultValue = is_null($field['default']) ? '' : " DEFAULT '" . mysql_tt_escape_string($field['default']) . "' "; 
    8794            $fieldLength = ($field['length'] >= 0) ? "(".$field['length'].")" : ''; 
    88             $sentence = $field['name'] . " " . $field['attribute'] . $fieldLength . $isNull . $defaultValue . ","; 
     95            $sentence = $field['name'] . " " . $field['attribute'] . $fieldLength . $isNull . $defaultValue . $ai . ","; 
    8996            $query .= $sentence; 
    9097        } 
     
    94101        $query .= ") TYPE=MyISAM "; 
    95102        $query .= ($database['utf8'] == true) ? 'DEFAULT CHARSET=utf8' : ''; 
    96          
    97103        if (DBQuery::execute($query)) { 
    98104                $keyname = mysql_tt_escape_string(mysql_lessen('Database_' . $name, 32)); 
  • sandbox/lib/plugins.php

    r2777 r2864  
    4949                            $fieldIsNull = isset($field['isnull']) ? $field['isnull'][0]['.value'] : 1; 
    5050                            $fieldDefault = isset($field['default']) ? $field['default'][0]['.value'] : null; 
     51                            $ai = isset($field['autoincrement']) ? $field['autoincrement'][0]['.value'] == '1' : false; 
    5152                             
    52                             array_push($storageMappings, array('name' => $fieldName, 'attribute' => $fieldAttribute, 'length' => $fieldLength, 'isnull' => $fieldIsNull, 'default' => $fieldDefault)); 
     53                            array_push($storageMappings, array('name' => $fieldName, 'attribute' => $fieldAttribute, 'length' => $fieldLength, 'isnull' => $fieldIsNull, 'default' => $fieldDefault , 'autoincrement' => $ai)); 
    5354                        } 
    5455                    }