Changeset 17877 for branches/comu-ver2/data/module/DB/oci8.php
- Timestamp:
- 2009/03/06 20:21:51 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/comu-ver2/data/module/DB/oci8.php
r15532 r17877 19 19 * @author James L. Pine <jlp@valinux.com> 20 20 * @author Daniel Convissor <danielc@php.net> 21 * @copyright 1997-200 5The PHP Group21 * @copyright 1997-2007 The PHP Group 22 22 * @license http://www.php.net/license/3_0.txt PHP License 3.0 23 23 * @version CVS: $Id$ … … 46 46 * @author James L. Pine <jlp@valinux.com> 47 47 * @author Daniel Convissor <danielc@php.net> 48 * @copyright 1997-200 5The PHP Group48 * @copyright 1997-2007 The PHP Group 49 49 * @license http://www.php.net/license/3_0.txt PHP License 3.0 50 * @version Release: @package_version@50 * @version Release: 1.7.14RC1 51 51 * @link http://pear.php.net/package/DB 52 52 */ … … 95 95 */ 96 96 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, 115 116 ); 116 117 … … 160 161 */ 161 162 var $manip_query = array(); 163 164 /** 165 * Store of prepared SQL queries. 166 * @var array 167 * @access private 168 */ 169 var $_prepared_queries = array(); 162 170 163 171 … … 217 225 } 218 226 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 219 234 if (function_exists('oci_connect')) { 220 235 if (isset($dsn['new_link']) … … 226 241 : 'oci_connect'; 227 242 } 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']; 234 245 } 235 246 … … 249 260 } else { 250 261 $connect_function = $persistent ? 'OCIPLogon' : 'OCILogon'; 251 if ($d sn['hostspec']) {262 if ($db) { 252 263 $this->connection = @$connect_function($dsn['username'], 253 264 $dsn['password'], 254 $d sn['hostspec']);265 $db); 255 266 } elseif ($dsn['username'] || $dsn['password']) { 256 267 $this->connection = @$connect_function($dsn['username'], … … 323 334 } 324 335 $this->last_stmt = $result; 325 if ( DB::isManip($query)) {336 if ($this->_checkManip($query)) { 326 337 return DB_OK; 327 338 } else { … … 416 427 function freeResult($result) 417 428 { 418 return @OCIFreeStatement($result);429 return is_resource($result) ? OCIFreeStatement($result) : false; 419 430 } 420 431 … … 477 488 $save_stmt = $this->last_stmt; 478 489 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 486 496 if (DB::isError($count) || 487 497 DB::isError($row = $count->fetchRow(DB_FETCHMODE_ORDERED))) 488 498 { 489 $this->last_query = $save_query;490 $this->last_stmt = $save_stmt;491 499 return $this->raiseError(DB_ERROR_NOT_CAPABLE); 492 500 } 501 493 502 return $row[0]; 494 503 } … … 591 600 $this->prepare_types[(int)$stmt] = $types; 592 601 $this->manip_query[(int)$stmt] = DB::isManip($query); 602 $this->_prepared_queries[(int)$stmt] = $newquery; 593 603 return $stmt; 594 604 } … … 621 631 $data = (array)$data; 622 632 $this->last_parameters = $data; 633 $this->last_query = $this->_prepared_queries[(int)$stmt]; 623 634 $this->_data = $data; 624 635 625 $types = &$this->prepare_types[(int)$stmt];636 $types = $this->prepare_types[(int)$stmt]; 626 637 if (count($types) != count($data)) { 627 $tmp = &$this->raiseError(DB_ERROR_MISMATCH);638 $tmp = $this->raiseError(DB_ERROR_MISMATCH); 628 639 return $tmp; 629 640 } … … 644 655 $fp = @fopen($data[$key], 'rb'); 645 656 if (!$fp) { 646 $tmp = &$this->raiseError(DB_ERROR_ACCESS_VIOLATION);657 $tmp = $this->raiseError(DB_ERROR_ACCESS_VIOLATION); 647 658 return $tmp; 648 659 } 649 660 $data[$key] = fread($fp, filesize($data[$key])); 650 661 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 } 651 668 } 652 669 if (!@OCIBindByName($stmt, ':bind' . $i, $data[$key], -1)) { … … 654 671 return $tmp; 655 672 } 673 $this->last_query = preg_replace("/:bind$i/",$this->quoteSmart($data[$key]),$this->last_query,1); 656 674 $i++; 657 675 } … … 666 684 } 667 685 $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; 669 689 $tmp = DB_OK; 670 690 } else { 691 $this->_last_query_manip = false; 671 692 @ocisetprefetch($stmt, $this->options['result_buffering']); 672 $tmp = &new DB_result($this, $stmt);693 $tmp = new DB_result($this, $stmt); 673 694 } 674 695 return $tmp; … … 798 819 $result = $this->prepare("SELECT * FROM ($query) " 799 820 . 'WHERE NULL = NULL'); 800 $tmp = &$this->execute($result, $params);821 $tmp = $this->execute($result, $params); 801 822 } else { 802 823 $q_fields = "SELECT * FROM ($query) WHERE NULL = NULL"; … … 858 879 do { 859 880 $this->expectError(DB_ERROR_NOSUCHTABLE); 860 $result = &$this->query("SELECT ${seqname}.nextval FROM dual");881 $result = $this->query("SELECT ${seqname}.nextval FROM dual"); 861 882 $this->popExpect(); 862 883 if ($ondemand && DB::isError($result) && … … 1016 1037 return $this->oci8RaiseError($stmt); 1017 1038 } 1018 1039 1019 1040 $i = 0; 1020 1041 while (@OCIFetch($stmt)) { … … 1099 1120 case 'synonyms': 1100 1121 return 'SELECT synonym_name FROM user_synonyms'; 1122 case 'views': 1123 return 'SELECT view_name FROM user_views'; 1101 1124 default: 1102 1125 return null; … … 1104 1127 } 1105 1128 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 1106 1145 // }}} 1107 1146
Note: See TracChangeset
for help on using the changeset viewer.