Changeset 18609 for tmp/version-2_5-test/data/module/DB.php
- Timestamp:
- 2010/03/11 10:35:11 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tmp/version-2_5-test/data/module/DB.php
r15532 r18609 19 19 * @author Tomas V.V.Cox <cox@idecnet.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$ … … 28 28 * Obtain the PEAR class so it can be extended from 29 29 */ 30 31 30 if(!defined('DB_PHP_DIR')) { 32 31 $DB_PHP_DIR = realpath(dirname( __FILE__)); 33 32 define("DB_PHP_DIR", $DB_PHP_DIR); 34 33 } 35 36 34 require_once DB_PHP_DIR . '/PEAR.php'; 35 37 36 38 37 // {{{ constants … … 430 429 * @author Tomas V.V.Cox <cox@idecnet.com> 431 430 * @author Daniel Convissor <danielc@php.net> 432 * @copyright 1997-200 5The PHP Group431 * @copyright 1997-2007 The PHP Group 433 432 * @license http://www.php.net/license/3_0.txt PHP License 3.0 434 * @version Release: @package_version@433 * @version Release: 1.7.14RC1 435 434 * @link http://pear.php.net/package/DB 436 435 */ … … 473 472 } 474 473 475 @$obj = &new $classname;474 @$obj = new $classname; 476 475 477 476 foreach ($options as $option => $value) { … … 550 549 } 551 550 552 @$obj = &new $classname;551 @$obj = new $classname; 553 552 554 553 foreach ($options as $option => $value) { … … 561 560 $err = $obj->connect($dsninfo, $obj->getOption('persistent')); 562 561 if (DB::isError($err)) { 563 $err->addUserInfo($dsn); 562 if (is_array($dsn)) { 563 $err->addUserInfo(DB::getDSNString($dsn, true)); 564 } else { 565 $err->addUserInfo($dsn); 566 } 564 567 return $err; 565 568 } … … 578 581 function apiVersion() 579 582 { 580 return ' @package_version@';583 return '1.7.14RC1'; 581 584 } 582 585 … … 631 634 $manips = 'INSERT|UPDATE|DELETE|REPLACE|' 632 635 . 'CREATE|DROP|' 633 . 'LOAD DATA|SELECT .* INTO |COPY|'636 . 'LOAD DATA|SELECT .* INTO .* FROM|COPY|' 634 637 . 'ALTER|GRANT|REVOKE|' 635 638 . 'LOCK|UNLOCK'; … … 814 817 $parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp'; 815 818 $proto_opts = rawurldecode($proto_opts); 819 if (strpos($proto_opts, ':') !== false) { 820 list($proto_opts, $parsed['port']) = explode(':', $proto_opts); 821 } 816 822 if ($parsed['protocol'] == 'tcp') { 817 if (strpos($proto_opts, ':') !== false) { 818 list($parsed['hostspec'], 819 $parsed['port']) = explode(':', $proto_opts); 820 } else { 821 $parsed['hostspec'] = $proto_opts; 822 } 823 $parsed['hostspec'] = $proto_opts; 823 824 } elseif ($parsed['protocol'] == 'unix') { 824 825 $parsed['socket'] = $proto_opts; … … 854 855 855 856 // }}} 857 // {{{ getDSNString() 858 859 /** 860 * Returns the given DSN in a string format suitable for output. 861 * 862 * @param array|string the DSN to parse and format 863 * @param boolean true to hide the password, false to include it 864 * @return string 865 */ 866 function getDSNString($dsn, $hidePassword) { 867 /* Calling parseDSN will ensure that we have all the array elements 868 * defined, and means that we deal with strings and array in the same 869 * manner. */ 870 $dsnArray = DB::parseDSN($dsn); 871 872 if ($hidePassword) { 873 $dsnArray['password'] = 'PASSWORD'; 874 } 875 876 /* Protocol is special-cased, as using the default "tcp" along with an 877 * Oracle TNS connection string fails. */ 878 if (is_string($dsn) && strpos($dsn, 'tcp') === false && $dsnArray['protocol'] == 'tcp') { 879 $dsnArray['protocol'] = false; 880 } 881 882 // Now we just have to construct the actual string. This is ugly. 883 $dsnString = $dsnArray['phptype']; 884 if ($dsnArray['dbsyntax']) { 885 $dsnString .= '('.$dsnArray['dbsyntax'].')'; 886 } 887 $dsnString .= '://' 888 .$dsnArray['username'] 889 .':' 890 .$dsnArray['password'] 891 .'@' 892 .$dsnArray['protocol']; 893 if ($dsnArray['socket']) { 894 $dsnString .= '('.$dsnArray['socket'].')'; 895 } 896 if ($dsnArray['protocol'] && $dsnArray['hostspec']) { 897 $dsnString .= '+'; 898 } 899 $dsnString .= $dsnArray['hostspec']; 900 if ($dsnArray['port']) { 901 $dsnString .= ':'.$dsnArray['port']; 902 } 903 $dsnString .= '/'.$dsnArray['database']; 904 905 /* Option handling. Unfortunately, parseDSN simply places options into 906 * the top-level array, so we'll first get rid of the fields defined by 907 * DB and see what's left. */ 908 unset($dsnArray['phptype'], 909 $dsnArray['dbsyntax'], 910 $dsnArray['username'], 911 $dsnArray['password'], 912 $dsnArray['protocol'], 913 $dsnArray['socket'], 914 $dsnArray['hostspec'], 915 $dsnArray['port'], 916 $dsnArray['database'] 917 ); 918 if (count($dsnArray) > 0) { 919 $dsnString .= '?'; 920 $i = 0; 921 foreach ($dsnArray as $key => $value) { 922 if (++$i > 1) { 923 $dsnString .= '&'; 924 } 925 $dsnString .= $key.'='.$value; 926 } 927 } 928 929 return $dsnString; 930 } 931 932 // }}} 856 933 } 857 934 … … 866 943 * @package DB 867 944 * @author Stig Bakken <ssb@php.net> 868 * @copyright 1997-200 5The PHP Group945 * @copyright 1997-2007 The PHP Group 869 946 * @license http://www.php.net/license/3_0.txt PHP License 3.0 870 * @version Release: @package_version@947 * @version Release: 1.7.14RC1 871 948 * @link http://pear.php.net/package/DB 872 949 */ … … 913 990 * @package DB 914 991 * @author Stig Bakken <ssb@php.net> 915 * @copyright 1997-200 5The PHP Group992 * @copyright 1997-2007 The PHP Group 916 993 * @license http://www.php.net/license/3_0.txt PHP License 3.0 917 * @version Release: @package_version@994 * @version Release: 1.7.14RC1 918 995 * @link http://pear.php.net/package/DB 919 996 */ … … 1095 1172 $object_class = $this->fetchmode_object_class; 1096 1173 } 1097 if ( $this->limit_from !== null) {1174 if (is_null($rownum) && $this->limit_from !== null) { 1098 1175 if ($this->row_counter === null) { 1099 1176 $this->row_counter = $this->limit_from; … … 1127 1204 $arr = (object) $arr; 1128 1205 } else { 1129 $arr = &new $object_class($arr);1206 $arr = new $object_class($arr); 1130 1207 } 1131 1208 } … … 1177 1254 $object_class = $this->fetchmode_object_class; 1178 1255 } 1179 if ( $this->limit_from !== null) {1256 if (is_null($rownum) && $this->limit_from !== null) { 1180 1257 if ($this->row_counter === null) { 1181 1258 $this->row_counter = $this->limit_from; … … 1259 1336 $i++; 1260 1337 } 1261 return$i;1338 $count = $i; 1262 1339 } else { 1263 return $this->dbh->numRows($this->result); 1264 } 1340 $count = $this->dbh->numRows($this->result); 1341 } 1342 1343 /* fbsql is checked for here because limit queries are implemented 1344 * using a TOP() function, which results in fbsql_num_rows still 1345 * returning the total number of rows that would have been returned, 1346 * rather than the real number. As a result, we'll just do the limit 1347 * calculations for fbsql in the same way as a database with emulated 1348 * limits. Unfortunately, we can't just do this in DB_fbsql::numRows() 1349 * because that only gets the result resource, rather than the full 1350 * DB_Result object. */ 1351 if (($this->dbh->features['limit'] === 'emulate' 1352 && $this->limit_from !== null) 1353 || $this->dbh->phptype == 'fbsql') { 1354 $limit_count = is_null($this->limit_count) ? $count : $this->limit_count; 1355 if ($count < $this->limit_from) { 1356 $count = 0; 1357 } elseif ($count < ($this->limit_from + $limit_count)) { 1358 $count -= $this->limit_from; 1359 } else { 1360 $count = $limit_count; 1361 } 1362 } 1363 1364 return $count; 1265 1365 } 1266 1366 … … 1355 1455 * @package DB 1356 1456 * @author Stig Bakken <ssb@php.net> 1357 * @copyright 1997-200 5The PHP Group1457 * @copyright 1997-2007 The PHP Group 1358 1458 * @license http://www.php.net/license/3_0.txt PHP License 3.0 1359 * @version Release: @package_version@1459 * @version Release: 1.7.14RC1 1360 1460 * @link http://pear.php.net/package/DB 1361 1461 * @see DB_common::setFetchMode()
Note: See TracChangeset
for help on using the changeset viewer.