Ignore:
Timestamp:
2009/03/06 20:21:51 (15 years ago)
Author:
Seasoft
Message:

・PEAR::DB を Ver.1.7.14RC1(2007-11-27)ベースに更改。
・不適切な文字列比較を修正。

 http://xoops.ec-cube.net/modules/newbb/viewtopic.php?topic_id=1808&forum=9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/comu-ver2/data/module/DB/oci8.php

    r15532 r17877  
    1919 * @author     James L. Pine <jlp@valinux.com> 
    2020 * @author     Daniel Convissor <danielc@php.net> 
    21  * @copyright  1997-2005 The PHP Group 
     21 * @copyright  1997-2007 The PHP Group 
    2222 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0 
    2323 * @version    CVS: $Id$ 
     
    4646 * @author     James L. Pine <jlp@valinux.com> 
    4747 * @author     Daniel Convissor <danielc@php.net> 
    48  * @copyright  1997-2005 The PHP Group 
     48 * @copyright  1997-2007 The PHP Group 
    4949 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0 
    50  * @version    Release: @package_version@ 
     50 * @version    Release: 1.7.14RC1 
    5151 * @link       http://pear.php.net/package/DB 
    5252 */ 
     
    9595     */ 
    9696    var $errorcode_map = array( 
    97         1    => DB_ERROR_CONSTRAINT, 
    98         900  => DB_ERROR_SYNTAX, 
    99         904  => DB_ERROR_NOSUCHFIELD, 
    100         913  => DB_ERROR_VALUE_COUNT_ON_ROW, 
    101         921  => DB_ERROR_SYNTAX, 
    102         923  => DB_ERROR_SYNTAX, 
    103         942  => DB_ERROR_NOSUCHTABLE, 
    104         955  => DB_ERROR_ALREADY_EXISTS, 
    105         1400 => DB_ERROR_CONSTRAINT_NOT_NULL, 
    106         1401 => DB_ERROR_INVALID, 
    107         1407 => DB_ERROR_CONSTRAINT_NOT_NULL, 
    108         1418 => DB_ERROR_NOT_FOUND, 
    109         1476 => DB_ERROR_DIVZERO, 
    110         1722 => DB_ERROR_INVALID_NUMBER, 
    111         2289 => DB_ERROR_NOSUCHTABLE, 
    112         2291 => DB_ERROR_CONSTRAINT, 
    113         2292 => DB_ERROR_CONSTRAINT, 
    114         2449 => DB_ERROR_CONSTRAINT, 
     97        1     => DB_ERROR_CONSTRAINT, 
     98        900   => DB_ERROR_SYNTAX, 
     99        904   => DB_ERROR_NOSUCHFIELD, 
     100        913   => DB_ERROR_VALUE_COUNT_ON_ROW, 
     101        921   => DB_ERROR_SYNTAX, 
     102        923   => DB_ERROR_SYNTAX, 
     103        942   => DB_ERROR_NOSUCHTABLE, 
     104        955   => DB_ERROR_ALREADY_EXISTS, 
     105        1400  => DB_ERROR_CONSTRAINT_NOT_NULL, 
     106        1401  => DB_ERROR_INVALID, 
     107        1407  => DB_ERROR_CONSTRAINT_NOT_NULL, 
     108        1418  => DB_ERROR_NOT_FOUND, 
     109        1476  => DB_ERROR_DIVZERO, 
     110        1722  => DB_ERROR_INVALID_NUMBER, 
     111        2289  => DB_ERROR_NOSUCHTABLE, 
     112        2291  => DB_ERROR_CONSTRAINT, 
     113        2292  => DB_ERROR_CONSTRAINT, 
     114        2449  => DB_ERROR_CONSTRAINT, 
     115        12899 => DB_ERROR_INVALID, 
    115116    ); 
    116117 
     
    160161     */ 
    161162    var $manip_query = array(); 
     163 
     164    /** 
     165     * Store of prepared SQL queries. 
     166     * @var array 
     167     * @access private 
     168     */ 
     169    var $_prepared_queries = array(); 
    162170 
    163171 
     
    217225        } 
    218226 
     227        // Backwards compatibility with DB < 1.7.0 
     228        if (empty($dsn['database']) && !empty($dsn['hostspec'])) { 
     229            $db = $dsn['hostspec']; 
     230        } else { 
     231            $db = $dsn['database']; 
     232        } 
     233 
    219234        if (function_exists('oci_connect')) { 
    220235            if (isset($dsn['new_link']) 
     
    226241                                    : 'oci_connect'; 
    227242            } 
    228  
    229             // Backwards compatibility with DB < 1.7.0 
    230             if (empty($dsn['database']) && !empty($dsn['hostspec'])) { 
    231                 $db = $dsn['hostspec']; 
    232             } else { 
    233                 $db = $dsn['database']; 
     243            if (isset($this->dsn['port']) && $this->dsn['port']) { 
     244                $db = '//'.$db.':'.$this->dsn['port']; 
    234245            } 
    235246 
     
    249260        } else { 
    250261            $connect_function = $persistent ? 'OCIPLogon' : 'OCILogon'; 
    251             if ($dsn['hostspec']) { 
     262            if ($db) { 
    252263                $this->connection = @$connect_function($dsn['username'], 
    253264                                                       $dsn['password'], 
    254                                                        $dsn['hostspec']); 
     265                                                       $db); 
    255266            } elseif ($dsn['username'] || $dsn['password']) { 
    256267                $this->connection = @$connect_function($dsn['username'], 
     
    323334        } 
    324335        $this->last_stmt = $result; 
    325         if (DB::isManip($query)) { 
     336        if ($this->_checkManip($query)) { 
    326337            return DB_OK; 
    327338        } else { 
     
    416427    function freeResult($result) 
    417428    { 
    418         return @OCIFreeStatement($result); 
     429        return is_resource($result) ? OCIFreeStatement($result) : false; 
    419430    } 
    420431 
     
    477488            $save_stmt = $this->last_stmt; 
    478489 
    479             if (count($this->_data)) { 
    480                 $smt = $this->prepare('SELECT COUNT(*) FROM ('.$this->last_query.')'); 
    481                 $count = $this->execute($smt, $this->_data); 
    482             } else { 
    483                 $count =& $this->query($countquery); 
    484             } 
    485  
     490            $count = $this->query($countquery); 
     491 
     492            // Restore the last query and statement. 
     493            $this->last_query = $save_query; 
     494            $this->last_stmt = $save_stmt; 
     495             
    486496            if (DB::isError($count) || 
    487497                DB::isError($row = $count->fetchRow(DB_FETCHMODE_ORDERED))) 
    488498            { 
    489                 $this->last_query = $save_query; 
    490                 $this->last_stmt = $save_stmt; 
    491499                return $this->raiseError(DB_ERROR_NOT_CAPABLE); 
    492500            } 
     501 
    493502            return $row[0]; 
    494503        } 
     
    591600        $this->prepare_types[(int)$stmt] = $types; 
    592601        $this->manip_query[(int)$stmt] = DB::isManip($query); 
     602        $this->_prepared_queries[(int)$stmt] = $newquery; 
    593603        return $stmt; 
    594604    } 
     
    621631        $data = (array)$data; 
    622632        $this->last_parameters = $data; 
     633        $this->last_query = $this->_prepared_queries[(int)$stmt]; 
    623634        $this->_data = $data; 
    624635 
    625         $types =& $this->prepare_types[(int)$stmt]; 
     636        $types = $this->prepare_types[(int)$stmt]; 
    626637        if (count($types) != count($data)) { 
    627             $tmp =& $this->raiseError(DB_ERROR_MISMATCH); 
     638            $tmp = $this->raiseError(DB_ERROR_MISMATCH); 
    628639            return $tmp; 
    629640        } 
     
    644655                $fp = @fopen($data[$key], 'rb'); 
    645656                if (!$fp) { 
    646                     $tmp =& $this->raiseError(DB_ERROR_ACCESS_VIOLATION); 
     657                    $tmp = $this->raiseError(DB_ERROR_ACCESS_VIOLATION); 
    647658                    return $tmp; 
    648659                } 
    649660                $data[$key] = fread($fp, filesize($data[$key])); 
    650661                fclose($fp); 
     662            } elseif ($types[$i] == DB_PARAM_SCALAR) { 
     663                // Floats have to be converted to a locale-neutral 
     664                // representation. 
     665                if (is_float($data[$key])) { 
     666                    $data[$key] = $this->quoteFloat($data[$key]); 
     667                } 
    651668            } 
    652669            if (!@OCIBindByName($stmt, ':bind' . $i, $data[$key], -1)) { 
     
    654671                return $tmp; 
    655672            } 
     673            $this->last_query = preg_replace("/:bind$i/",$this->quoteSmart($data[$key]),$this->last_query,1); 
    656674            $i++; 
    657675        } 
     
    666684        } 
    667685        $this->last_stmt = $stmt; 
    668         if ($this->manip_query[(int)$stmt]) { 
     686        if ($this->manip_query[(int)$stmt] || $this->_next_query_manip) { 
     687            $this->_last_query_manip = true; 
     688            $this->_next_query_manip = false; 
    669689            $tmp = DB_OK; 
    670690        } else { 
     691            $this->_last_query_manip = false; 
    671692            @ocisetprefetch($stmt, $this->options['result_buffering']); 
    672             $tmp =& new DB_result($this, $stmt); 
     693            $tmp = new DB_result($this, $stmt); 
    673694        } 
    674695        return $tmp; 
     
    798819            $result = $this->prepare("SELECT * FROM ($query) " 
    799820                                     . 'WHERE NULL = NULL'); 
    800             $tmp =& $this->execute($result, $params); 
     821            $tmp = $this->execute($result, $params); 
    801822        } else { 
    802823            $q_fields = "SELECT * FROM ($query) WHERE NULL = NULL"; 
     
    858879        do { 
    859880            $this->expectError(DB_ERROR_NOSUCHTABLE); 
    860             $result =& $this->query("SELECT ${seqname}.nextval FROM dual"); 
     881            $result = $this->query("SELECT ${seqname}.nextval FROM dual"); 
    861882            $this->popExpect(); 
    862883            if ($ondemand && DB::isError($result) && 
     
    10161037                return $this->oci8RaiseError($stmt); 
    10171038            } 
    1018  
     1039             
    10191040            $i = 0; 
    10201041            while (@OCIFetch($stmt)) { 
     
    10991120            case 'synonyms': 
    11001121                return 'SELECT synonym_name FROM user_synonyms'; 
     1122            case 'views': 
     1123                return 'SELECT view_name FROM user_views'; 
    11011124            default: 
    11021125                return null; 
     
    11041127    } 
    11051128 
     1129    // }}} 
     1130    // {{{ quoteFloat() 
     1131 
     1132    /** 
     1133     * Formats a float value for use within a query in a locale-independent 
     1134     * manner. 
     1135     * 
     1136     * @param float the float value to be quoted. 
     1137     * @return string the quoted string. 
     1138     * @see DB_common::quoteSmart() 
     1139     * @since Method available since release 1.7.8. 
     1140     */ 
     1141    function quoteFloat($float) { 
     1142        return $this->escapeSimple(str_replace(',', '.', strval(floatval($float)))); 
     1143    } 
     1144      
    11061145    // }}} 
    11071146 
Note: See TracChangeset for help on using the changeset viewer.