Ignore:
Timestamp:
09/26/13 15:41:49 (11 years ago)
Author:
angelo
Message:

Ticket #3491 - Compatibilizar Expresso com novas versoes do PHP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.5.1-evolucao/phpgwapi/inc/adodb/adodb-datadict.inc.php

    r6057 r8222  
    22 
    33/** 
    4   V4.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. 
    55  Released under both BSD license and Lesser GPL library license.  
    66  Whenever there is any discrepancy between the two licenses,  
     
    216216        } 
    217217         
    218  
    219218        function MetaType($t,$len=-1,$fieldobj=false) 
    220219        {                
     
    232231                'INTERVAL' => 'C',  # Postgres 
    233232                'MACADDR' => 'C', # postgres 
     233                'VAR_STRING' => 'C', # mysql 
    234234                ## 
    235235                'LONGCHAR' => 'X', 
     
    259259                'DATETIME' => 'T', 
    260260                'TIMESTAMPTZ' => 'T', 
     261                'SMALLDATETIME' => 'T', 
    261262                'T' => 'T', 
    262263                'TIMESTAMP WITHOUT TIME ZONE' => 'T', // postgresql 
     
    370371        { 
    371372                $rez = 2; 
    372                 $conn = &$this->connection; 
     373                $conn = $this->connection; 
    373374                $saved = $conn->debug; 
    374375                foreach($sql as $line) { 
     
    519520                        if ($lines == null) $lines = array(); 
    520521                        list(,$first) = each($lines); 
    521                         list(,$column_def) = preg_split('/[\t ]+/',$first,2); 
     522                        list(,$column_def) = preg_split("/[\t ]+/",$first,2); 
    522523                } 
    523524                return array(sprintf($this->renameColumn,$tabname,$this->NameQuote($oldcolumn),$this->NameQuote($newcolumn),$column_def)); 
     
    589590                return $sql; 
    590591        } 
     592                 
     593         
    591594         
    592595        function _GenFields($flds,$widespacing=false) 
     
    814817         
    815818        // 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) 
    817820        {        
    818821                $suffix = ''; 
     
    913916        } 
    914917         
     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         
    915933        /** 
    916934        "Florian Buzin [ easywe ]" <florian.buzin#easywe.de> 
     
    919937        have to know if the col is new or not. It will check on its own. 
    920938        */ 
    921         function ChangeTableSQL($tablename, $flds, $tableoptions = false) 
     939        function ChangeTableSQL($tablename, $flds, $tableoptions = false, $dropOldFlds=false) 
    922940        { 
    923941        global $ADODB_FETCH_MODE; 
     
    952970                                        if (isset($obj->not_null) && $obj->not_null) 
    953971                                                $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                                         
    955975                                        $c = $cols[$k]; 
    956976                                        $ml = $c->max_length; 
    957977                                        $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 
    958985                                        if ($ml == -1) $ml = ''; 
    959986                                        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)) { 
    961988                                                $holdflds[$k] = $v; 
    962989                                        } 
     
    9821009                                 
    9831010                                //  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>"; 
    9861016                                        continue;         
    9871017                                } 
     
    9921022                } 
    9931023                 
     1024                if ($dropOldFlds) { 
     1025                        foreach ( $cols as $id => $v ) 
     1026                            if ( !isset($lines[$id]) )  
     1027                                        $sql[] = $alter . $this->dropCol . ' ' . $v->name; 
     1028                } 
    9941029                return $sql; 
    9951030        } 
Note: See TracChangeset for help on using the changeset viewer.