- Timestamp:
- 09/26/13 15:41:49 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.5.1-evolucao/phpgwapi/inc/adodb/adodb-datadict.inc.php
r6057 r8222 2 2 3 3 /** 4 V 4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.4 V5.18 3 Sep 2012 (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved. 5 5 Released under both BSD license and Lesser GPL library license. 6 6 Whenever there is any discrepancy between the two licenses, … … 216 216 } 217 217 218 219 218 function MetaType($t,$len=-1,$fieldobj=false) 220 219 { … … 232 231 'INTERVAL' => 'C', # Postgres 233 232 'MACADDR' => 'C', # postgres 233 'VAR_STRING' => 'C', # mysql 234 234 ## 235 235 'LONGCHAR' => 'X', … … 259 259 'DATETIME' => 'T', 260 260 'TIMESTAMPTZ' => 'T', 261 'SMALLDATETIME' => 'T', 261 262 'T' => 'T', 262 263 'TIMESTAMP WITHOUT TIME ZONE' => 'T', // postgresql … … 370 371 { 371 372 $rez = 2; 372 $conn = &$this->connection;373 $conn = $this->connection; 373 374 $saved = $conn->debug; 374 375 foreach($sql as $line) { … … 519 520 if ($lines == null) $lines = array(); 520 521 list(,$first) = each($lines); 521 list(,$column_def) = preg_split( '/[\t ]+/',$first,2);522 list(,$column_def) = preg_split("/[\t ]+/",$first,2); 522 523 } 523 524 return array(sprintf($this->renameColumn,$tabname,$this->NameQuote($oldcolumn),$this->NameQuote($newcolumn),$column_def)); … … 589 590 return $sql; 590 591 } 592 593 591 594 592 595 function _GenFields($flds,$widespacing=false) … … 814 817 815 818 // return string must begin with space 816 function _CreateSuffix($fname, $ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint)819 function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned) 817 820 { 818 821 $suffix = ''; … … 913 916 } 914 917 918 919 function _getSizePrec($size) 920 { 921 $fsize = false; 922 $fprec = false; 923 $dotat = strpos($size,'.'); 924 if ($dotat === false) $dotat = strpos($size,','); 925 if ($dotat === false) $fsize = $size; 926 else { 927 $fsize = substr($size,0,$dotat); 928 $fprec = substr($size,$dotat+1); 929 } 930 return array($fsize, $fprec); 931 } 932 915 933 /** 916 934 "Florian Buzin [ easywe ]" <florian.buzin#easywe.de> … … 919 937 have to know if the col is new or not. It will check on its own. 920 938 */ 921 function ChangeTableSQL($tablename, $flds, $tableoptions = false )939 function ChangeTableSQL($tablename, $flds, $tableoptions = false, $dropOldFlds=false) 922 940 { 923 941 global $ADODB_FETCH_MODE; … … 952 970 if (isset($obj->not_null) && $obj->not_null) 953 971 $v = str_replace('NOT NULL','',$v); 954 972 if (isset($obj->auto_increment) && $obj->auto_increment && empty($v['AUTOINCREMENT'])) 973 $v = str_replace('AUTOINCREMENT','',$v); 974 955 975 $c = $cols[$k]; 956 976 $ml = $c->max_length; 957 977 $mt = $this->MetaType($c->type,$ml); 978 979 if (isset($c->scale)) $sc = $c->scale; 980 else $sc = 99; // always force change if scale not known. 981 982 if ($sc == -1) $sc = false; 983 list($fsize, $fprec) = $this->_getSizePrec($v['SIZE']); 984 958 985 if ($ml == -1) $ml = ''; 959 986 if ($mt == 'X') $ml = $v['SIZE']; 960 if (($mt != $v['TYPE']) || $ml != $v['SIZE']) {987 if (($mt != $v['TYPE']) || ($ml != $fsize || $sc != $fprec) || (isset($v['AUTOINCREMENT']) && $v['AUTOINCREMENT'] != $obj->auto_increment)) { 961 988 $holdflds[$k] = $v; 962 989 } … … 982 1009 983 1010 // We are trying to change the size of the field, if not allowed, simply ignore the request. 984 if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4)) { 985 echo "<h3>$this->alterCol cannot be changed to $flds currently</h3>"; 1011 // $flds[1] holds the type, $flds[2] holds the size -postnuke addition 1012 if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4) 1013 && (isset($flds[0][2]) && is_numeric($flds[0][2]))) { 1014 if ($this->debug) ADOConnection::outp(sprintf("<h3>%s cannot be changed to %s currently</h3>", $flds[0][0], $flds[0][1])); 1015 #echo "<h3>$this->alterCol cannot be changed to $flds currently</h3>"; 986 1016 continue; 987 1017 } … … 992 1022 } 993 1023 1024 if ($dropOldFlds) { 1025 foreach ( $cols as $id => $v ) 1026 if ( !isset($lines[$id]) ) 1027 $sql[] = $alter . $this->dropCol . ' ' . $v->name; 1028 } 994 1029 return $sql; 995 1030 }
Note: See TracChangeset
for help on using the changeset viewer.