Ignore:
Timestamp:
2013/08/02 13:22:57 (11 years ago)
Author:
Seasoft
Message:

#2322 (セッションのGC処理がエラーとなる)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/module/MDB2/Driver/Datatype/Common.php

    r20119 r23022  
    4343// +----------------------------------------------------------------------+ 
    4444// 
    45 // $Id: Common.php,v 1.139 2008/12/04 11:50:42 afz Exp $ 
     45// $Id: Common.php 328137 2012-10-25 02:26:35Z danielc $ 
    4646 
    4747require_once 'MDB2/LOB.php'; 
     
    101101    { 
    102102        $types = $this->valid_default_values; 
    103         $db =& $this->getDBInstance(); 
    104         if (PEAR::isError($db)) { 
     103        $db = $this->getDBInstance(); 
     104        if (MDB2::isError($db)) { 
    105105            return $db; 
    106106        } 
     
    146146        foreach ($types as $key => $type) { 
    147147            if (!isset($this->valid_default_values[$type])) { 
    148                 $db =& $this->getDBInstance(); 
    149                 if (PEAR::isError($db)) { 
     148                $db = $this->getDBInstance(); 
     149                if (MDB2::isError($db)) { 
    150150                    return $db; 
    151151                } 
     
    210210        } 
    211211 
    212         $db =& $this->getDBInstance(); 
    213         if (PEAR::isError($db)) { 
     212        $db = $this->getDBInstance(); 
     213        if (MDB2::isError($db)) { 
    214214            return $db; 
    215215        } 
     
    233233    function convertResult($value, $type, $rtrim = true) 
    234234    { 
    235         if (is_null($value)) { 
     235        if (null === $value) { 
    236236            return null; 
    237237        } 
    238         $db =& $this->getDBInstance(); 
    239         if (PEAR::isError($db)) { 
     238        $db = $this->getDBInstance(); 
     239        if (MDB2::isError($db)) { 
    240240            return $db; 
    241241        } 
     
    264264    function convertResultRow($types, $row, $rtrim = true) 
    265265    { 
    266         $types = $this->_sortResultFieldTypes(array_keys($row), $types); 
     266        //$types = $this->_sortResultFieldTypes(array_keys($row), $types); 
     267        $keys = array_keys($row); 
     268        if (is_int($keys[0])) { 
     269            $types = $this->_sortResultFieldTypes($keys, $types); 
     270        } 
    267271        foreach ($row as $key => $value) { 
    268272            if (empty($types[$key])) { 
     
    270274            } 
    271275            $value = $this->convertResult($row[$key], $types[$key], $rtrim); 
    272             if (PEAR::isError($value)) { 
     276            if (MDB2::isError($value)) { 
    273277                return $value; 
    274278            } 
     
    314318            reset($types); 
    315319            foreach (array_keys($sorted_types) as $k) { 
    316                 if (is_null($sorted_types[$k])) { 
     320                if (null === $sorted_types[$k]) { 
    317321                    $sorted_types[$k] = current($types); 
    318322                    next($types); 
     
    339343    function getDeclaration($type, $name, $field) 
    340344    { 
    341         $db =& $this->getDBInstance(); 
    342         if (PEAR::isError($db)) { 
     345        $db = $this->getDBInstance(); 
     346        if (MDB2::isError($db)) { 
    343347            return $db; 
    344348        } 
     
    388392    function getTypeDeclaration($field) 
    389393    { 
    390         $db =& $this->getDBInstance(); 
    391         if (PEAR::isError($db)) { 
     394        $db = $this->getDBInstance(); 
     395        if (MDB2::isError($db)) { 
    392396            return $db; 
    393397        } 
     
    454458    function _getDeclaration($name, $field) 
    455459    { 
    456         $db =& $this->getDBInstance(); 
    457         if (PEAR::isError($db)) { 
     460        $db = $this->getDBInstance(); 
     461        if (MDB2::isError($db)) { 
    458462            return $db; 
    459463        } 
     
    461465        $name = $db->quoteIdentifier($name, true); 
    462466        $declaration_options = $db->datatype->_getDeclarationOptions($field); 
    463         if (PEAR::isError($declaration_options)) { 
     467        if (MDB2::isError($declaration_options)) { 
    464468            return $declaration_options; 
    465469        } 
     
    502506        if (array_key_exists('default', $field)) { 
    503507            if ($field['default'] === '') { 
    504                 $db =& $this->getDBInstance(); 
    505                 if (PEAR::isError($db)) { 
     508                $db = $this->getDBInstance(); 
     509                if (MDB2::isError($db)) { 
    506510                    return $db; 
    507511                } 
    508512                $valid_default_values = $this->getValidTypes(); 
    509513                $field['default'] = $valid_default_values[$field['type']]; 
    510                 if ($field['default'] === ''&& ($db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL)) { 
     514                if ($field['default'] === '' && ($db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL)) { 
    511515                    $field['default'] = ' '; 
    512516                } 
    513517            } 
    514             if (!is_null($field['default'])) { 
     518            if (null !== $field['default']) { 
    515519                $default = ' DEFAULT ' . $this->quote($field['default'], $field['type']); 
    516520            } 
     
    525529    // }}} 
    526530    // {{{ _getCharsetFieldDeclaration() 
    527      
     531 
    528532    /** 
    529533     * Obtain DBMS specific SQL code portion needed to set the CHARACTER SET 
     
    584588    { 
    585589        if (!empty($field['unsigned'])) { 
    586             $db =& $this->getDBInstance(); 
    587             if (PEAR::isError($db)) { 
     590            $db = $this->getDBInstance(); 
     591            if (MDB2::isError($db)) { 
    588592                return $db; 
    589593            } 
     
    652656    function _getCLOBDeclaration($name, $field) 
    653657    { 
    654         $db =& $this->getDBInstance(); 
    655         if (PEAR::isError($db)) { 
     658        $db = $this->getDBInstance(); 
     659        if (MDB2::isError($db)) { 
    656660            return $db; 
    657661        } 
     
    688692    function _getBLOBDeclaration($name, $field) 
    689693    { 
    690         $db =& $this->getDBInstance(); 
    691         if (PEAR::isError($db)) { 
     694        $db = $this->getDBInstance(); 
     695        if (MDB2::isError($db)) { 
    692696            return $db; 
    693697        } 
     
    876880 
    877881        if (!method_exists($this, "_compare{$type}Definition")) { 
    878             $db =& $this->getDBInstance(); 
    879             if (PEAR::isError($db)) { 
     882            $db = $this->getDBInstance(); 
     883            if (MDB2::isError($db)) { 
    880884                return $db; 
    881885            } 
     
    906910 
    907911        $previous_default = array_key_exists('default', $previous) ? $previous['default'] : 
    908             ($previous_notnull ? '' : null); 
     912            null; 
    909913        $default = array_key_exists('default', $current) ? $current['default'] : 
    910             ($notnull ? '' : null); 
     914            null; 
    911915        if ($previous_default !== $default) { 
    912916            $change['default'] = true; 
     
    930934    { 
    931935        $change = array(); 
     936        $previous_length = !empty($previous['length']) ? $previous['length'] : 4; 
     937        $length = !empty($current['length']) ? $current['length'] : 4; 
     938        if ($previous_length != $length) { 
     939            $change['length'] = $length; 
     940        } 
    932941        $previous_unsigned = !empty($previous['unsigned']) ? $previous['unsigned'] : false; 
    933942        $unsigned = !empty($current['unsigned']) ? $current['unsigned'] : false; 
     
    11151124    function quote($value, $type = null, $quote = true, $escape_wildcards = false) 
    11161125    { 
    1117         $db =& $this->getDBInstance(); 
    1118         if (PEAR::isError($db)) { 
     1126        $db = $this->getDBInstance(); 
     1127        if (MDB2::isError($db)) { 
    11191128            return $db; 
    11201129        } 
    11211130 
    1122         if (is_null($value) 
     1131        if ((null === $value) 
    11231132            || ($value === '' && $db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL) 
    11241133        ) { 
     
    11291138        } 
    11301139 
    1131         if (is_null($type)) { 
     1140        if (null === $type) { 
    11321141            switch (gettype($value)) { 
    11331142            case 'integer': 
     
    12191228        } 
    12201229 
    1221         $db =& $this->getDBInstance(); 
    1222         if (PEAR::isError($db)) { 
     1230        $db = $this->getDBInstance(); 
     1231        if (MDB2::isError($db)) { 
    12231232            return $db; 
    12241233        } 
    12251234 
    12261235        $value = $db->escape($value, $escape_wildcards); 
    1227         if (PEAR::isError($value)) { 
     1236        if (MDB2::isError($value)) { 
    12281237            return $value; 
    12291238        } 
     
    12481257        if (preg_match('/^(\w+:\/\/)(.*)$/', $value, $match)) { 
    12491258            $close = true; 
    1250             if ($match[1] == 'file://') { 
     1259            if (strtolower($match[1]) == 'file://') { 
    12511260                $value = $match[2]; 
    12521261            } 
     
    12551264 
    12561265        if (is_resource($value)) { 
    1257             $db =& $this->getDBInstance(); 
    1258             if (PEAR::isError($db)) { 
     1266            $db = $this->getDBInstance(); 
     1267            if (MDB2::isError($db)) { 
    12591268                return $db; 
    12601269            } 
     
    12891298    function _quoteLOB($value, $quote, $escape_wildcards) 
    12901299    { 
    1291         $value = $this->_readFile($value); 
    1292         if (PEAR::isError($value)) { 
    1293             return $value; 
     1300        $db = $this->getDBInstance(); 
     1301        if (MDB2::isError($db)) { 
     1302            return $db; 
     1303        } 
     1304        if ($db->options['lob_allow_url_include']) { 
     1305            $value = $this->_readFile($value); 
     1306            if (MDB2::isError($value)) { 
     1307                return $value; 
     1308            } 
    12941309        } 
    12951310        return $this->_quoteText($value, $quote, $escape_wildcards); 
     
    13701385    { 
    13711386        if ($value === 'CURRENT_DATE') { 
    1372             $db =& $this->getDBInstance(); 
    1373             if (PEAR::isError($db)) { 
     1387            $db = $this->getDBInstance(); 
     1388            if (MDB2::isError($db)) { 
    13741389                return $db; 
    13751390            } 
    1376             if (isset($db->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) { 
     1391            if (isset($db->function) && is_object($this->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) { 
    13771392                return $db->function->now('date'); 
    13781393            } 
     
    13991414    { 
    14001415        if ($value === 'CURRENT_TIMESTAMP') { 
    1401             $db =& $this->getDBInstance(); 
    1402             if (PEAR::isError($db)) { 
     1416            $db = $this->getDBInstance(); 
     1417            if (MDB2::isError($db)) { 
    14031418                return $db; 
    14041419            } 
    1405             if (isset($db->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) { 
     1420            if (isset($db->function) && is_object($db->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) { 
    14061421                return $db->function->now('timestamp'); 
    14071422            } 
     
    14281443    { 
    14291444        if ($value === 'CURRENT_TIME') { 
    1430             $db =& $this->getDBInstance(); 
    1431             if (PEAR::isError($db)) { 
     1445            $db = $this->getDBInstance(); 
     1446            if (MDB2::isError($db)) { 
    14321447                return $db; 
    14331448            } 
    1434             if (isset($db->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) { 
     1449            if (isset($db->function) && is_object($this->function) && is_a($db->function, 'MDB2_Driver_Function_Common')) { 
    14351450                return $db->function->now('time'); 
    14361451            } 
     
    15181533    function writeLOBToFile($lob, $file) 
    15191534    { 
    1520         $db =& $this->getDBInstance(); 
    1521         if (PEAR::isError($db)) { 
     1535        $db = $this->getDBInstance(); 
     1536        if (MDB2::isError($db)) { 
    15221537            return $db; 
    15231538        } 
     
    15551570    function _retrieveLOB(&$lob) 
    15561571    { 
    1557         if (is_null($lob['value'])) { 
     1572        if (null === $lob['value']) { 
    15581573            $lob['value'] = $lob['resource']; 
    15591574        } 
     
    16821697    function matchPattern($pattern, $operator = null, $field = null) 
    16831698    { 
    1684         $db =& $this->getDBInstance(); 
    1685         if (PEAR::isError($db)) { 
     1699        $db = $this->getDBInstance(); 
     1700        if (MDB2::isError($db)) { 
    16861701            return $db; 
    16871702        } 
    16881703 
    16891704        $match = ''; 
    1690         if (!is_null($operator)) { 
     1705        if (null !== $operator) { 
    16911706            $operator = strtoupper($operator); 
    16921707            switch ($operator) { 
    16931708            // case insensitive 
    16941709            case 'ILIKE': 
    1695                 if (is_null($field)) { 
     1710                if (null === $field) { 
    16961711                    return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, 
    16971712                        'case insensitive LIKE matching requires passing the field name', __FUNCTION__); 
     
    17001715                $match = $db->function->lower($field).' LIKE '; 
    17011716                break; 
     1717            case 'NOT ILIKE': 
     1718                if (null === $field) { 
     1719                    return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, 
     1720                        'case insensitive NOT ILIKE matching requires passing the field name', __FUNCTION__); 
     1721                } 
     1722                $db->loadModule('Function', null, true); 
     1723                $match = $db->function->lower($field).' NOT LIKE '; 
     1724                break; 
    17021725            // case sensitive 
    17031726            case 'LIKE': 
    1704                 $match = is_null($field) ? 'LIKE ' : $field.' LIKE '; 
     1727                $match = (null === $field) ? 'LIKE ' : ($field.' LIKE '); 
     1728                break; 
     1729            case 'NOT LIKE': 
     1730                $match = (null === $field) ? 'NOT LIKE ' : ($field.' NOT LIKE '); 
    17051731                break; 
    17061732            default: 
     
    17141740                $match.= $value; 
    17151741            } else { 
    1716                 if ($operator === 'ILIKE') { 
    1717                     $value = strtolower($value); 
    1718                 } 
    17191742                $escaped = $db->escape($value); 
    1720                 if (PEAR::isError($escaped)) { 
     1743                if (MDB2::isError($escaped)) { 
    17211744                    return $escaped; 
    17221745                } 
     
    17561779    function mapNativeDatatype($field) 
    17571780    { 
    1758         $db =& $this->getDBInstance(); 
    1759         if (PEAR::isError($db)) { 
     1781        $db = $this->getDBInstance(); 
     1782        if (MDB2::isError($db)) { 
    17601783            return $db; 
    17611784        } 
     
    17851808    function _mapNativeDatatype($field) 
    17861809    { 
    1787         $db =& $this->getDBInstance(); 
    1788         if (PEAR::isError($db)) { 
     1810        $db = $this->getDBInstance(); 
     1811        if (MDB2::isError($db)) { 
    17891812            return $db; 
    17901813        } 
     
    18061829    function mapPrepareDatatype($type) 
    18071830    { 
    1808         $db =& $this->getDBInstance(); 
    1809         if (PEAR::isError($db)) { 
     1831        $db = $this->getDBInstance(); 
     1832        if (MDB2::isError($db)) { 
    18101833            return $db; 
    18111834        } 
Note: See TracChangeset for help on using the changeset viewer.